summaryrefslogtreecommitdiff
path: root/spec/frontend/notebook/cells/output/latex_spec.js
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/frontend/notebook/cells/output/latex_spec.js
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
downloadgitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/frontend/notebook/cells/output/latex_spec.js')
-rw-r--r--spec/frontend/notebook/cells/output/latex_spec.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/frontend/notebook/cells/output/latex_spec.js b/spec/frontend/notebook/cells/output/latex_spec.js
new file mode 100644
index 00000000000..848d2069421
--- /dev/null
+++ b/spec/frontend/notebook/cells/output/latex_spec.js
@@ -0,0 +1,40 @@
+import { shallowMount } from '@vue/test-utils';
+import LatexOutput from '~/notebook/cells/output/latex.vue';
+import Prompt from '~/notebook/cells/prompt.vue';
+
+describe('LaTeX output cell', () => {
+ beforeEach(() => {
+ window.MathJax = {
+ tex2svg: jest.fn((code) => ({ outerHTML: code })),
+ };
+ });
+
+ const inlineLatex = '$$F(k) = \\int_{-\\infty}^{\\infty} f(x) e^{2\\pi i k} dx$$';
+ const count = 12345;
+
+ const createComponent = (rawCode, index) =>
+ shallowMount(LatexOutput, {
+ propsData: {
+ count,
+ index,
+ rawCode,
+ },
+ });
+
+ it.each`
+ index | expectation
+ ${0} | ${true}
+ ${1} | ${false}
+ `('sets `Prompt.show-output` to $expectation when index is $index', ({ index, expectation }) => {
+ const wrapper = createComponent(inlineLatex, index);
+ const prompt = wrapper.find(Prompt);
+
+ expect(prompt.props().count).toEqual(count);
+ expect(prompt.props().showOutput).toEqual(expectation);
+ });
+
+ it('strips the `$$` delimter from LaTeX', () => {
+ createComponent(inlineLatex, 0);
+ expect(window.MathJax.tex2svg).toHaveBeenCalledWith(expect.not.stringContaining('$$'));
+ });
+});