Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deps #250

Merged
merged 8 commits into from
Jan 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/test/fixtures/built-sw.js
/es5/
package-lock.json
/node_modules/
Expand Down
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
.PHONY: test

build-sw:
./node_modules/.bin/browserify test/fixtures/sw.js > test/fixtures/built-sw.js
test-dev:
./node_modules/karma/bin/karma start --browsers=Chrome

test-dev: build-sw
./node_modules/karma/bin/karma start

test-chrome: build-sw
test-chrome:
./node_modules/karma/bin/karma start --single-run --browsers=Chrome

test-firefox: build-sw
test-firefox:
./node_modules/karma/bin/karma start --single-run --browsers=Firefox

test-unit:
Expand Down
36 changes: 21 additions & 15 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,36 @@ module.exports = function(karma) {

var configuration = {

frameworks: [ 'mocha', 'chai', 'browserify'],
frameworks: [ 'mocha' ],
files: [
'http://cdn.polyfill.io/v2/polyfill.min.js?features=default,Promise,fetch,Array.prototype.map,Array.prototype.filter',
'test/client.js',
'test/sw.js',
{pattern: 'test/fixtures/built-sw.js', served: true, included: false},
{pattern: 'test/fixtures/sw.js', served: true, included: false},
],
proxies: {
'/__sw.js': '/base/test/fixtures/built-sw.js'
'/__sw.js': '/base/test/fixtures/sw.js'
},
preprocessors: {
'test/*.js': ['browserify']
'test/**/*.js': ['webpack']
},
browserify: {
debug: true,
transform: [
['babelify', {
'presets': ['es2017'],
'plugins': ['transform-object-assign']
}]
]
webpack: {
devtool: 'source-map',
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
babelrc: false, // ignore any .babelrc in project & dependencies
cacheDirectory: true,
plugins: ['transform-runtime'],
presets: ['env']
}
}
]
}
}
};

karma.set(configuration);

};
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"browser": "es5/client.js",
"scripts": {
"test": "make lint test",
"browserify": "browserify -s fetchMock es5/client.js > es5/client-bundle.js",
"prepublish": "babel src --out-dir es5 --plugins transform-object-assign --presets es2017 && npm run browserify"
"bundle": "webpack --output-library fetchMock --entry ./es5/client.js --output-filename ./es5/client-bundle.js",
"prepublish": "babel src --out-dir es5 --presets env --plugins transform-runtime && npm run bundle"
},
"repository": {
"type": "git",
Expand All @@ -30,30 +30,28 @@
"homepage": "http://www.wheresrhys.co.uk/fetch-mock",
"dependencies": {
"glob-to-regexp": "^0.3.0",
"path-to-regexp": "^1.7.0"
"path-to-regexp": "^2.1.0"
},
"devDependencies": {
"babel": "^6.0.15",
"babel-cli": "^6.1.2",
"babel-plugin-transform-object-assign": "^6.8.0",
"babel-preset-es2017": "^6.1.2",
"babelify": "^7.3.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"bluebird": "^3.4.6",
"browserify": "^13.1.0",
"chai": "^4.1.2",
"coveralls": "^2.11.16",
"eslint": "^4.14.0",
"istanbul": "^1.1.0-alpha.1",
"karma": "^1.3.0",
"karma-browserify": "^5.1.0",
"karma": "^2.0.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.2.0",
"karma-mocha": "^1.3.0",
"karma-webpack": "^2.0.9",
"mocha": "^4.0.1",
"node-fetch": "^2.0.0-alpha.9",
"sinon": "^4.1.3",
"sinon-chai": "^2.14.0",
"watchify": "^3.7.0",
"whatwg-fetch": "^0.10.1"
"webpack": "^3.10.0"
}
}
2 changes: 0 additions & 2 deletions src/client.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const FetchMock = require('./lib/index');
const statusTextMap = require('./lib/status-text');
const theGlobal = typeof window !== 'undefined' ? window : self;
Expand Down
1 change: 0 additions & 1 deletion src/lib/compile-route.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
'use strict';
const glob = require('glob-to-regexp')
const express = require('path-to-regexp');
const URL = require('url');
Expand Down
30 changes: 25 additions & 5 deletions test/client.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
'use strict';

require('whatwg-fetch');

const fetchMock = require('../src/client.js');
const expect = require('chai').expect;

Expand Down Expand Up @@ -57,4 +53,28 @@ describe('no real fetch', function () {
fetchMock.realFetch = realFetchCache;
window.fetch = fetchCache;
});
});
});

describe('service worker', () => {
it('should work within a service worker', () => {
return navigator.serviceWorker && navigator.serviceWorker.register('__sw.js')
.then(registration => {
return new Promise((resolve, reject) => {
if (registration.installing) {
registration.installing.onstatechange = function () {
if (this.state === 'activated') {
resolve();
}
}
} else {
reject('No idea what happened');
}
})
.then(() => {
expect(true).to.be.true;
return navigator.serviceWorker.getRegistration()
.then(registration => registration ? registration.unregister() : false);
})
})
})
})
24 changes: 0 additions & 24 deletions test/sw.js

This file was deleted.