Skip to content

Commit

Permalink
Revert "Babel"
Browse files Browse the repository at this point in the history
  • Loading branch information
sunesimonsen committed Sep 3, 2017
1 parent 6a11ad1 commit a3173a2
Show file tree
Hide file tree
Showing 41 changed files with 203 additions and 177 deletions.
5 changes: 0 additions & 5 deletions .babelrc

This file was deleted.

1 change: 0 additions & 1 deletion .eslintignore
@@ -1,6 +1,5 @@
/documentation/
/images/
/build/
/vendor/
/coverage/
/site-build/
Expand Down
1 change: 0 additions & 1 deletion .gitignore
@@ -1,6 +1,5 @@
/node_modules/
/coverage/
/build/
/site-build/
/test/tests.html
/test/JasmineRunner.html
Expand Down
2 changes: 0 additions & 2 deletions .npmignore
@@ -1,7 +1,5 @@
/node_modules/
/site-build/
/build/test/
/build/externaltests/
/test/
/documentation/
/coverage/
Expand Down
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -6,5 +6,5 @@ node_js:
- "5"
- "6"
- "7"
- "8.4.0"
- "8"
script: "make travis"
96 changes: 29 additions & 67 deletions Makefile
Expand Up @@ -4,107 +4,64 @@ TARGETS ?= unexpected.js unexpected.js.map

CHEWBACCA_THRESHOLD ?= 25

TEST_SOURCES_MARKDOWN = $(shell find documentation -name '*.md')

MODERN_NODE = $(shell node -p -e 'require("node-version-check").gte(require("fs").readFileSync(".nvmrc", "utf8").trim())')

lint:
npm run lint

.PHONY: lint

build/lib: lib/*
babel --copy-files --out-dir build/lib --quiet lib

build/test: test/*
babel --copy-files --out-dir build/test --quiet test
sed -i -e 's#--require ./test#--require ./build/test#g' ./build/test/mocha.opts

build/externaltests: externaltests/*
babel --copy-files --out-dir build/externaltests --quiet externaltests

build: build/lib build/test build/externaltests

.PHONY: ${TARGETS}
${TARGETS}: build
./node_modules/.bin/rollup --config --sourcemap --format umd --name weknowhow.expect -o unexpected.js build/lib/index.js
${TARGETS}: lib/*
./node_modules/.bin/rollup --config --sourcemap --format umd --name weknowhow.expect -o unexpected.js lib/index.js

create-html-runners: build/test test/tests.tpl.html test/JasmineRunner.tpl.html
create-html-runners: test/tests.tpl.html test/JasmineRunner.tpl.html
@for file in tests JasmineRunner ; do \
(sed '/test files/q' ./build/test/$${file}.tpl.html | sed '$$d' && \
(sed '/test files/q' ./test/$${file}.tpl.html | sed '$$d' && \
find test -name '*.spec.js' | sed 's/test/ <script src="./' | sed 's/$$/"><\/script>/' && \
sed -n '/test files/,$$p' ./build/test/$${file}.tpl.html | sed '1d') > ./build/test/$${file}.html;\
sed -n '/test files/,$$p' ./test/$${file}.tpl.html | sed '1d') > ./test/$${file}.html;\
done

.PHONY: create-html-runners

test-phantomjs: create-html-runners ${TARGETS}
phantomjs ./node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js build/test/tests.html spec "`node -pe 'JSON.stringify({useColors:true,grep:process.env.grep})'`"
phantomjs ./node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/tests.html spec "`node -pe 'JSON.stringify({useColors:true,grep:process.env.grep})'`"

test-jest-if-supported-node-version:
ifeq ($(shell node --version | grep -vP '^v[0123]\.'),)
@echo Skipping, jest is unsupported with node $(shell node --version)
else
./node_modules/.bin/jest
endif

test-jasmine:
./node_modules/.bin/jasmine JASMINE_CONFIG_PATH=test/support/jasmine.json

test-jasmine-browser: create-html-runners ${TARGETS}
@echo open http://localhost:5000/build/test/JasmineRunner.html
@./node_modules/.bin/serve .

test-sources:
ifeq ($(MODERN_NODE), true)
MOCHA_OPTS = ./test/mocha.opts
TEST_SOURCES = $(shell find test -name '*.spec.js')
else
make build
MOCHA_OPTS = ./build/test/mocha.opts
TEST_SOURCES = $(shell find build/test -name '*.spec.js')
endif

.PHONY: test-jest
test-jest:
ifeq ($(MODERN_NODE), true)
./node_modules/.bin/jest
else
./node_modules/.bin/jest -c test/jest.es5.config.json
endif

test-jest-if-supported-node-version:
@node-version-gte-4 && 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)

nyc-includes:
ifeq ($(MODERN_NODE), true)
NYC_INCLUDES='lib/**'
else
NYC_INCLUDES='build/lib/**'
endif
TEST_SOURCES = $(shell find test -name '*.spec.js') $(shell find documentation -name '*.md')
test: lint
@./node_modules/.bin/mocha $(TEST_SOURCES)

.PHONY: coverage
coverage: nyc-includes test-sources
@./node_modules/.bin/nyc --include $(NYC_INCLUDES) --reporter=lcov --reporter=text --all -- mocha --opts $(MOCHA_OPTS) $(TEST_SOURCES) $(TEST_SOURCES_MARKDOWN)
coverage:
@./node_modules/.bin/nyc --reporter=lcov --reporter=text --all -- mocha --compilers md:unexpected-markdown test/*.js $(TEST_SOURCES)
@echo google-chrome coverage/lcov-report/index.html

.PHONY: test-browser
test-browser: create-html-runners ${TARGETS}
@echo open http://localhost:5000/build/test/tests.html
@./node_modules/.bin/serve .

.PHONY: travis-secondary
travis-secondary: test test-jest-if-supported-node-version coverage
.PHONY: travis-chewbacca
travis-chewbacca:
./node_modules/.bin/chewbacca --threshold ${CHEWBACCA_THRESHOLD} `echo ${TRAVIS_COMMIT_RANGE} | sed -e 's/\.\.\..*//;'` -- test/benchmark.spec.js

