22describe ( 'UnexpectedError' , ( ) => {
33 describe ( 'with a single line message' , ( ) => {
44 it ( 'should be inspected correctly' , ( ) => {
5- expect (
6- function ( ) {
7- expect ( 2 , 'to equal' , 4 ) ;
8- } ,
9- 'to throw' ,
5+ expect ( function ( ) {
6+ expect ( 2 ) . toEqual ( 4 ) ;
7+ } ) . toThrow (
108 expect . it ( function ( err ) {
119 expect (
1210 err ,
@@ -20,11 +18,9 @@ describe('UnexpectedError', () => {
2018
2119 describe ( 'with a multiline message' , ( ) => {
2220 it ( 'should be inspected correctly' , ( ) => {
23- expect (
24- function ( ) {
25- expect ( 'foo' , 'to equal' , 'bar' ) ;
26- } ,
27- 'to throw' ,
21+ expect ( function ( ) {
22+ expect ( 'foo' ) . toEqual ( 'bar' ) ;
23+ } ) . toThrow (
2824 expect . it ( function ( err ) {
2925 expect (
3026 err ,
@@ -42,13 +38,11 @@ describe('UnexpectedError', () => {
4238 } ) ;
4339
4440 it ( '#getKeys should return a trimmed-down list' , ( ) => {
45- expect (
46- function ( ) {
47- expect ( 'foo' , 'to equal' , 'bar' ) ;
48- } ,
49- 'to throw' ,
41+ expect ( function ( ) {
42+ expect ( 'foo' ) . toEqual ( 'bar' ) ;
43+ } ) . toThrow (
5044 expect . it ( function ( err ) {
51- expect ( expect . findTypeOf ( err ) . getKeys ( err ) , 'to equal' , [
45+ expect ( expect . findTypeOf ( err ) . getKeys ( err ) ) . toEqual ( [
5246 'message' ,
5347 'errorMode' ,
5448 'parent' ,
@@ -59,11 +53,9 @@ describe('UnexpectedError', () => {
5953
6054 describe ( 'when full stack traces is disabled' , ( ) => {
6155 it ( 'trims the stack for node_module/unexpected/ and node_module/unexpected-<plugin-name>/' , ( ) => {
62- expect (
63- function ( ) {
64- expect . fail ( 'wat' ) ;
65- } ,
66- 'to throw' ,
56+ expect ( function ( ) {
57+ expect . fail ( 'wat' ) ;
58+ } ) . toThrow (
6759 expect . it ( function ( err ) {
6860 err . useFullStackTrace = false ;
6961 err . _hasSerializedErrorMessage = false ;
@@ -79,7 +71,7 @@ describe('UnexpectedError', () => {
7971
8072 err . serializeMessage ( 'text' ) ;
8173
82- expect ( err , 'to satisfy' , {
74+ expect ( err ) . toSatisfy ( {
8375 stack :
8476 'wat\n' +
8577 ' at Context.<anonymous> (test/Insection.spec.js:48:17)\n' +
@@ -90,11 +82,9 @@ describe('UnexpectedError', () => {
9082 } ) ;
9183
9284 it ( 'trims the stack for node_module\\unexpected\\ and node_module\\unexpected-<plugin-name>\\ (windows paths)' , ( ) => {
93- expect (
94- function ( ) {
95- expect . fail ( 'wat' ) ;
96- } ,
97- 'to throw' ,
85+ expect ( function ( ) {
86+ expect . fail ( 'wat' ) ;
87+ } ) . toThrow (
9888 expect . it ( function ( err ) {
9989 err . useFullStackTrace = false ;
10090 err . _hasSerializedErrorMessage = false ;
@@ -110,7 +100,7 @@ describe('UnexpectedError', () => {
110100
111101 err . serializeMessage ( 'text' ) ;
112102
113- expect ( err , 'to satisfy' , {
103+ expect ( err ) . toSatisfy ( {
114104 stack :
115105 'wat\n' +
116106 ' at Context.<anonymous> (test\\Insection.spec.js:48:17)\n' +
@@ -121,11 +111,9 @@ describe('UnexpectedError', () => {
121111 } ) ;
122112
123113 it ( 'trims the stack for custom assertions in the consuming code' , ( ) => {
124- expect (
125- function ( ) {
126- expect . fail ( 'wat' ) ;
127- } ,
128- 'to throw' ,
114+ expect ( function ( ) {
115+ expect . fail ( 'wat' ) ;
116+ } ) . toThrow (
129117 expect . it ( function ( err ) {
130118 err . useFullStackTrace = false ;
131119 err . _hasSerializedErrorMessage = false ;
@@ -143,7 +131,7 @@ describe('UnexpectedError', () => {
143131
144132 err . serializeMessage ( 'text' ) ;
145133
146- expect ( err , 'to satisfy' , {
134+ expect ( err ) . toSatisfy ( {
147135 stack :
148136 'wat\n' +
149137 ' at functionCalledByCustomHandler (test/my.spec.js:42:666)\n' +
@@ -156,11 +144,9 @@ describe('UnexpectedError', () => {
156144
157145 describe ( 'and the output format is set to html' , ( ) => {
158146 it ( 'shows a helping message about how to turn of stack trace trimming' , ( ) => {
159- expect (
160- function ( ) {
161- expect . fail ( 'wat' ) ;
162- } ,
163- 'to throw' ,
147+ expect ( function ( ) {
148+ expect . fail ( 'wat' ) ;
149+ } ) . toThrow (
164150 expect . it ( function ( err ) {
165151 err . useFullStackTrace = false ;
166152 err . _hasSerializedErrorMessage = false ;
@@ -176,7 +162,7 @@ describe('UnexpectedError', () => {
176162
177163 err . serializeMessage ( 'html' ) ;
178164
179- expect ( err , 'to satisfy' , {
165+ expect ( err ) . toSatisfy ( {
180166 stack :
181167 'wat\n' +
182168 ' at Context.<anonymous> (test/Insection.spec.js:48:17)\n' +
@@ -190,11 +176,9 @@ describe('UnexpectedError', () => {
190176
191177 describe ( 'when full stack traces is enabled' , ( ) => {
192178 it ( 'the initial stack is preserved' , ( ) => {
193- expect (
194- function ( ) {
195- expect . fail ( 'wat' ) ;
196- } ,
197- 'to throw' ,
179+ expect ( function ( ) {
180+ expect . fail ( 'wat' ) ;
181+ } ) . toThrow (
198182 expect . it ( function ( err ) {
199183 err . useFullStackTrace = true ;
200184 err . _hasSerializedErrorMessage = false ;
@@ -210,7 +194,7 @@ describe('UnexpectedError', () => {
210194
211195 err . serializeMessage ( 'text' ) ;
212196
213- expect ( err , 'to satisfy' , {
197+ expect ( err ) . toSatisfy ( {
214198 stack :
215199 'wat\n' +
216200 ' at oathbreaker (node_modules/unexpected/lib/oathbreaker.js:46:19)\n' +
@@ -228,32 +212,30 @@ describe('UnexpectedError', () => {
228212
229213 describe ( 'when an originalError instance is passed' , ( ) => {
230214 it ( 'should give up' , ( ) => {
231- return expect (
232- function ( ) {
233- return expect ( function ( ) {
234- try {
235- throw new Error ( 'argh' ) ;
236- } catch ( err ) {
237- err . stack = 'foobarquux\n at yaddayadda' ;
238- throw err ;
239- }
240- } , 'not to error' ) ;
241- } ,
242- 'to error' ,
215+ return expect ( function ( ) {
216+ return expect ( function ( ) {
217+ try {
218+ throw new Error ( 'argh' ) ;
219+ } catch ( err ) {
220+ err . stack = 'foobarquux\n at yaddayadda' ;
221+ throw err ;
222+ }
223+ } ) . notToError ( ) ;
224+ } ) . toError (
243225 expect . it ( function ( err ) {
244- expect ( err . stack , 'to contain' , 'foobarquux\n at yaddayadda' ) ;
226+ expect ( err . stack ) . toContain ( 'foobarquux\n at yaddayadda' ) ;
245227 } )
246228 ) ;
247229 } ) ;
248230 } ) ;
249231
250232 describe ( '#stack' , ( ) => {
251233 it ( 'should not mess up when the error message contains $&' , ( ) => {
252- return expect ( ( ) => expect ( '$&' , 'to equal' , ' foo') , 'to error' ) . then (
253- ( err ) => {
254- expect ( err . stack , 'to contain' , '$&' ) ;
255- }
256- ) ;
234+ return expect ( ( ) => expect ( '$&' ) . toEqual ( ' foo') )
235+ . toError ( )
236+ . then ( ( err ) => {
237+ expect ( err . stack ) . toContain ( '$&' ) ;
238+ } ) ;
257239 } ) ;
258240 } ) ;
259241} ) ;
0 commit comments