1
1
/*global describe, it, beforeEach*/
2
2
var { array, integer, string } = require ( 'chance-generators' ) ;
3
- var expect = require ( 'unexpected' ) ;
3
+ var expect = require ( 'unexpected' ) . clone ( ) ;
4
4
expect . output . preferredWidth = 80 ;
5
5
6
6
expect . use ( require ( '../lib/unexpected-check' ) ) ;
@@ -134,9 +134,11 @@ describe('unexpected-check', function() {
134
134
function ( ) {
135
135
expect (
136
136
function ( items ) {
137
- expect ( items , 'to have items satisfying' , function ( item , i ) {
138
- expect ( item , 'not to be' , i ) ;
139
- } ) ;
137
+ expect (
138
+ items . map ( ( value , index ) => ( { index, value } ) ) ,
139
+ 'to have items satisfying' ,
140
+ expect . it ( ( { index, value } ) => expect ( value , 'not to be' , index ) )
141
+ ) ;
140
142
} ,
141
143
'to be valid for all' ,
142
144
numbers
@@ -149,11 +151,11 @@ describe('unexpected-check', function() {
149
151
' Generated input: [ 0 ]\n' +
150
152
' with: array({ itemGenerator: integer({ min: -20, max: 20 }), min: 1, max: 20 })\n' +
151
153
'\n' +
152
- ' expected [ 0 ]\n' +
153
- " to have items satisfying function (item, i) { expect(item , 'not to be', i); } \n" +
154
+ ' expected [ { index: 0, value: 0 } ]\n' +
155
+ " to have items satisfying expect.it(({ index, value }) => expect(value , 'not to be', index)) \n" +
154
156
'\n' +
155
157
' [\n' +
156
- ' 0 // should not be 0\n' +
158
+ ' { index: 0, value: 0 } // expected 0 not to be 0\n' +
157
159
' ]'
158
160
) ;
159
161
} ) ;
@@ -165,9 +167,12 @@ describe('unexpected-check', function() {
165
167
function ( ) {
166
168
expect (
167
169
function ( items ) {
168
- expect ( items , 'to have items satisfying' , function ( item ) {
169
- expect ( item , 'not to match' , / [ ! @ # $ % ^ & * ( ) _ + ] / ) ;
170
- } ) ;
170
+ expect (
171
+ items ,
172
+ 'to have items satisfying' ,
173
+ 'not to match' ,
174
+ / [ ! @ # $ % ^ & * ( ) _ + ] /
175
+ ) ;
171
176
} ,
172
177
'to be valid for all' ,
173
178
strings
@@ -180,10 +185,7 @@ describe('unexpected-check', function() {
180
185
" Generated input: [ '#' ]\n" +
181
186
' with: array({ itemGenerator: string, min: 1, max: 20 })\n' +
182
187
'\n' +
183
- " expected [ '#' ] to have items satisfying\n" +
184
- ' function (item) {\n' +
185
- " expect(item, 'not to match', /[!@#$%^&*()_+]/);\n" +
186
- ' }\n' +
188
+ " expected [ '#' ] to have items satisfying not to match /[!@#$%^&*()_+]/\n" +
187
189
'\n' +
188
190
' [\n' +
189
191
" '#' // should not match /[!@#$%^&*()_+]/\n" +
0 commit comments