@@ -37,7 +37,7 @@ describe('manifest', () => {
37
37
)
38
38
} )
39
39
40
- it ( 'should raises an exception when `options` is not an array' , ( ) => {
40
+ it ( 'should raise an exception when `options` is not an array' , ( ) => {
41
41
vi . mocked ( existsSync ) . mockReturnValue ( true )
42
42
vi . mocked ( readFileSync ) . mockReturnValue (
43
43
JSON . stringify ( {
@@ -50,7 +50,55 @@ describe('manifest', () => {
50
50
)
51
51
} )
52
52
53
- it ( 'should raises an exception when any `options item` has no `name` property' , ( ) => {
53
+ it ( 'should raise an exception when `options` is not an array' , ( ) => {
54
+ vi . mocked ( existsSync ) . mockReturnValue ( true )
55
+ vi . mocked ( readFileSync ) . mockReturnValue (
56
+ JSON . stringify ( {
57
+ options : { } ,
58
+ } ) ,
59
+ )
60
+
61
+ expect ( ( ) => load ( ) ) . toThrowErrorMatchingInlineSnapshot (
62
+ `[Error: Error while loading the manifest file: When declared, the 'options' property should be an array]` ,
63
+ )
64
+ } )
65
+
66
+ it ( 'should NOT raise an exception when `options` is an empty array' , ( ) => {
67
+ vi . mocked ( existsSync ) . mockReturnValue ( true )
68
+ vi . mocked ( readFileSync ) . mockReturnValue (
69
+ JSON . stringify ( {
70
+ options : [ ] ,
71
+ } ) ,
72
+ )
73
+
74
+ expect ( ( ) => load ( ) ) . not . toThrowError ( )
75
+ } )
76
+
77
+ it ( 'should NOT raise an exception when `options` is an undefined' , ( ) => {
78
+ vi . mocked ( existsSync ) . mockReturnValue ( true )
79
+ vi . mocked ( readFileSync ) . mockReturnValue (
80
+ JSON . stringify ( {
81
+ options : undefined ,
82
+ } ) ,
83
+ )
84
+
85
+ expect ( ( ) => load ( ) ) . not . toThrowError ( )
86
+ } )
87
+
88
+ it ( 'should raise an exception when `options` is not an array' , ( ) => {
89
+ vi . mocked ( existsSync ) . mockReturnValue ( true )
90
+ vi . mocked ( readFileSync ) . mockReturnValue (
91
+ JSON . stringify ( {
92
+ options : null ,
93
+ } ) ,
94
+ )
95
+
96
+ expect ( ( ) => load ( ) ) . toThrowErrorMatchingInlineSnapshot (
97
+ `[Error: Error while loading the manifest file: When declared, the 'options' property should be an array]` ,
98
+ )
99
+ } )
100
+
101
+ it ( 'should raise an exception when any `options item` has no `name` property' , ( ) => {
54
102
vi . mocked ( existsSync ) . mockReturnValue ( true )
55
103
vi . mocked ( readFileSync ) . mockReturnValue (
56
104
JSON . stringify ( {
@@ -69,7 +117,7 @@ describe('manifest', () => {
69
117
)
70
118
} )
71
119
72
- it ( 'should raises an exception when any `options item` has no `value` property' , ( ) => {
120
+ it ( 'should raise an exception when any `options item` has no `value` property' , ( ) => {
73
121
vi . mocked ( existsSync ) . mockReturnValue ( true )
74
122
vi . mocked ( readFileSync ) . mockReturnValue (
75
123
JSON . stringify ( {
@@ -88,6 +136,24 @@ describe('manifest', () => {
88
136
)
89
137
} )
90
138
139
+ it ( 'should raise an exception when any `options item` --> `value` property is not of type string' , ( ) => {
140
+ vi . mocked ( existsSync ) . mockReturnValue ( true )
141
+ vi . mocked ( readFileSync ) . mockReturnValue (
142
+ JSON . stringify ( {
143
+ options : [
144
+ {
145
+ name : 'opt1' ,
146
+ value : 1 ,
147
+ } ,
148
+ ] ,
149
+ } ) ,
150
+ )
151
+
152
+ expect ( ( ) => load ( ) ) . toThrowErrorMatchingInlineSnapshot (
153
+ `[Error: Error while loading the manifest file: Each option must be an object with string properties "name" and "value". The following values need to be corrected: \n {"name":"opt1","value":1} --> Incorrect value type. Must be of type string.]` ,
154
+ )
155
+ } )
156
+
91
157
it ( 'should be valid but with no `options` defined' , ( ) => {
92
158
vi . mocked ( existsSync ) . mockReturnValue ( true )
93
159
vi . mocked ( readFileSync ) . mockReturnValue ( '{}' )
0 commit comments