File tree Expand file tree Collapse file tree 7 files changed +400
-76
lines changed
Filter options
Expand file tree Collapse file tree 7 files changed +400
-76
lines changed
Original file line number Diff line number Diff line change @@ -7,16 +7,18 @@ import type { FluentVue } from '../../src'
7
7
install ( )
8
8
9
9
export function mountWithFluent < T > (
10
- fluent : FluentVue ,
10
+ fluent : FluentVue | null ,
11
11
component : ComponentOptions < T > ,
12
12
) : VueWrapper < ComponentPublicInstance < T > > {
13
13
if ( isVue3 ) {
14
14
// eslint-disable-next-line @typescript-eslint/no-var-requires
15
15
const { mount } = require ( '@vue/test-utils' )
16
16
17
+ const plugins = fluent ? [ fluent ] : [ ]
18
+
17
19
return mount ( component , {
18
20
global : {
19
- plugins : [ fluent ] ,
21
+ plugins,
20
22
} ,
21
23
} )
22
24
}
@@ -25,7 +27,8 @@ export function mountWithFluent<T>(
25
27
const { createLocalVue, mount } = require ( '@vue/test-utils' )
26
28
27
29
const localVue = createLocalVue ( )
28
- localVue . use ( fluent )
30
+ if ( fluent )
31
+ localVue . use ( fluent )
29
32
return mount ( component , {
30
33
localVue,
31
34
} )
Original file line number Diff line number Diff line change @@ -46,4 +46,29 @@ describe('composition api', () => {
46
46
// Assert
47
47
expect ( mounted . html ( ) ) . toEqual ( '<a href="/foo" aria-label="Aria label">link text</a>' )
48
48
} )
49
+
50
+ it ( 'thrpws when used outside of setup' , ( ) => {
51
+ // Arrange
52
+ // Act
53
+ const use = ( ) => useFluent ( )
54
+
55
+ // Assert
56
+ expect ( use ) . toThrowError ( '[fluent-vue] useFluent called outside of setup' )
57
+ } )
58
+
59
+ it ( 'throws when used without installing plugin' , ( ) => {
60
+ // Arrange
61
+ const component = {
62
+ template : '<span></span>' ,
63
+ setup ( ) {
64
+ useFluent ( )
65
+ } ,
66
+ }
67
+
68
+ // Act
69
+ const mount = ( ) => mountWithFluent ( null , component )
70
+
71
+ // Asser
72
+ expect ( mount ) . toThrowError ( '[fluent-vue] useFluent called without installing plugin' )
73
+ } )
49
74
} )
Original file line number Diff line number Diff line change 83
83
"@ls-lint/ls-lint" : " ^1.11.2" ,
84
84
"@release-it-plugins/lerna-changelog" : " ^5.0.0" ,
85
85
"@types/node" : " ^17.0.10" ,
86
- "@vitest/coverage-c8 " : " ^0.23.4 " ,
86
+ "@vitest/coverage-istanbul " : " ^0.24.3 " ,
87
87
"@vue/compiler-sfc" : " ^3.2.41" ,
88
88
"@vue/test-utils" : " ^2.1.0" ,
89
89
"esbuild-plugin-globals" : " ^0.1.1" ,
You can’t perform that action at this time.
0 commit comments