.PHONY: travis-main
travis-main: clean lint test test-jasmine test-jest coverage
travis: clean lint test travis-chewbacca test-jasmine test-jest-if-supported-node-version coverage
ifneq ($(shell node --version | grep -vP '^v[0123]\.'),)
make site-build
make test-phantomjs
-<coverage/lcov.info ./node_modules/coveralls/bin/coveralls.js

travis:
ifeq ($(MODERN_NODE), true)
make travis-main
else
make travis-secondary
endif
-<coverage/lcov.info ./node_modules/coveralls/bin/coveralls.js

.PHONY: git-dirty-check
git-dirty-check:
Expand All @@ -126,6 +83,7 @@ commit-unexpected: ${TARGETS}

.PHONY: release-%
release-%: git-dirty-check lint ${TARGETS} test-phantomjs test-jasmine test-jest-if-supported-node-version commit-unexpected deploy-site
./node_modules/.bin/chewbacca --threshold ${CHEWBACCA_THRESHOLD} `git describe --abbrev=0 --tags --match 'v*'` -- test/benchmark.spec.js
IS_MAKE_RELEASE=yes npm version $*
@echo $* release ready to be publised to NPM
@echo Remember to push tags
Expand All @@ -141,3 +99,7 @@ site-build:
.PHONY: update-examples
update-examples:
npm run update-examples

.PHONY: benchmark
benchmark:
./node_modules/.bin/mocha --no-timeouts --ui chewbacca/mocha-benchmark-ui --reporter chewbacca/mocha-benchmark-reporter test/benchmark.spec.js
2 changes: 1 addition & 1 deletion documentation/api/shift.md
Expand Up @@ -29,7 +29,7 @@ optionally takes one via `<assertion?>` and is invoked without,
`expect.shift` will propagate its argument as the fulfillment value of the
promise returned from your assertion:

