Skip to content

Commit

Permalink
Change swSrc validation (#2451)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffposnick committed Apr 13, 2020
1 parent 0f2ffda commit 18939e4
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 45 deletions.
20 changes: 0 additions & 20 deletions packages/workbox-cli/src/lib/assert-valid-sw-src.js

This file was deleted.

8 changes: 1 addition & 7 deletions packages/workbox-cli/src/lib/questions/ask-sw-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
const inquirer = require('inquirer');
const ol = require('common-tags').oneLine;

const assertValidSWSrc = require('../assert-valid-sw-src');

// The key used for the question/answer.
const name = 'swSrc';

Expand All @@ -29,9 +27,5 @@ function askQuestion() {

module.exports = async () => {
const answers = await askQuestion();
const swSrc = answers[name].trim();

await assertValidSWSrc(swSrc);

return swSrc;
return answers[name].trim();
};
18 changes: 0 additions & 18 deletions test/workbox-cli/node/lib/questions/ask-sw-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,12 @@ const MODULE_PATH = '../../../../../packages/workbox-cli/src/lib/questions/ask-s
const QUESTION_NAME = 'swSrc';

describe(`[workbox-cli] lib/questions/ask-sw-src.js`, function() {
it(`should reject when the valid SW assertion fails`, async function() {
const injectedError = new Error('injected error');
const askSWSrc = proxyquire(MODULE_PATH, {
'inquirer': {
prompt: () => Promise.resolve({[QUESTION_NAME]: ''}),
},
'../assert-valid-sw-src': () => Promise.reject(injectedError),
});

try {
await askSWSrc();
throw new Error('Unexpected success.');
} catch (error) {
expect(error).to.eql(injectedError);
}
});

it(`should resolve with a valid answer to the question`, async function() {
const expectedAnswer = 'expected answer';
const askSWSrc = proxyquire(MODULE_PATH, {
'inquirer': {
prompt: () => Promise.resolve({[QUESTION_NAME]: expectedAnswer}),
},
'../assert-valid-sw-src': () => Promise.resolve(),
});

const answer = await askSWSrc();
Expand Down

0 comments on commit 18939e4

Please sign in to comment.