aws-spa
Version:
A no-brainer script to deploy a single page app on AWS
47 lines (42 loc) • 1.24 kB
JavaScript
;
var _inquirer = _interopRequireDefault(require("inquirer"));
var _prompt = require("./prompt");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
jest.mock('inquirer', () => {
return {
__esModule: true,
default: {
prompt: jest.fn()
}
};
});
describe('prompt', () => {
beforeEach(() => {
jest.resetAllMocks();
});
describe('predeployPrompt', () => {
const promptMock = jest.spyOn(_inquirer.default, 'prompt');
it('does not prompt if CI is true', async () => {
await (0, _prompt.predeployPrompt)(true, false);
expect(promptMock).not.toHaveBeenCalled();
});
it('does prompt if CI is not defined', async () => {
promptMock.mockResolvedValue({
continueDeploy: true
});
await (0, _prompt.predeployPrompt)(false, false);
expect(promptMock).toHaveBeenCalled();
});
it('throws if not confirmed', async () => {
expect.assertions(1);
promptMock.mockResolvedValue({
continueDeploy: false
});
try {
await (0, _prompt.predeployPrompt)(false, false);
} catch (error) {
expect(promptMock).toHaveBeenCalled();
}
});
});
});