```js#async:true&freshExpect:true
```js#freshExpect:true
expect.addAssertion('<string> [when] parsed as an integer <assertion?>', function (expect, subject) {
expect(subject, 'to match', /^[1-9][0-9]*$/);
return expect.shift(parseInt(subject, 10));
Expand Down
2 changes: 1 addition & 1 deletion documentation/assertions/Buffer/when-decoded-as.md
Expand Up @@ -21,7 +21,7 @@ expected Buffer([0xE2, 0x98, 0xBA]) when decoded as 'utf-8' to equal 'happy face
If you don't provide an assertion to delegate to, the decoded value will be provided
as the fulfillment value of the promise:

```js#async:true,skipBrowser:true
```js#skipBrowser:true
return expect(new Buffer([0xe2, 0x98, 0xba]), 'decoded as', 'utf-8').then(function (result) {
expect(result, 'to equal', '☺');
});
Expand Down
Expand Up @@ -27,7 +27,7 @@ assertion and also supports the `async` and `constructor` flags.
If you don't provide an assertion to delegate to, the return value will be provided
as the fulfillment value of the promise:

```js#async:true
```js
return expect(10, 'passed as parameter to', increment).then(function (result) {
expect(result, 'to equal', 11);
});
Expand Down
Expand Up @@ -50,7 +50,7 @@ expect([123], 'when passed as parameters to constructor', Foo, 'to be a', Foo);
If you don't provide an assertion to delegate to, the return value will be provided
as the fulfillment value of the promise:

```js#async:true
```js
return expect([1, 3], 'passed as parameters to', add).then(function (result) {
expect(result, 'to equal', 4);
});
Expand Down
2 changes: 1 addition & 1 deletion documentation/assertions/function/when-called-with.md
Expand Up @@ -22,7 +22,7 @@ expected function add(a, b) { return a + b; } when called with 1, 2 to equal 9
If you don't provide an assertion to delegate to, the returned value will be
provided as the fulfillment value of the promise:

```js#async
```js
return expect(add, 'called with', [1, 2]).then(function (result) {
expect(result, 'to equal', 3);
});
Expand Down
2 changes: 1 addition & 1 deletion documentation/assertions/function/when-called.md
Expand Up @@ -22,7 +22,7 @@ expected function giveMeFive() { return 5; } when called to equal 7
If you don't provide an assertion to delegate to, the return value will be provided
as the fulfillment value of the promise:

```js#async:true
```js
return expect(giveMeFive, 'called').then(function (result) {
expect(result, 'to equal', 5);
});
Expand Down
@@ -1,4 +1,4 @@
var expect = require('../lib');
var expect = require('../');

expect.addAssertion('<any> to bar', function (expect, subject) {
expect(subject, 'to equal', 'bar');
Expand Down
2 changes: 1 addition & 1 deletion externaltests/deepObject.spec.js
@@ -1,4 +1,4 @@
var expect = require('../lib');
var expect = require('../');
it('should not dot out the object in the diff', function () {
expect(function () {
expect({0: {0: {0: {0: {0: {0: {}}}}}}}, 'to equal', {});
Expand Down
2 changes: 1 addition & 1 deletion externaltests/failingAsync.spec.js
@@ -1,4 +1,4 @@
var expect = require('../lib');
var expect = require('../');

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

it('should call the callback', function () {
expect(function () {}, 'to call the callback');
Expand Down
@@ -1,4 +1,4 @@
var expect = require('../lib');
var expect = require('../');

it('should call the callback', function () {
expect(function () {}, 'to call the callback');
Expand Down
@@ -1,4 +1,4 @@
var expect = require('../lib');
var expect = require('../');

it('should call the callback', function () {
expect(function () {}, 'to call the callback');
Expand Down
@@ -1,4 +1,4 @@
var expect = require('../lib');
var expect = require('../');

it('should fail', function () {
expect.addAssertion('<any> to foo', function (expect, subject) {
Expand Down
2 changes: 1 addition & 1 deletion externaltests/fullTrace.spec.js
@@ -1,4 +1,4 @@
var expect = require('../lib').clone().use(require('./node_modules/unexpected-bogus/index.js'));
var expect = require('../').clone().use(require('./node_modules/unexpected-bogus/index.js'));

it('should fail with a full trace', function () {
expect('abc', 'to be bogus');
Expand Down
2 changes: 1 addition & 1 deletion externaltests/notToErrorCaughtError.spec.js
@@ -1,4 +1,4 @@
var expect = require('../lib');
var expect = require('../');

it('should foo', function () {
return expect(function () {
Expand Down
2 changes: 1 addition & 1 deletion externaltests/successful.spec.js
@@ -1,4 +1,4 @@
var expect = require('../lib');
var expect = require('../');

it('should call the callback', function () {
expect(true, 'to be true');
Expand Down
6 changes: 3 additions & 3 deletions lib/Unexpected.js
Expand Up @@ -300,7 +300,7 @@ Unexpected.prototype.equal = function (actual, expected, depth, seen) {
Unexpected.prototype.inspect = function (obj, depth, outputOrFormat) {
var seen = [];
var that = this;
function printOutput(obj, currentDepth, output) {
var printOutput = function (obj, currentDepth, output) {
var objType = that.findTypeOf(obj);
if (currentDepth <= 0 && objType.is('object') && !objType.is('expect.it')) {
return output.text('...');
Expand Down Expand Up @@ -852,9 +852,9 @@ function installExpectMethods(unexpected) {
expect.equal = unexpected.equal.bind(unexpected);
expect.inspect = unexpected.inspect.bind(unexpected);
expect.findTypeOf = unexpected.findTypeOf; // Already bound
expect.fail = function (...args) {
expect.fail = function () {
try {
unexpected.fail(...args);
unexpected.fail.apply(unexpected, arguments);
} catch (e) {
if (e && e._isUnexpected) {
unexpected.setErrorMessage(e);
Expand Down
7 changes: 3 additions & 4 deletions lib/addAdditionalPromiseMethods.js
@@ -1,5 +1,6 @@
function addAdditionalPromiseMethods(promise, expect, subject) {
promise.and = function (...args) {
module.exports = function addAdditionalPromiseMethods(promise, expect, subject) {
promise.and = function () { // ...
var args = Array.prototype.slice.call(arguments);
function executeAnd() {
if (expect.findTypeOf(args[0]).is('expect.it')) {
return addAdditionalPromiseMethods(args[0](subject), expect, subject);
Expand All @@ -17,5 +18,3 @@ function addAdditionalPromiseMethods(promise, expect, subject) {

return promise;
};

module.exports = addAdditionalPromiseMethods;
4 changes: 1 addition & 3 deletions lib/assertions.js
Expand Up @@ -1545,9 +1545,7 @@ module.exports = function (expect) {
return a - b;
};
}
return expect.shift(Array.prototype.slice.call(subject).sort(
typeof compareFunction === 'function' ? compareFunction : undefined
));
return expect.shift(Array.prototype.slice.call(subject).sort(compareFunction));
});

expect.addAssertion('<Promise> to be rejected', function (expect, subject) {
Expand Down
4 changes: 1 addition & 3 deletions lib/throwIfNonUnexpectedError.js
@@ -1,4 +1,4 @@
function throwIfNonUnexpectedError(err) {
module.exports = function throwIfNonUnexpectedError(err) {
if (err && err.message === 'aggregate error') {
for (var i = 0 ; i < err.length ; i += 1) {
throwIfNonUnexpectedError(err[i]);
Expand All @@ -7,5 +7,3 @@ function throwIfNonUnexpectedError(err) {
throw err;
}
};

module.exports = throwIfNonUnexpectedError;

0 comments on commit a3173a2

Please sign in to comment.