@codecademy/markdown-overrides
Advanced tools
Comparing version
@@ -6,9 +6,5 @@ # Change Log | ||
## <small>0.2.1-alpha.be2667.0 (2020-10-01)</small> | ||
## 0.3.0-alpha.816f8f.0 (2020-10-01) | ||
* Add MathBlock ([f0e9bbc](https://github.com/Codecademy/client-modules/commit/f0e9bbc)) | ||
* Fix formatting ([0a66224](https://github.com/Codecademy/client-modules/commit/0a66224)) | ||
* 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)) | ||
* feat(markdown-overrides): Add MathBlock component (#977) ([4b46117](https://github.com/Codecademy/client-modules/commit/4b46117)), closes [#977](https://github.com/Codecademy/client-modules/issues/977) | ||
* chore: update changelogs ([8678ae3](https://github.com/Codecademy/client-modules/commit/8678ae3)) | ||
@@ -15,0 +11,0 @@ |
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import katex from 'katex'; | ||
import { MathBlock } from '../'; | ||
jest.mock('katex'); | ||
describe('MathBlock', function () { | ||
@@ -10,3 +8,2 @@ describe('with valid LaTex', function () { | ||
var latexText = '1234'; | ||
katex.renderToString.mockReturnValue("<div>".concat(latexText, "</div>")); | ||
var view = render(React.createElement(MathBlock, null, latexText)); | ||
@@ -18,10 +15,9 @@ view.getByText(latexText); | ||
it('catches and renders parsing errors', function () { | ||
var parsingErrorText = 'parsing error'; | ||
katex.renderToString.mockImplementation(function () { | ||
throw new Error(parsingErrorText); | ||
var invalidLaTeX = 'invalid & latex'; | ||
var view = render(React.createElement(MathBlock, null, invalidLaTeX)); | ||
view.getByText('parse error', { | ||
exact: false | ||
}); | ||
var view = render(React.createElement(MathBlock, null, "children")); | ||
view.getByText(parsingErrorText); | ||
}); | ||
}); | ||
}); |
@@ -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'; | ||
@@ -24,3 +22,3 @@ import 'katex/dist/katex.css'; | ||
wrap = _ref$wrap === void 0 ? true : _ref$wrap; | ||
var classes = cx(_defineProperty({}, styles.wrap, wrap), styles.MathBlock, className); | ||
var classes = cx(wrap && styles.wrap, styles.MathBlock, className); | ||
var html = getKatex(children); | ||
@@ -27,0 +25,0 @@ return React.createElement("span", { |
{ | ||
"name": "@codecademy/markdown-overrides", | ||
"description": "Markdown overrides React Components for Codecademy", | ||
"version": "0.2.1-alpha.be2667.0", | ||
"version": "0.3.0-alpha.816f8f.0", | ||
"author": "Codecademy Engineering", | ||
@@ -32,3 +32,3 @@ "main": "dist/index.js", | ||
"license": "MIT", | ||
"gitHead": "c324cb64c5e1f6da284945cf032a9d8271fd4410" | ||
"gitHead": "9893009162b493301e062b819841f932ce20b083" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
12153
-7.43%227
-6.97%