Skip to content

Commit

Permalink
Merge 0fce828 into 92034bc
Browse files Browse the repository at this point in the history
  • Loading branch information
harrysarson committed Feb 19, 2019
2 parents 92034bc + 0fce828 commit 538d32f
Show file tree
Hide file tree
Showing 20 changed files with 38 additions and 62 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Expand Up @@ -6,22 +6,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [UNRELEASED]

### Changed

- Updated badges in README.
- Converted tests from coffeescript into javascript.

## [3.0.0] - 2018-09-04

With version 3, chai-iterator has changed ownership.
This release updates the libary to work with chai@4, to use chai-iterator with chai@3 stick to version 1.
This release updates the library to work with chai@4, to use chai-iterator with chai@3 stick to version 1.

### Changed

- Passing null to functions with optional arguments will now cause an error.
- Upgraded peer dependancy from chai@3 to chai@4.
- Upgraded peer dependency from chai@3 to chai@4.

### Removed

- Typescript support: I don't know much about typescript and cannot maintain the definitions.
If anyone is willing to maintain typescript definitions please open an issue.

## [2.0.0] - Skipped

I published version 2 at @harrysarson/chai-iterator.
Instead of having to overwrite git tags, chai-iterator will skip over version 2.
Instead of having to overwrite git tags, chai-iterator will skip over version 2.
18 changes: 9 additions & 9 deletions README.md
Expand Up @@ -26,12 +26,12 @@ a [`for...of`][for-of] loop. A number of [built-in][built-in-iterable] types are
iterable by default, while [custom iterable objects][custom-iterable] may also
be defined. chai-iterator makes it easy to test all such objects.

#### You may not need chai-iterator
### You may not need chai-iterator

In many cases the [array spread operator][array-spread] is the best way to test iterables.
chai-iterator is however very usefull for testing part of a very long (or infinite) iterable.
chai-iterator is however very useful for testing part of a very long (or infinite) iterable.

#### Basic usage
### Basic usage

