mirror of
https://github.com/hanzoai/workbox.git
synced 2026-09-24 17:04:35 +00:00
* 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
34 lines
949 B
JavaScript
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.'});
|
|
});
|
|
});
|