Skip to content

Commit

Permalink
Merge 6f5d4b2 into 1248cb8
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjeffburke committed Dec 28, 2018
2 parents 1248cb8 + 6f5d4b2 commit 357247c
Show file tree
Hide file tree
Showing 56 changed files with 1,075 additions and 765 deletions.
18 changes: 12 additions & 6 deletions .travis.yml
Expand Up @@ -4,20 +4,26 @@ env:
- TARGET=travis

node_js:
- "0.10"
- "0.12"
- "4"
- "5"
- "6"
- "7"
- "8.4.0"
- "9"
- "10"

matrix:
include:
- name: Travis main 8.4.0
- name: Lint (8.4.0)
node_js: "8.4.0"
env: TARGET=travis-main
env: TARGET=lint
- name: Jest (8.4.0)
node_js: "8.4.0"
env: TARGET=test-jest
- name: Jasmine (8.4.0)
node_js: "8.4.0"
env: TARGET=test-jasmine
- name: Coverage (8.4.0)
node_js: "8.4.0"
env: TARGET=travis-coverage
- name: BrowserStack IE11
node_js: "8.4.0"
env: TARGET=test-browserstack-ie11
Expand Down
3 changes: 0 additions & 3 deletions CHANGELOG.md
Expand Up @@ -196,9 +196,6 @@