Here is a fairly exhaustive sample of the assertions we can make using Chai
Iterator. While we could just as easily use `expect` or `assert`, we'll use
Expand Down Expand Up @@ -67,7 +67,7 @@ And we can pass any iterable as our expected values too.
'abcde'.should.iterate.until('cde');
```

#### User-defined iterable objects
### User-defined iterable objects

chai-iterator is best used to test
[user-defined iterable objects][custom-iterable], like the one constructed by
Expand Down Expand Up @@ -106,7 +106,7 @@ Just don't go trying to use [`over()`](#iterateoverexpected) or
[`until()`](#iterateuntilexpected) on infinite sequences. The former will always
fail and the latter will never stop.

#### Generators and iterators
### Generators and iterators

Let's generate the [fibonacci sequence][fibonacci-sequence]. A
[generator function][generator-function] is just a function that returns a
Expand Down Expand Up @@ -171,7 +171,7 @@ chai-iterator can be imported as a [Node][node] module, an [AMD][amd]
module, or included in an HTML [`<script>`][script-tag] tag. For
[TypeScript][typescript] users, declarations are installed with the package.

#### Node
### Node

To set up chai-iterator for [Node][node], make sure the version is v4.0 or
higher, as prior versions lack support for the [`@@iterator`][iterator-method]
Expand Down Expand Up @@ -233,7 +233,7 @@ chai.use(chaiIterator);

## Expect/Should API

#### Assertions
### Assertions

- [`iterable`](#iterable)
- [`iterate.over()`](#iterateoverexpected)
Expand Down Expand Up @@ -392,7 +392,7 @@ expect([2, 3, 5]).not.to.iterate.for.length.within(4, 7);

## Assert API

#### Assertions
### Assertions

- [`isIterable()`](#isiterablevalue-message)
- [`isNotIterable()`](#isnotiterablevalue-message)
Expand Down Expand Up @@ -595,7 +595,7 @@ Copyright &copy; 2016&ndash;2017 Akim McMath. Licensed under the [MIT License][l
[ecma-iterable]: http://www.ecma-international.org/ecma-262/6.0/#sec-iterable-interface
[iterator-method]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator
[for-of]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of
[array-spread]: (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax)
[array-spread]: (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax)
[built-in-iterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#Builtin_iterables
[custom-iterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#User-defined_iterables
[assertion-style]: http://chaijs.com/guide/styles/
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -5,14 +5,15 @@
"main": "chai-iterator.js",
"scripts": {
"test:lint": "xo",
"test:mocha": "mocha",
"test:cover": "nyc mocha test/**/*.js",
"test:mocha": "mocha test/**/*.js",
"test:cover": "nyc npm run test:mocha",
"test": "npm run test:lint && npm run test:cover",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"files": [
"chai-iterator.js",
"LICENSE",
"CHANGELOG.md",
"README.md"
],
"repository": {
Expand Down Expand Up @@ -46,7 +47,6 @@
},
"devDependencies": {
"chai": "4.1.2",
"coffeescript": "2.3.2",
"coveralls": "3.0.2",
"mocha": "6.0.0",
"nyc": "13.3.0",
Expand Down
3 changes: 1 addition & 2 deletions test/assert/iterate-from.js
Expand Up @@ -159,8 +159,7 @@ describe('assert: doesNotDeepIterateFrom(value, expected, [message])', function
});
context('iterator ed by @@iterator is not itself iterable', function () {
it('works correctly', function () {
var iterable;
iterable = customIterableFactory();
const iterable = customIterableFactory();
err(function () {
assert.iteratesFrom(iterable, [2, 3]);
});
Expand Down
3 changes: 1 addition & 2 deletions test/assert/iterate-over.js
Expand Up @@ -182,8 +182,7 @@ describe('assert: doesNotDeepIterateOver(value, expected, [message])', function
});
context('iterator ed by @@iterator is not itself iterable', function () {
it('works correctly', function () {
var iterable;
iterable = customIterableFactory();
const iterable = customIterableFactory();
err(function () {
assert.iteratesOver(iterable, [2, 3, 5]);
});
Expand Down
3 changes: 1 addition & 2 deletions test/assert/iterate-until.js
Expand Up @@ -159,8 +159,7 @@ describe('assert: doesNotDeepIterateUntil(value, expected, [message])', function
});
context('iterator ed by @@iterator is not itself iterable', function () {
it('works correctly', function () {
var iterable;
iterable = customIterableFactory();
const iterable = customIterableFactory();
err(function () {
assert.iteratesUntil(iterable, [3, 5]);
});
Expand Down
10 changes: 3 additions & 7 deletions test/assert/length-of.js
Expand Up @@ -7,19 +7,15 @@ const {err} = require('../helpers');

describe('assert: lengthOf(act, len, [msg])', function () {
context('@act is an iterable without a length:number property', function () {
var customIterable;
customIterable = beforeEach(function () {
customIterable = customGenerator();
});
it('passes if @act has length of @len', function () {
assert.lengthOf(customIterable, 3);
assert.lengthOf(customGenerator(), 3);
});
it('throws if @act does not have length of @n', function () {
err(function () {
assert.lengthOf(customIterable, 4);
assert.lengthOf(customGenerator(), 4);
});
err(function () {
assert.lengthOf(customIterable, 2);
assert.lengthOf(customGenerator(), 2);
});
});
it('works on infinite iterables', function () {
Expand Down
3 changes: 1 addition & 2 deletions test/expect-should/iterate-from.js
Expand Up @@ -78,8 +78,7 @@ describe('expect/should: iterate.from(iterable)', function () {

context('iterator ed by @@iterator is not itself iterable', function () {
it('works correctly', function () {
var iterable;
iterable = customIterableFactory();
const iterable = customIterableFactory();
err(function () {
iterable.should.iterate.from([2, 3]);
});
Expand Down
3 changes: 1 addition & 2 deletions test/expect-should/iterate-over.js
Expand Up @@ -86,8 +86,7 @@ describe('expect/should: iterate.over(iterable)', function () {
});
context('iterator ed by @@iterator is not itself iterable', function () {
it('works correctly', function () {
var iterable;
iterable = customIterableFactory();
const iterable = customIterableFactory();
err(function () {
iterable.should.iterate.over([2, 3, 5]);
});
Expand Down
3 changes: 1 addition & 2 deletions test/expect-should/iterate-until.js
Expand Up @@ -76,8 +76,7 @@ describe('expect/should: iterate.until(iterable)', function () {
});
context('iterator ed by @@iterator is not itself iterable', function () {
it('works correctly', function () {
var iterable;
iterable = customIterableFactory();
const iterable = customIterableFactory();
err(function () {
iterable.should.iterate.until([3, 5]);
});
Expand Down
4 changes: 1 addition & 3 deletions test/expect-should/length-above.js
@@ -1,6 +1,4 @@
var infiniteGenerator;

({infiniteGenerator} = require('../fixtures'));
const {infiniteGenerator} = require('../fixtures');

const {err} = require('../helpers');

Expand Down
4 changes: 1 addition & 3 deletions test/expect-should/length-below.js
@@ -1,6 +1,4 @@
var infiniteGenerator;

({infiniteGenerator} = require('../fixtures'));
const {infiniteGenerator} = require('../fixtures');

const {err} = require('../helpers');

Expand Down
4 changes: 1 addition & 3 deletions test/expect-should/length-of-at-least.js
@@ -1,6 +1,4 @@
var infiniteGenerator;

({infiniteGenerator} = require('../fixtures'));
const {infiniteGenerator} = require('../fixtures');

const {err} = require('../helpers');

Expand Down
4 changes: 1 addition & 3 deletions test/expect-should/length-of-at-most.js
@@ -1,6 +1,4 @@
var infiniteGenerator;

({infiniteGenerator} = require('../fixtures'));
const {infiniteGenerator} = require('../fixtures');

const {err} = require('../helpers');

Expand Down
4 changes: 1 addition & 3 deletions test/expect-should/length-of.js
@@ -1,6 +1,4 @@
var infiniteGenerator;

({infiniteGenerator} = require('../fixtures'));
const {infiniteGenerator} = require('../fixtures');

const {err} = require('../helpers');

Expand Down
4 changes: 1 addition & 3 deletions test/expect-should/length-within.js
@@ -1,6 +1,4 @@
var infiniteGenerator;

({infiniteGenerator} = require('../fixtures'));
const {infiniteGenerator} = require('../fixtures');

const {err} = require('../helpers');

Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/custom.js
Expand Up @@ -2,8 +2,7 @@
module.exports = function () {
return Object.defineProperty({}, Symbol.iterator, {
value: function () {
var i;
i = 0;
let i = 0;
return {
next: function () {
return {
Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/infinite.js
Expand Up @@ -2,8 +2,7 @@
module.exports = function () {
return Object.defineProperty({}, Symbol.iterator, {
value: function () {
var i;
i = 0;
let i = 0;
return {
next: function () {
return {
Expand Down
4 changes: 1 addition & 3 deletions test/helpers/err.js
@@ -1,7 +1,5 @@

var AssertionError;

({AssertionError} = require('chai'));
const {AssertionError} = require('chai');

module.exports = function (fn, msg) {
fn.should.throw(AssertionError, msg);
Expand Down
4 changes: 1 addition & 3 deletions test/index.js
@@ -1,7 +1,5 @@

var chaiIterator;

({chaiIterator} = require('./helpers'));
const {chaiIterator} = require('./helpers');

describe('plugin: chai-iterator', function () {
it('exports a function', function () {
Expand Down

0 comments on commit 538d32f

Please sign in to comment.