Skip to content

Commit

Permalink
add test for HTML snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
saahithjanapati committed Jun 15, 2023
1 parent 6592865 commit 12018fd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/transformers/searchservice/createDirectAnswer.ts
Expand Up @@ -32,6 +32,38 @@ it('can create a FeaturedSnippetDirectAnswer', () => {
expect(actualDirectAnswer).toMatchObject(expectedDirectAnswer);
});


Check warning on line 35 in tests/transformers/searchservice/createDirectAnswer.ts

View workflow job for this annotation

GitHub Actions / call_run_tests / tests (16.x)

More than 1 blank line not allowed

Check warning on line 35 in tests/transformers/searchservice/createDirectAnswer.ts

View workflow job for this annotation

GitHub Actions / call_run_tests / tests (14.x)

More than 1 blank line not allowed

Check warning on line 35 in tests/transformers/searchservice/createDirectAnswer.ts

View workflow job for this annotation

GitHub Actions / linting / linting

More than 1 blank line not allowed

Check warning on line 35 in tests/transformers/searchservice/createDirectAnswer.ts

View workflow job for this annotation

GitHub Actions / call_run_tests / tests (16.x)

More than 1 blank line not allowed
it('can create a FeaturedSnippetDirectAnswer with an HTML snippet', () => {
const apiFeaturedSnippetDirectAnswer = {
type: 'FEATURED_SNIPPET',
answer: {
value: 'Honolulu. Hawaii',
fieldType: 'html',
snippet: {
matchedSubstrings: [],
value: '<p>senator from 1997 to 2004. Obama was born in Honolulu. Hawaii. After graduating</p>'
}
},
relatedItem: {
verticalConfigId: 'wiki_bios',
data: {}
}
};
const actualDirectAnswer = createDirectAnswer(apiFeaturedSnippetDirectAnswer);
const expectedDirectAnswer = {
type: DirectAnswerType.FeaturedSnippet,
value: 'Honolulu. Hawaii',
relatedResult: {},
verticalKey: 'wiki_bios',
fieldType: 'html',
snippet: {
matchedSubstrings: [],
value: '<p>senator from 1997 to 2004. Obama was born in Honolulu. Hawaii. After graduating</p>'
}
};
expect(actualDirectAnswer).toMatchObject(expectedDirectAnswer);
});

it('can handle unexpected fieldType for a FeaturedSnippetDirectAnswer', () => {
const apiFeaturedSnippetDirectAnswer = {
type: 'FEATURED_SNIPPET',
Expand Down

0 comments on commit 12018fd

Please sign in to comment.