Files
workbox/packages/sw-cli/test/node/utils-save-config.js
T
Matt GauntandAddy Osmani 1f62f7a2b3 Test sweep (#420)
* Big ole test re-jig

* Current work

* Moving all tests over to the test runner

* Fixing last nits in the build and test runner

* Adding precaching integration tests

* Moving sw-appcache-behavior to integration test

* Adding bg-sync to test suite again - incoming fails

* Fixing the last pieces of the test sweep

* Removing logs

* Removing number of repeats in tests - should be determined by the individual tests - not the runner

* Small move around with sw-appcache

* Retry the end to end-to-end test
2017-04-07 10:59:53 -07:00

34 lines
949 B
JavaScript

const proxyquire = require('proxyquire');
const errors = require('../../src/lib/errors');
describe('Test Save Config', function() {
it('should be able to handle writeFile error', function() {
const saveConfig = proxyquire('../../src/lib/utils/save-config', {
fs: {
writeFile: (path, content, cb) => {
cb(new Error('Injected Error'));
},
},
});
return saveConfig({example: 'Hi.'})
.then(() => {
throw new Error('Expected error to be thrown.');
}, (err) => {
if (err.message.indexOf(errors['config-write-failure']) !== 0) {
throw new Error('Unexpected error thrown.');
}
});
});
it('should resolve on writing file', function() {
const saveConfig = proxyquire('../../src/lib/utils/save-config', {
fs: {
writeFile: (path, content, cb) => {
cb(null);
},
},
});
return saveConfig({example: 'Hi.'});
});
});