- [#338](https://github.com/unexpectedjs/unexpected/pull/338) Add <object|array-like> to have (a value|an item) satisfying <any|assertion> ([Andreas Lind](mailto:andreas@one.com), [Joel Mukuthu](mailto:jmu@one.com))
- [#355](https://github.com/unexpectedjs/unexpected/pull/355) Inspect async functions ([Andreas Lind](mailto:andreas@one.com))

### v10.20.0 (2016-11-27)

- [#340](https://github.com/unexpectedjs/unexpected/pull/340) Add 'to be fulfilled with a value satisfying' and 'to be rejected with error satisfying' ([Joel Mukuthu](mailto:jmu@one.com))
- [#348](https://github.com/unexpectedjs/unexpected/pull/348) to have (items|values|keys) satisfying: Only allow one <any> as the value, not <any+> ([Andreas Lind](mailto:andreas@one.com))
- [#349](https://github.com/unexpectedjs/unexpected/pull/349) to have keys satisfying, to have values satisfying: Disallow an empty array ([Andreas Lind](mailto:andreas@one.com))
Expand Down
15 changes: 6 additions & 9 deletions Makefile
@@ -1,6 +1,6 @@
REPORTER = dot

TARGETS ?= unexpected.js unexpected.js.map
TARGETS ?= unexpected.js

CHEWBACCA_THRESHOLD ?= 25

Expand Down Expand Up @@ -50,12 +50,9 @@ test-jest:
ifeq ($(MODERN_NODE), true)
./node_modules/.bin/jest
else
./node_modules/.bin/jest -c test/jest.es5.config.json
./node_modules/.bin/jest --rootDir . -c test/jest.es5.config.json
endif

test-jest-if-supported-node-version:
@node-version-gte-6 && make test-jest || echo Skipping, jest is unsupported with node $(shell node --version)

.PHONY: test
test: test-sources
@./node_modules/.bin/mocha --opts $(MOCHA_OPTS) $(TEST_SOURCES) $(TEST_SOURCE_MARKDOWN)
Expand Down Expand Up @@ -84,12 +81,12 @@ test-chrome-headless: ${TARGETS}
test-browserstack-%: ${TARGETS}
@./node_modules/.bin/karma start --browsers=$* --single-run

.PHONY: travis-main
travis-main: clean lint test test-jasmine test-jest coverage
.PHONY: travis-coverage
travis-coverage: clean coverage
-<coverage/lcov.info ./node_modules/coveralls/bin/coveralls.js

.PHONY: travis
travis: test test-jest-if-supported-node-version
travis: test

.PHONY: git-dirty-check
git-dirty-check:
Expand Down Expand Up @@ -117,7 +114,7 @@ changelog: git-dirty-check
fi

.PHONY: release-%
release-%: git-dirty-check lint ${TARGETS} test-chrome-headless test-jasmine test-jest-if-supported-node-version commit-unexpected deploy-site
release-%: git-dirty-check lint ${TARGETS} test-chrome-headless test-jasmine test-jest commit-unexpected deploy-site
IS_MAKE_RELEASE=yes npm version $*
make changelog
@echo $* release ready to be publised to NPM
Expand Down
54 changes: 27 additions & 27 deletions documentation/api/addType.md
Expand Up @@ -299,32 +299,32 @@ block. The outputs below shows the contrast between setting the
inlineDiff = true;
expect(
{
'John Doe': new Person('John Doe', 42),
'Jane Doe': new Person('Janie Doe', 24)
JohnDoe: new Person('John Doe', 42),
JaneDoe: new Person('Janie Doe', 24)
},
'to equal',
{
'John Doe': new Person('John Doe', 42),
'Jane Doe': new Person('Jane Doe', 24)
JohnDoe: new Person('John Doe', 42),
JaneDoe: new Person('Jane Doe', 24)
}
);
```

```output
expected
{
'John Doe': new Person('John Doe', 42),
'Jane Doe': new Person('Janie Doe', 24)
JohnDoe: new Person('John Doe', 42),
JaneDoe: new Person('Janie Doe', 24)
}
to equal
{
'John Doe': new Person('John Doe', 42),
'Jane Doe': new Person('Jane Doe', 24)
JohnDoe: new Person('John Doe', 42),
JaneDoe: new Person('Jane Doe', 24)
}
{
'John Doe': new Person('John Doe', 42),
'Jane Doe': new Person(
JohnDoe: new Person('John Doe', 42),
JaneDoe: new Person(
'Janie Doe', // should be 'Jane Doe'
// -Janie Doe
// +Jane Doe
Expand All @@ -337,39 +337,39 @@ to equal
inlineDiff = false;
expect(
{
'John Doe': new Person('John Doe', 42),
'Jane Doe': new Person('Janie Doe', 24)
JohnDoe: new Person('John Doe', 42),
JaneDoe: new Person('Janie Doe', 24)
},
'to equal',
{
'John Doe': new Person('John Doe', 42),
'Jane Doe': new Person('Jane Doe', 24)
JohnDoe: new Person('John Doe', 42),
JaneDoe: new Person('Jane Doe', 24)
}
);
```

```output
expected
{
'John Doe': new Person('John Doe', 42),
'Jane Doe': new Person('Janie Doe', 24)
JohnDoe: new Person('John Doe', 42),
JaneDoe: new Person('Janie Doe', 24)
}
to equal
{
'John Doe': new Person('John Doe', 42),
'Jane Doe': new Person('Jane Doe', 24)
JohnDoe: new Person('John Doe', 42),
JaneDoe: new Person('Jane Doe', 24)
}
{
'John Doe': new Person('John Doe', 42),
'Jane Doe': new Person('Janie Doe', 24) // should equal new Person('Jane Doe', 24)
//
// new Person(
// 'Janie Doe', // should be 'Jane Doe'
// // -Janie Doe
// // +Jane Doe
// 24
// )
JohnDoe: new Person('John Doe', 42),
JaneDoe: new Person('Janie Doe', 24) // should equal new Person('Jane Doe', 24)
//
// new Person(
// 'Janie Doe', // should be 'Jane Doe'
// // -Janie Doe
// // +Jane Doe
// 24
// )
}
```

Expand Down
Expand Up @@ -8,9 +8,9 @@ expect([{ a: 1 }, { b: 2 }], 'to have an item satisfying', { a: 1 });

expect([0, 1, 2, 3, 4], 'to have an item satisfying', 'to be a number');

expect([0, 1, 2, 3, 4], 'to have an item satisfying', function(item, index) {
expect([0, 1, 2, 3, 4], 'to have an item satisfying', expect.it(function(item) {
expect(item, 'to be a number');
});
}));

expect(
[[1], ['foo']],
Expand Down
Expand Up @@ -5,9 +5,9 @@ Alias: `to be an array whose items satisfy`.
Notice this assertion fails when given an empty array.

```js
expect([0, 1, 2, 3, 4], 'to have items satisfying', function(item, index) {
expect([0, 1, 2, 3, 4], 'to have items satisfying', expect.it(function(item) {
expect(item, 'to be a number');
});
}));

expect([0, 1, 2, 3, 4], 'to have items satisfying', 'to be a number');

Expand Down
12 changes: 6 additions & 6 deletions documentation/assertions/function/to-error.md
Expand Up @@ -120,9 +120,9 @@ function willBeRejectedAsync() {
});
}
return expect(willBeRejectedAsync, 'to error', function(e) {
return expect(willBeRejectedAsync, 'to error', expect.it(function(e) {
return expect(e.message, 'to equal', 'async error');
});
}));
```

You can even do async assertions in the function that you pass in.
Expand All @@ -140,9 +140,9 @@ function willBeRejectedAsync() {
});
}
return expect(willBeRejectedAsync, 'to error', function(e) {
return expect(willBeRejectedAsync, 'to error', function(e2) {
return expect(willBeRejectedAsync, 'to error', expect.it(function(e) {
return expect(willBeRejectedAsync, 'to error', expect.it(function(e2) {
return expect(e2.errorCount, 'to be greater than', e.errorCount);
});
});
}));
}));
```
42 changes: 1 addition & 41 deletions documentation/assertions/function/to-throw.md
Expand Up @@ -83,47 +83,7 @@ to throw /catastrophic failure/
expected Error('The error message!') to satisfy /catastrophic failure/
```

You can also provide a function as the second parameter to do
arbitrary assertions on the error.

```js
expect(
function() {
this.foo.bar();
},
'to throw',
function(e) {
expect(e, 'to be a', TypeError);
}
);
```

In case of a failing expectation you get the following output:

```js
expect(function () {
throw new Error('Another error');
}, 'to throw', function (e) {
expect(e, 'to be a', TypeError);
});
```

```output
expected
function () {
throw new Error('Another error');
}
to throw
function (e) {
expect(e, 'to be a', TypeError);
}
expected Error('Another error') to be a TypeError
```

Actually what happens is, that the thrown error is checked
[to satisfy](/assertions/any/to-satisfy/) against the second
parameter. That means you could also just supply an error object to
validate against:
That can also just supply an error object to validate against:

```js
expect(
Expand Down
6 changes: 3 additions & 3 deletions documentation/assertions/object/to-have-a-value-satisfying.md
@@ -1,5 +1,5 @@
Asserts that an object contains at least one value that satisfies a given
value, function or other assertion.
value, function (wrapped in `expect.it`) or other assertion.

Note that this assertion fails if passed an empty object as the subject.

Expand All @@ -13,9 +13,9 @@ expect(
expect(
{ foo: 0, bar: 1, baz: 2, qux: 3 },
'to have a value satisfying',
function(value, index) {
expect.it(function(value) {
expect(value, 'to be a number');
}
})
);

expect(
Expand Down
4 changes: 2 additions & 2 deletions documentation/assertions/object/to-have-keys-satisfying.md
Expand Up @@ -6,11 +6,11 @@ Aliases: `to be a map whose keys satisfy`,
`to be an object whose keys satisfy`, `to be a hash whose keys satisfy`.

```js
expect({ foo: 0, bar: 1, baz: 2, qux: 3 }, 'to have keys satisfying', function(
expect({ foo: 0, bar: 1, baz: 2, qux: 3 }, 'to have keys satisfying', expect.it(function(
key
) {
expect(key, 'to match', /^[a-z]{3}$/);
});
}));

expect(
{ foo: 0, bar: 1, baz: 2, qux: 3 },
Expand Down
4 changes: 2 additions & 2 deletions documentation/assertions/object/to-have-values-satisfying.md
Expand Up @@ -9,9 +9,9 @@ Aliases: `to be a map whose values satisfy`,
expect(
{ foo: 0, bar: 1, baz: 2, qux: 3 },
'to have values satisfying',
function(value, index) {
expect.it(function(value) {
expect(value, 'to be a number');
}
})
);

expect(
Expand Down
@@ -1,4 +1,4 @@
var expect = require('../lib');
var expect = require('../lib').clone();

expect.addAssertion('<any> to bar', function(expect, subject) {
expect(subject, 'to equal', 'bar');
Expand Down
2 changes: 1 addition & 1 deletion externaltests/failingAsync.spec.js
@@ -1,4 +1,4 @@
var expect = require('../lib');
var expect = require('../lib').clone();

expect.addAssertion('<any> when delayed a little bit <assertion?>', function(
expect,
Expand Down
@@ -1,4 +1,4 @@
var expect = require('../lib');
var expect = require('../lib').clone();

it('should fail', () => {
expect.addAssertion('<any> to foo', function(expect, subject) {
Expand Down
6 changes: 5 additions & 1 deletion karma.conf.js
Expand Up @@ -17,9 +17,13 @@ module.exports = function(config) {

browsers: ['ChromeHeadlessNoSandbox', 'ie11'],

browserDisconnectTimeout: '60000',
browserNoActivityTimeout: '60000',

client: {
mocha: {
reporter: 'html'
reporter: 'html',
timeout: '60000'
}
},

Expand Down

0 comments on commit 357247c

Please sign in to comment.