Skip to content

Commit 8ec5a3e

Browse files
committed
Try to be forward compatible with unexpected v11
1 parent 8ef22a9 commit 8ec5a3e

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

test/unexpected-check.spec.js

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*global describe, it, beforeEach*/
22
var { array, integer, string } = require('chance-generators');
3-
var expect = require('unexpected');
3+
var expect = require('unexpected').clone();
44
expect.output.preferredWidth = 80;
55

66
expect.use(require('../lib/unexpected-check'));
@@ -134,9 +134,11 @@ describe('unexpected-check', function() {
134134
function() {
135135
expect(
136136
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+
);
140142
},
141143
'to be valid for all',
142144
numbers
@@ -149,11 +151,11 @@ describe('unexpected-check', function() {
149151
' Generated input: [ 0 ]\n' +
150152
' with: array({ itemGenerator: integer({ min: -20, max: 20 }), min: 1, max: 20 })\n' +
151153
'\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" +
154156
'\n' +
155157
' [\n' +
156-
' 0 // should not be 0\n' +
158+
' { index: 0, value: 0 } // expected 0 not to be 0\n' +
157159
' ]'
158160
);
159161
});
@@ -165,9 +167,12 @@ describe('unexpected-check', function() {
165167
function() {
166168
expect(
167169
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+
);
171176
},
172177
'to be valid for all',
173178
strings
@@ -180,10 +185,7 @@ describe('unexpected-check', function() {
180185
" Generated input: [ '#' ]\n" +
181186
' with: array({ itemGenerator: string, min: 1, max: 20 })\n' +
182187
'\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" +
187189
'\n' +
188190
' [\n' +
189191
" '#' // should not match /[!@#$%^&*()_+]/\n" +

0 commit comments

Comments
 (0)