Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

refactor(index): rewrite answer parsing #541

Merged
merged 20 commits into from
Dec 2, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
write tests
  • Loading branch information
Haroenv committed Nov 29, 2021
commit 371419ee24e2df89013efb7f25938c1d35e43159
34 changes: 28 additions & 6 deletions src/cli/__tests__/isQuestionAsked.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test('with appId undefined should ask', () => {
expect(
isQuestionAsked({
question: { name: 'appId', validate: input => Boolean(input) },
args: { appId: undefined },
args: { appId: undefined, interactive: true },
})
).toBe(false);
});
Expand All @@ -13,19 +13,19 @@ test('with appId defined should not ask', () => {
expect(
isQuestionAsked({
question: { name: 'appId', validate: input => Boolean(input) },
args: { appId: 'APP_ID' },
args: { appId: 'APP_ID', interactive: true },
})
).toBe(true);
});

test('with unvalid template should ask', () => {
test('with invalid template should ask', () => {
expect(
isQuestionAsked({
question: {
name: 'template',
validate: () => false,
},
args: { template: 'Unvalid' },
args: { template: 'Unvalid', interactive: true },
})
).toBe(false);
});
Expand All @@ -37,7 +37,7 @@ test('with valid template should not ask', () => {
name: 'template',
validate: () => true,
},
args: { template: 'InstantSearch.js' },
args: { template: 'InstantSearch.js', interactive: true },
})
).toBe(true);
});
Expand All @@ -48,7 +48,29 @@ test('with indexName should ask attributesToDisplay', () => {
question: {
name: 'attributesToDisplay',
},
args: { indexName: 'INDEX_NAME' },
args: { indexName: 'INDEX_NAME', interactive: true },
})
).toBe(false);
});

test('with config it does not ask', () => {
expect(
isQuestionAsked({
question: {
name: 'attributesToDisplay',
},
args: { config: '' },
})
).toBe(true);
});

test('with --no-interactive it does not ask', () => {
expect(
isQuestionAsked({
question: {
name: 'attributesToDisplay',
},
args: { interactive: false },
})
).toBe(true);
});