Skip to content

Commit

Permalink
test(unit): converted a couple more of the base scaffolder tests to v…
Browse files Browse the repository at this point in the history
…itest

for #1276
  • Loading branch information
travi committed Jul 7, 2023
1 parent 8d67eb9 commit e23f8ee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
23 changes: 0 additions & 23 deletions src/scaffolder-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,6 @@ suite('project scaffolder', () => {

teardown(() => sandbox.restore());

test('that the options are optional', async () => {
const gitRepoShouldBeInitialized = any.boolean();
optionsValidator.validate.returns({});
prompts.promptForBaseDetails
.withArgs(projectPath, undefined)
.resolves({[coreQuestionNames.PROJECT_NAME]: projectName, [questionNames.GIT_REPO]: gitRepoShouldBeInitialized});
languagePrompt.default.resolves({});

await scaffold();

assert.calledWith(gitScaffolder.initialize, gitRepoShouldBeInitialized, projectPath, projectName, {});
});

test('that each option is optional', () => {
const emptyOptions = {};
optionsValidator.validate.withArgs(emptyOptions).returns({});
prompts.promptForBaseDetails.withArgs(projectPath, undefined).resolves({});
languagePrompt.default.resolves({});
gitScaffolder.initialize.resolves({});

return scaffold(emptyOptions);
});

test('that the PRs-welcome badge is included for public projects', () => {
optionsValidator.validate.withArgs(options).returns({});
prompts.promptForBaseDetails.resolves({
Expand Down
27 changes: 27 additions & 0 deletions src/scaffolder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,31 @@ describe('project scaffolder', () => {
nextSteps: [...gitNextSteps, ...dependencyUpdaterNextSteps]
});
});

it('should consider all options to be optional', async () => {
const gitRepoShouldBeInitialized = any.boolean();
optionsValidator.validate.mockReturnValue({});
when(prompts.promptForBaseDetails)
.calledWith(projectPath, undefined, undefined)
.mockResolvedValue({
[coreQuestionNames.PROJECT_NAME]: projectName,
[questionNames.GIT_REPO]: gitRepoShouldBeInitialized
});
languagePrompt.default.mockResolvedValue({});

await scaffold();

expect(gitScaffolder.initialize)
.toHaveBeenCalledWith(gitRepoShouldBeInitialized, projectPath, projectName, {}, undefined, undefined);
});

it('should consider each option optional', async () => {
const emptyOptions = {};
when(optionsValidator.validate).calledWith(emptyOptions).mockReturnValue({});
when(prompts.promptForBaseDetails).calledWith(projectPath, undefined, undefined).mockResolvedValue({});
languagePrompt.default.mockResolvedValue({});
gitScaffolder.initialize.mockResolvedValue({});

await scaffold(emptyOptions);
});
});

0 comments on commit e23f8ee

Please sign in to comment.