@@ -13,11 +13,13 @@ describe("Strict Mode", () => {
13
13
14
14
describe ( "by default" , ( ) => {
15
15
it ( "should not throw an error when accessing a non-draftable class instance" , ( ) => {
16
- expect ( ( ) =>
17
- produce ( { instance : new Foo ( ) } , draft => {
16
+ expect . hasAssertions ( )
17
+
18
+ produce ( { instance : new Foo ( ) } , draft => {
19
+ expect ( ( ) => {
18
20
draft . instance . value = 5
19
- } )
20
- ) . not . toThrow ( )
21
+ } ) . not . toThrow ( )
22
+ } )
21
23
} )
22
24
} )
23
25
@@ -31,21 +33,25 @@ describe("Strict Mode", () => {
31
33
} )
32
34
33
35
it ( "should allow accessing a non-draftable class instance" , ( ) => {
34
- expect ( ( ) =>
35
- produce ( { instance : new Foo ( ) } , draft => {
36
+ expect . hasAssertions ( )
37
+
38
+ produce ( { instance : new Foo ( ) } , draft => {
39
+ expect ( ( ) => {
36
40
draft . instance . value = 5
37
- } )
38
- ) . not . toThrow ( )
41
+ } ) . not . toThrow ( )
42
+ } )
39
43
} )
40
44
41
45
it ( "should not throw errors when using the `unsafe` function" , ( ) => {
42
- expect ( ( ) =>
43
- produce ( { instance : new Foo ( ) } , draft => {
44
- unsafe ( ( ) => {
46
+ expect . hasAssertions ( )
47
+
48
+ produce ( { instance : new Foo ( ) } , draft => {
49
+ unsafe ( ( ) => {
50
+ expect ( ( ) => {
45
51
draft . instance . value = 5
46
- } )
52
+ } ) . not . toThrow ( )
47
53
} )
48
- ) . not . toThrow ( )
54
+ } )
49
55
} )
50
56
} )
51
57
@@ -55,21 +61,23 @@ describe("Strict Mode", () => {
55
61
} )
56
62
57
63
it ( "should throw an error when accessing a non-draftable class instance" , ( ) => {
58
- expect ( ( ) =>
59
- produce ( { instance : new Foo ( ) } , draft => {
60
- draft . instance
61
- } )
62
- ) . toThrow ( )
64
+ expect . hasAssertions ( )
65
+
66
+ produce ( { instance : new Foo ( ) } , draft => {
67
+ expect ( ( ) => draft . instance ) . toThrow ( )
68
+ } )
63
69
} )
64
70
65
71
it ( "should allow accessing a non-draftable using the `unsafe` function" , ( ) => {
66
- expect ( ( ) =>
67
- produce ( { instance : new Foo ( ) } , draft => {
68
- unsafe ( ( ) => {
72
+ expect . hasAssertions ( )
73
+
74
+ produce ( { instance : new Foo ( ) } , draft => {
75
+ unsafe ( ( ) => {
76
+ expect ( ( ) => {
69
77
draft . instance . value = 5
70
- } )
78
+ } ) . not . toThrow ( )
71
79
} )
72
- ) . not . toThrow ( )
80
+ } )
73
81
} )
74
82
75
83
it ( "should require using unsafe for non-draftables in a different scope" , ( ) => {
@@ -98,11 +106,13 @@ describe("Strict Mode", () => {
98
106
} )
99
107
100
108
it ( "should allow accessing the class instance" , ( ) => {
101
- expect ( ( ) =>
102
- produce ( { instance : new Foo ( ) } , draft => {
109
+ expect . hasAssertions ( )
110
+
111
+ produce ( { instance : new Foo ( ) } , draft => {
112
+ expect ( ( ) => {
103
113
draft . instance . value = 5
104
- } )
105
- ) . not . toThrow ( )
114
+ } ) . not . toThrow ( )
115
+ } )
106
116
} )
107
117
} )
108
118
0 commit comments