Skip to content

Commit

Permalink
Merge pull request #10 from asnunes/fix/safari-issue
Browse files Browse the repository at this point in the history
Publish
  • Loading branch information
asnunes committed Sep 21, 2021
2 parents 71ae8b9 + 9a79edd commit 6799980
Show file tree
Hide file tree
Showing 10 changed files with 7,785 additions and 13 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish
on:
push:
branches: [main, master]
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Dependencies installation
run: npm install
- name: Test run
run: npm test
- name: Build
run: npm run build
- name: Publish
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Test
on:
pull_request:
branches: [main, master]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Build test compose
run: |
make test-build
make test
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ tsconfig.json
.prettierrc.js
.tool-versions
.vscode
Dockerfile*
docker-compose*
.github
makefile
6 changes: 6 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:14.17
WORKDIR /usr/src/mathml-to-latex
RUN npm -g i npm
COPY ./package*.json ./
RUN npm install
COPY . .
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import {
mfencedWithSeparatorAttribute,
mfencedWithBrokenAttributeCase1,
mfencedWithBrokenAttributeCase2,
mfencedWithBrokenAttributeCase4,
mfencedWithBrokenAttributeCase3,
mfencedWithBrokenAttributeCase5,
} from '../../mocks/mathmlStrings';

describe('#convert', () => {
Expand Down Expand Up @@ -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;
Expand All @@ -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: [] }],
},
],
});
});
});
});
36 changes: 36 additions & 0 deletions __tests__/mocks/mathmlStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>';
Expand Down
15 changes: 15 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.8'
services:
mathml-to-latex-test:
build:
context: .
dockerfile: Dockerfile.test
container_name: mathml-to-latex-test
logging:
driver: 'json-file'
options:
max-size: '10m'
max-file: '5'
working_dir: /usr/src/mathml-to-latex
command: |
npm run test
14 changes: 14 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# TEST
test_compose = docker-compose -f docker-compose.test.yml

.PRONY: test-build
test-build:
$(test_compose) build

.PRONY: test
test:
make test-build && $(test_compose) run mathml-to-latex-test && make test-down

.PRONY: test-down
test-down:
$(test_compose) down
Loading

0 comments on commit 6799980

Please sign in to comment.