1
1
import { describe , it , expect , vitest , beforeEach } from 'vitest' ;
2
2
import formatProp from './formatProp' ;
3
3
import formatPropValue from './formatPropValue' ;
4
+ import { Options } from '../options' ;
4
5
5
6
vitest . mock ( './formatPropValue' ) ;
6
7
7
8
const defaultOptions = {
8
9
useBooleanShorthandSyntax : true ,
9
10
tabStop : 2 ,
10
- } ;
11
+ } as any as Options ;
11
12
12
13
describe ( 'formatProp' , ( ) => {
13
14
beforeEach ( ( ) => {
@@ -16,7 +17,7 @@ describe('formatProp', () => {
16
17
} ) ;
17
18
18
19
it ( 'should format prop with only a value' , ( ) => {
19
- formatPropValue . mockReturnValue ( '"MockedPropValue"' ) ;
20
+ vitest . mocked ( formatPropValue ) . mockReturnValue ( '"MockedPropValue"' ) ;
20
21
21
22
expect (
22
23
formatProp ( 'foo' , true , 'bar' , false , null , true , 0 , defaultOptions )
@@ -36,7 +37,7 @@ describe('formatProp', () => {
36
37
} ) ;
37
38
38
39
it ( 'should format prop with only a default value' , ( ) => {
39
- formatPropValue . mockReturnValue ( '"MockedPropValue"' ) ;
40
+ vitest . mocked ( formatPropValue ) . mockReturnValue ( '"MockedPropValue"' ) ;
40
41
41
42
expect (
42
43
formatProp ( 'foo' , false , null , true , 'baz' , true , 0 , defaultOptions )
@@ -56,7 +57,7 @@ describe('formatProp', () => {
56
57
} ) ;
57
58
58
59
it ( 'should format prop with a value and a default value' , ( ) => {
59
- formatPropValue . mockReturnValue ( '"MockedPropValue"' ) ;
60
+ vitest . mocked ( formatPropValue ) . mockReturnValue ( '"MockedPropValue"' ) ;
60
61
61
62
expect (
62
63
formatProp ( 'foo' , true , 'bar' , true , 'baz' , true , 0 , defaultOptions )
@@ -79,9 +80,9 @@ describe('formatProp', () => {
79
80
const options = {
80
81
useBooleanShorthandSyntax : true ,
81
82
tabStop : 2 ,
82
- } ;
83
+ } as Options ;
83
84
84
- formatPropValue . mockReturnValue ( '{true}' ) ;
85
+ vitest . mocked ( formatPropValue ) . mockReturnValue ( '{true}' ) ;
85
86
86
87
expect (
87
88
formatProp ( 'foo' , true , true , false , false , true , 0 , options )
@@ -99,9 +100,9 @@ describe('formatProp', () => {
99
100
const options = {
100
101
useBooleanShorthandSyntax : true ,
101
102
tabStop : 2 ,
102
- } ;
103
+ } as Options ;
103
104
104
- formatPropValue . mockReturnValue ( '{false}' ) ;
105
+ vitest . mocked ( formatPropValue ) . mockReturnValue ( '{false}' ) ;
105
106
106
107
expect (
107
108
formatProp ( 'foo' , true , false , false , null , true , 0 , options )
@@ -118,9 +119,9 @@ describe('formatProp', () => {
118
119
const options = {
119
120
useBooleanShorthandSyntax : false ,
120
121
tabStop : 2 ,
121
- } ;
122
+ } as Options ;
122
123
123
- formatPropValue . mockReturnValue ( '{true}' ) ;
124
+ vitest . mocked ( formatPropValue ) . mockReturnValue ( '{true}' ) ;
124
125
125
126
expect (
126
127
formatProp ( 'foo' , true , true , false , false , true , 0 , options )
@@ -138,9 +139,9 @@ describe('formatProp', () => {
138
139
const options = {
139
140
useBooleanShorthandSyntax : false ,
140
141
tabStop : 2 ,
141
- } ;
142
+ } as Options ;
142
143
143
- formatPropValue . mockReturnValue ( '{false}' ) ;
144
+ vitest . mocked ( formatPropValue ) . mockReturnValue ( '{false}' ) ;
144
145
145
146
expect (
146
147
formatProp ( 'foo' , true , false , false , false , true , 0 , options )
@@ -155,7 +156,7 @@ describe('formatProp', () => {
155
156
} ) ;
156
157
157
158
it ( 'should format a mulitline props' , ( ) => {
158
- formatPropValue . mockReturnValue ( `{[
159
+ vitest . mocked ( formatPropValue ) . mockReturnValue ( `{[
159
160
"a",
160
161
"b"
161
162
]}` ) ;
@@ -202,9 +203,9 @@ describe('formatProp', () => {
202
203
const options = {
203
204
useBooleanShorthandSyntax : true ,
204
205
tabStop : 2 ,
205
- } ;
206
+ } as Options ;
206
207
207
- formatPropValue . mockReturnValue ( '"MockedPropValue"' ) ;
208
+ vitest . mocked ( formatPropValue ) . mockReturnValue ( '"MockedPropValue"' ) ;
208
209
209
210
expect (
210
211
formatProp ( 'foo' , true , 'bar' , false , null , true , 4 , options )
0 commit comments