Skip to content

Commit

Permalink
Merge 8a3f5be into 5cb7f34
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed Sep 6, 2018
2 parents 5cb7f34 + 8a3f5be commit 46c44bc
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -16,6 +16,7 @@ before_install:

after_success:
- npm run coverage
- npm run integration-test

before_script:
# we only need to run eslint once per build, so let's conserve a few resources
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -11,9 +11,11 @@
"build:dist-folder": "mkdirp dist",
"coverage": "nyc report --reporter text-lcov | coveralls",
"test": "nyc mocha",
"//integration-test": "This cannot run as a prepare step, as it will trigger a loop",
"integration-test": "test-repos/do-test.sh",
"lint": "eslint .",
"prepare": "run-p test lint build",
"preversion": "./scripts/preversion.sh"
"preversion": "test-repos/do-test.sh && ./scripts/preversion.sh"
},
"greenkeeper": {
"ignore": [
Expand Down
2 changes: 2 additions & 0 deletions test-repos/.gitignore
@@ -0,0 +1,2 @@
package-lock.json
test*js
4 changes: 4 additions & 0 deletions test-repos/cjs-pre.js
@@ -0,0 +1,4 @@
/* eslint-disable */
var sinon = require("sinon");
var sinonTestFactory = require("sinon-test");
var assert = require("assert");
20 changes: 20 additions & 0 deletions test-repos/do-test.sh
@@ -0,0 +1,20 @@
#!/bin/bash
set -e;

# make sure we can call this script from everywhere and still have relative paths working
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd "$SCRIPT_DIR" > /dev/null

# build test files
cat esm-pre.mjs test-body.js > test.mjs
cat cjs-pre.js test-body.js > test.js
cat esm-bundle-pre.mjs test-body.js > test-bundle.mjs
cat umd-bundle-pre.js test-body.js > test-bundle.js

cd ..
npm link # create a global symlink to the local sinon-test project
cd "$SCRIPT_DIR"

npm install
npm link sinon-test # use local version
npm test
3 changes: 3 additions & 0 deletions test-repos/esm-bundle-pre.mjs
@@ -0,0 +1,3 @@
import sinon from 'sinon';
import sinonTestFactory from 'sinon-test';
import assert from 'assert';
3 changes: 3 additions & 0 deletions test-repos/esm-pre.mjs
@@ -0,0 +1,3 @@
import sinon from 'sinon';
import sinonTestFactory from 'sinon-test';
import assert from 'assert';
14 changes: 14 additions & 0 deletions test-repos/package.json
@@ -0,0 +1,14 @@
{
"name": "test-integration",
"version": "1.0.0",
"description": "Tests the integration using other consumers",
"dependencies": {
"esm": "^3.0.82",
"sinon-test": "^2.2.1"
},
"scripts": {
"test": "node -r esm test.mjs && node test.js && node -r esm test-bundle.mjs && node test-bundle.js"
},
"author": "",
"license": "ISC"
}
20 changes: 20 additions & 0 deletions test-repos/test-body.js
@@ -0,0 +1,20 @@
/* eslint-disable */
var sinonTest = sinonTestFactory(sinon);

var testFramework = {
"the usual suspects should be present": sinonTest(
function myTestFunction() {
["stub", "spy", "mock"].forEach(function(func) {
assert.equal(typeof this[func], "function");
}, this);
["clock", "server"].forEach(function(name) {
assert.equal(typeof this[name], "object");
}, this);
}
),
"basic functionality should work": sinonTest(function myTestFunction() {
assert.equal(this.stub().returns(42)(), 42);
})
};

for (var test in testFramework) testFramework[test].call(testFramework);
4 changes: 4 additions & 0 deletions test-repos/umd-bundle-pre.js
@@ -0,0 +1,4 @@
/* eslint-disable */
var sinon = require("sinon");
var sinonTestFactory = require("sinon-test/dist/sinon-test");
var assert = require("assert");

0 comments on commit 46c44bc

Please sign in to comment.