forked from mcmath/chai-iterator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41d846b
commit 42f7507
Showing
44 changed files
with
1,279 additions
and
736 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
const {chai: {assert}} = require('../helpers'); | ||
|
||
const err = require('../helpers/err'); | ||
|
||
describe('assert: isIterable(value, [message])', function () { | ||
context('value is an iterable object', function () { | ||
it('passes', function () { | ||
assert.isIterable([2, 3, 5]); | ||
assert.isIterable('abcdefg'); | ||
}); | ||
}); | ||
context('value is not an iterable object', function () { | ||
it('throws', function () { | ||
err(function () { | ||
assert.isIterable(235); | ||
}); | ||
err(function () { | ||
assert.isIterable(true); | ||
}); | ||
}); | ||
}); | ||
context('a message is passed', function () { | ||
it('logs message on error', function () { | ||
err((function () { | ||
assert.isIterable(235, 'norway'); | ||
}), 'norway'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('assert: isNotIterable(value, [message])', function () { | ||
context('value is an iterable object', function () { | ||
it('passes', function () { | ||
assert.isNotIterable(235); | ||
assert.isNotIterable(true); | ||
}); | ||
}); | ||
context('value is not an iterable object', function () { | ||
it('throws', function () { | ||
err(function () { | ||
assert.isNotIterable([2, 3, 5]); | ||
}); | ||
err(function () { | ||
assert.isNotIterable('abcdefg'); | ||
}); | ||
}); | ||
}); | ||
context('a message is passed', function () { | ||
it('logs message on error', function () { | ||
err((function () { | ||
assert.isNotIterable([2, 3, 5], 'sweden'); | ||
}), 'sweden'); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
|
||
const {chai: {assert}} = require('../helpers'); | ||
|
||
const customIterableFactory = require('../fixtures/custom'); | ||
|
||
const err = require('../helpers/err'); | ||
|
||
describe('assert: iteratesFrom(value, expected, [message])', function () { | ||
context('initial yielded values match expected values', function () { | ||
it('passes', function () { | ||
assert.iteratesFrom([2, 3, 5], [2, 3, 5]); | ||
assert.iteratesFrom([2, 3, 5], [2, 3]); | ||
assert.iteratesFrom([2, 3, 5], []); | ||
}); | ||
}); | ||
context('initial yielded values do not match expected values', function () { | ||
it('throws', function () { | ||
err(function () { | ||
assert.iteratesFrom([2, 3, 5], [3, 5]); | ||
}); | ||
}); | ||
}); | ||
context('a message is passed', function () { | ||
it('logs message on error', function () { | ||
err((function () { | ||
assert.iteratesFrom([2, 3, 5], [3, 5], 'ukraine'); | ||
}), 'ukraine'); | ||
}); | ||
}); | ||
context('value is not iterable', function () { | ||
it('throws', function () { | ||
err(function () { | ||
assert.iteratesFrom(true, []); | ||
}); | ||
}); | ||
}); | ||
context('expected is not iterable', function () { | ||
it('throws', function () { | ||
err(function () { | ||
assert.iteratesFrom([], true); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('assert: doesNotIterateFrom(value, expected, [message])', function () { | ||
context('initial yielded do not values match expected values', function () { | ||
it('passes', function () { | ||
assert.doesNotIterateFrom([2, 3, 5], [3, 5]); | ||
}); | ||
}); | ||
context('initial yielded values match expected values', function () { | ||
it('throws', function () { | ||
err(function () { | ||
assert.doesNotIterateFrom([2, 3, 5], [2, 3, 5]); | ||
}); | ||
err(function () { | ||
assert.doesNotIterateFrom([2, 3, 5], [2, 3]); | ||
}); | ||
err(function () { | ||
assert.doesNotIterateFrom([2, 3, 5], []); | ||
}); | ||
}); | ||
}); | ||
context('a message is passed', function () { | ||
it('logs message on error', function () { | ||
err((function () { | ||
assert.doesNotIterateFrom([2, 3, 5], [2, 3], 'belarus'); | ||
}), 'belarus'); | ||
}); | ||
}); | ||
context('value is not iterable', function () { | ||
it('throws', function () { | ||
err(function () { | ||
assert.doesNotIterateFrom(true, []); | ||
}); | ||
}); | ||
}); | ||
context('expected is not iterable', function () { | ||
it('throws', function () { | ||
err(function () { | ||
assert.doesNotIterateFrom([], true); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('assert: deepIteratesFrom(value, expected, [message])', function () { | ||
context('yielded values deeply equal expected values', function () { | ||
it('passes', function () { | ||
assert.deepIteratesFrom([ | ||
{ | ||
id: 1 | ||
}, | ||
{ | ||
id: 2 | ||
} | ||
], [ | ||
{ | ||
id: 1 | ||
} | ||
]); | ||
}); | ||
}); | ||
context('yielded values do not deeply equal expected values', function () { | ||
it('throws', function () { | ||
err(function () { | ||
assert.deepIteratesFrom([ | ||
{ | ||
id: 1 | ||
}, | ||
{ | ||
id: 2 | ||
} | ||
], [ | ||
{ | ||
id: 2 | ||
} | ||
]); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('assert: doesNotDeepIterateFrom(value, expected, [message])', function () { | ||
context('yielded values do not deeply equal expected values', function () { | ||
it('passes', function () { | ||
assert.doesNotDeepIterateFrom([ | ||
{ | ||
id: 1 | ||
}, | ||
{ | ||
id: 2 | ||
} | ||
], [ | ||
{ | ||
id: 2 | ||
} | ||
]); | ||
}); | ||
}); | ||
context('yielded values deeply equal expected values', function () { | ||
it('throws', function () { | ||
err(function () { | ||
assert.doesNotDeepIterateFrom([ | ||
{ | ||
id: 1 | ||
}, | ||
{ | ||
id: 2 | ||
} | ||
], [ | ||
{ | ||
id: 1 | ||
} | ||
]); | ||
}); | ||
}); | ||
}); | ||
context('iterator ed by @@iterator is not itself iterable', function () { | ||
it('works correctly', function () { | ||
var iterable; | ||
iterable = customIterableFactory(); | ||
err(function () { | ||
assert.iteratesFrom(iterable, [2, 3]); | ||
}); | ||
assert.iteratesFrom(iterable, [0, 1]); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.