@codecademy/markdown-overrides
Advanced tools
Comparing version
@@ -6,6 +6,11 @@ # Change Log | ||
## <small>0.2.1-alpha.0a6622.0 (2020-10-01)</small> | ||
## <small>0.2.1-alpha.36dfc3.0 (2020-10-01)</small> | ||
* Add MathBlock ([f0e9bbc](https://github.com/Codecademy/client-modules/commit/f0e9bbc)) | ||
* Feedback ([5fdaef4](https://github.com/Codecademy/client-modules/commit/5fdaef4)) | ||
* Fix formatting ([0a66224](https://github.com/Codecademy/client-modules/commit/0a66224)) | ||
* Formatting ([36dfc32](https://github.com/Codecademy/client-modules/commit/36dfc32)) | ||
* One more refactor ([be2667c](https://github.com/Codecademy/client-modules/commit/be2667c)) | ||
* Update tests ([92f942c](https://github.com/Codecademy/client-modules/commit/92f942c)) | ||
* Use shared variable in tests ([9b95edc](https://github.com/Codecademy/client-modules/commit/9b95edc)) | ||
* chore: update changelogs ([8678ae3](https://github.com/Codecademy/client-modules/commit/8678ae3)) | ||
@@ -12,0 +17,0 @@ |
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { MathBlock } from '../'; | ||
jest.mock('katex', function () { | ||
return { | ||
renderToString: function renderToString() { | ||
return '<div>1234</div>'; | ||
} | ||
}; | ||
}); | ||
describe('MathBlock', function () { | ||
it('renders itself and children', function () { | ||
var latexText = '1234'; | ||
var view = render(React.createElement(MathBlock, null, "1234")); | ||
view.getByText(latexText); | ||
describe('with valid LaTex', function () { | ||
it('renders itself and children', function () { | ||
var latexText = '1234'; | ||
var view = render(React.createElement(MathBlock, null, latexText)); | ||
view.getByText(latexText); | ||
}); | ||
}); | ||
describe('with invalid LaTex', function () { | ||
it('catches and renders parsing errors', function () { | ||
var invalidLaTeX = 'invalid & latex'; | ||
var view = render(React.createElement(MathBlock, null, invalidLaTeX)); | ||
view.getByText('parse error', { | ||
exact: false | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -1,3 +0,1 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import React from 'react'; | ||
@@ -7,3 +5,2 @@ import 'katex/dist/katex.css'; | ||
import cx from 'classnames'; | ||
import { isString } from 'lodash'; | ||
import styles from './styles.module.scss'; | ||
@@ -26,8 +23,3 @@ | ||
wrap = _ref$wrap === void 0 ? true : _ref$wrap; | ||
if (!isString(children)) { | ||
throw new Error("MathBlock needs a text node child; got ".concat(children)); | ||
} | ||
var classes = cx(_defineProperty({}, styles.wrap, wrap), styles.MathBlock, className); | ||
var classes = cx(wrap && styles.wrap, styles.MathBlock, className); | ||
var html = getKatex(children); | ||
@@ -34,0 +26,0 @@ return React.createElement("span", { |
{ | ||
"name": "@codecademy/markdown-overrides", | ||
"description": "Markdown overrides React Components for Codecademy", | ||
"version": "0.2.1-alpha.0a6622.0", | ||
"version": "0.2.1-alpha.36dfc3.0", | ||
"author": "Codecademy Engineering", | ||
@@ -32,3 +32,3 @@ "main": "dist/index.js", | ||
"license": "MIT", | ||
"gitHead": "9c8066d298a046de4d88d7eae41a90bc9a6c83e6" | ||
"gitHead": "adb1b4d9280655d0eb5239acfe63d0e3fdbbd67d" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
12598
3.26%227
-2.16%