1
1
import VCodeBlock from '../VCodeBlock.vue' ;
2
2
import { describe , it , expect } from 'vitest' ;
3
3
import { mount } from '@vue/test-utils' ;
4
+ import { pluginName } from '../utils/globals' ;
4
5
5
6
6
7
describe ( 'VCodeBlock Component' , ( ) => {
@@ -11,41 +12,27 @@ describe('VCodeBlock Component', () => {
11
12
prismjs : true ,
12
13
}
13
14
} ) ;
15
+
14
16
const returnedProps = wrapper . getComponent ( VCodeBlock ) . props ( ) ;
15
17
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 ,
45
27
}
46
- ` ) ;
28
+ } ) ;
29
+
30
+ wrapper . find ( `.${ pluginName } --tab-run` ) . trigger ( 'click' ) ;
31
+
32
+ expect ( wrapper . emitted ( ) ) . toHaveProperty ( 'run' ) ;
47
33
} ) ;
48
34
35
+
49
36
// -------------------------------------------------- Errors //
50
37
const throwErrors = {
51
38
bothSet : '[vue-code-block]: You cannot have both prismjs and highlightjs props set at the same time.' ,
0 commit comments