Skip to content

Commit 46d3ac1

Browse files
Add tests
1 parent a130994 commit 46d3ac1

File tree

2 files changed

+50
-30
lines changed

2 files changed

+50
-30
lines changed

src/plugin/__tests__/VCodeBlock.test.ts

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import VCodeBlock from '../VCodeBlock.vue';
22
import { describe, it, expect } from 'vitest';
33
import { mount } from '@vue/test-utils';
4+
import { pluginName } from '../utils/globals';
45

56

67
describe('VCodeBlock Component', () => {
@@ -11,41 +12,27 @@ describe('VCodeBlock Component', () => {
1112
prismjs: true,
1213
}
1314
});
15+
1416
const returnedProps = wrapper.getComponent(VCodeBlock).props();
1517

16-
expect(returnedProps).toMatchInlineSnapshot(`
17-
{
18-
"browserWindow": false,
19-
"code": "",
20-
"codeBlockRadius": "0.5rem",
21-
"copyButton": true,
22-
"copyFailedText": "Copy failed!",
23-
"copyIcons": true,
24-
"copySuccessText": "Copied!",
25-
"copyTab": true,
26-
"copyText": "Copy Code",
27-
"cssPath": undefined,
28-
"floatingTabs": true,
29-
"globalOptions": false,
30-
"height": "auto",
31-
"highlightjs": false,
32-
"indent": 2,
33-
"label": "",
34-
"lang": "javascript",
35-
"languages": undefined,
36-
"maxHeight": "auto",
37-
"persistentCopyButton": false,
38-
"prismPlugin": false,
39-
"prismjs": true,
40-
"runTab": false,
41-
"runText": "Run",
42-
"tabGap": "0.25rem",
43-
"tabs": false,
44-
"theme": "neon-bunny",
18+
expect(returnedProps).toMatchSnapshot();
19+
});
20+
21+
it('should emit run event', () => {
22+
const wrapper = mount(VCodeBlock, {
23+
props: {
24+
prismjs: true,
25+
runTab: true,
26+
tabs: true,
4527
}
46-
`);
28+
});
29+
30+
wrapper.find(`.${pluginName}--tab-run`).trigger('click');
31+
32+
expect(wrapper.emitted()).toHaveProperty('run');
4733
});
4834

35+
4936
// -------------------------------------------------- Errors //
5037
const throwErrors = {
5138
bothSet: '[vue-code-block]: You cannot have both prismjs and highlightjs props set at the same time.',
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`VCodeBlock Component > should mount the component 1`] = `
4+
{
5+
"browserWindow": false,
6+
"code": "",
7+
"codeBlockRadius": "0.5rem",
8+
"copyButton": true,
9+
"copyFailedText": "Copy failed!",
10+
"copyIcons": true,
11+
"copySuccessText": "Copied!",
12+
"copyTab": true,
13+
"copyText": "Copy Code",
14+
"cssPath": undefined,
15+
"floatingTabs": true,
16+
"globalOptions": false,
17+
"height": "auto",
18+
"highlightjs": false,
19+
"indent": 2,
20+
"label": "",
21+
"lang": "javascript",
22+
"languages": undefined,
23+
"maxHeight": "auto",
24+
"persistentCopyButton": false,
25+
"prismPlugin": false,
26+
"prismjs": true,
27+
"runTab": false,
28+
"runText": "Run",
29+
"tabGap": "0.25rem",
30+
"tabs": false,
31+
"theme": "neon-bunny",
32+
}
33+
`;

0 commit comments

Comments
 (0)