test: implement test for many missing argument cases

This commit is contained in:
Alexandre Nunes 2021-09-20 22:18:08 -03:00
parent 5507d709c7
commit 22690d3deb
4 changed files with 7707 additions and 12 deletions

@ -11,6 +11,9 @@ import {
mfencedWithSeparatorAttribute,
mfencedWithBrokenAttributeCase1,
mfencedWithBrokenAttributeCase2,
mfencedWithBrokenAttributeCase4,
mfencedWithBrokenAttributeCase3,
mfencedWithBrokenAttributeCase5,
} from '../../mocks/mathmlStrings';
describe('#convert', () => {
@ -130,6 +133,58 @@ describe('#convert', () => {
});
});
describe('given math with two broken mfenced', () => {
test('add attributes to children related with name mfenced', () => {
const mathmlString = mfencedWithBrokenAttributeCase3;
const result = makeSut().convert(mathmlString);
expect(result.length).toBe(1);
expect(result[0]).toMatchObject({
name: 'math',
value: '',
attributes: {},
children: [
{
name: 'mfenced',
value: '',
attributes: { open: '{' },
children: [{ name: 'mn', value: '3', attributes: {}, children: [] }],
},
{
name: 'mfenced',
value: '',
attributes: { open: '{' },
children: [{ name: 'mn', value: '5', attributes: {}, children: [] }],
},
],
});
});
});
describe('given math with two broken arguments', () => {
test('ignore broken args', () => {
const mathmlString = mfencedWithBrokenAttributeCase5;
const result = makeSut().convert(mathmlString);
expect(result.length).toBe(1);
expect(result[0]).toMatchObject({
name: 'math',
value: '',
attributes: {},
children: [
{
name: 'mfenced',
value: '',
attributes: {},
children: [{ name: 'mn', value: '3', attributes: {}, children: [] }],
},
],
});
});
});
describe('given math string with mfenced with single content, open attr settled as { and close attribute with = only', () => {
test('add attributes to children related with name mfenced', () => {
const mathmlString = mfencedWithBrokenAttributeCase2;
@ -152,4 +207,33 @@ describe('#convert', () => {
});
});
});
describe('given math with two broken mfenced', () => {
test('add attributes to children related with name mfenced', () => {
const mathmlString = mfencedWithBrokenAttributeCase4;
const result = makeSut().convert(mathmlString);
expect(result.length).toBe(1);
expect(result[0]).toMatchObject({
name: 'math',
value: '',
attributes: {},
children: [
{
name: 'mfenced',
value: '',
attributes: { open: '{' },
children: [{ name: 'mn', value: '3', attributes: {}, children: [] }],
},
{
name: 'mfenced',
value: '',
attributes: { open: '{' },
children: [{ name: 'mn', value: '5', attributes: {}, children: [] }],
},
],
});
});
});
});

@ -46,6 +46,42 @@ export const mfencedWithBrokenAttributeCase2 = `
</root>
`;
export const mfencedWithBrokenAttributeCase3 = `
<root>
<math>
<mfenced open='{' close >
<mn>3</mn>
</mfenced>
<mfenced open='{' close >
<mn>5</mn>
</mfenced>
</math>
</root>
`;
export const mfencedWithBrokenAttributeCase4 = `
<root>
<math>
<mfenced open='{' close= >
<mn>3</mn>
</mfenced>
<mfenced open='{' close= >
<mn>5</mn>
</mfenced>
</math>
</root>
`;
export const mfencedWithBrokenAttributeCase5 = `
<root>
<math>
<mfenced open='' close= >
<mn>3</mn>
</mfenced>
</math>
</root>
`;
export const mrootWithMi = '<root><math><mi>a</mi></math></root>';
export const mathWithMi = '<math><mi>b</mi></math>';

7597
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -8,7 +8,7 @@
"build": "rm -rf ./dist && tsc",
"watch": "tsc -w",
"lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
"test": "jest --passWithNoTests --silent --noStackTrace --runInBand",
"test": "jest --passWithNoTests --noStackTrace --runInBand",
"test:verbose": "jest --passWithNoTests --runInBand",
"test:watch": "npm run test -- --watch"
},