Skip to content

Commit

Permalink
fix: don't use snapshot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
airtonix committed Nov 13, 2024
1 parent 8c05a91 commit d62424a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 213 deletions.
99 changes: 0 additions & 99 deletions src/__snapshots__/core-remark-nomnoml.spec.ts.snap

This file was deleted.

99 changes: 0 additions & 99 deletions src/__snapshots__/remark-nomnoml.spec.ts.snap

This file was deleted.

39 changes: 24 additions & 15 deletions src/remark-nomnoml.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,48 @@ import { remarkNomnoml } from './remark-nomnoml';
test.each([
{
name: 'simple',
wordsToSearch: ['Decorator pattern', 'Component', 'operation()'],
diagram:
'```nomnoml\n[<frame>Decorator pattern|Component||+ operation()]\n```',
},
{
name: 'simple with error',
diagram: '```nomnoml\n ] >```\n',
wordsToSearch: [],
invalid: true,
},
{
name: 'class diagram',
wordsToSearch: ['Decorator pattern', 'Component', 'operation()'],
diagram:
'```nomnoml\n[<frame>Decorator pattern|Component||+ operation()]\n```',
},
])('render nomnoml diagram: $name', async ({ diagram, invalid }) => {
const processor = remark();
processor.use(remarkNomnoml);
])(
'render nomnoml diagram: $name',
async ({ diagram, invalid, wordsToSearch }) => {
const processor = remark();
processor.use(remarkNomnoml);

const file = new VFile(diagram);
const file = new VFile(diagram);

if (invalid) {
await expect(() => {
return processor.process(file);
}).rejects.toThrow();
return;
}
if (invalid) {
await expect(() => {
return processor.process(file);
}).rejects.toThrow();
return;
}

expect(file.messages).toHaveLength(0);
expect(file.messages).toHaveLength(0);

await processor.process(file);
await processor.process(file);

expect(file.messages).toHaveLength(0);
expect(file.value).toMatchSnapshot();
});
expect(file.messages).toHaveLength(0);

for (const word of wordsToSearch) {
expect(file.toString()).toContain(word);
}
},
);

test('it should throw a vfile error if a diagram is invalid without error fallback', async () => {
const processor = remark().use(remarkNomnoml);
Expand Down

0 comments on commit d62424a

Please sign in to comment.