diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/components/newtab/test/unit/asrouter/SnippetsTestMessageProvider.test.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/newtab/test/unit/asrouter/SnippetsTestMessageProvider.test.js')
-rw-r--r-- | browser/components/newtab/test/unit/asrouter/SnippetsTestMessageProvider.test.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/browser/components/newtab/test/unit/asrouter/SnippetsTestMessageProvider.test.js b/browser/components/newtab/test/unit/asrouter/SnippetsTestMessageProvider.test.js new file mode 100644 index 0000000000..fc8fbe15ac --- /dev/null +++ b/browser/components/newtab/test/unit/asrouter/SnippetsTestMessageProvider.test.js @@ -0,0 +1,43 @@ +import EOYSnippetSchema from "../../../content-src/asrouter/templates/EOYSnippet/EOYSnippet.schema.json"; +import SimpleBelowSearchSnippetSchema from "../../../content-src/asrouter/templates/SimpleBelowSearchSnippet/SimpleBelowSearchSnippet.schema.json"; +import SimpleSnippetSchema from "../../../content-src/asrouter/templates/SimpleSnippet/SimpleSnippet.schema.json"; +import { SnippetsTestMessageProvider } from "../../../lib/SnippetsTestMessageProvider.sys.mjs"; +import SubmitFormSnippetSchema from "../../../content-src/asrouter/templates/SubmitFormSnippet/SubmitFormSnippet.schema.json"; +import SubmitFormScene2SnippetSchema from "../../../content-src/asrouter/templates/SubmitFormSnippet/SubmitFormScene2Snippet.schema.json"; + +const schemas = { + simple_snippet: SimpleSnippetSchema, + newsletter_snippet: SubmitFormSnippetSchema, + fxa_signup_snippet: SubmitFormSnippetSchema, + send_to_device_snippet: SubmitFormSnippetSchema, + send_to_device_scene2_snippet: SubmitFormScene2SnippetSchema, + eoy_snippet: EOYSnippetSchema, + simple_below_search_snippet: SimpleBelowSearchSnippetSchema, +}; + +describe("SnippetsTestMessageProvider", async () => { + let messages = await SnippetsTestMessageProvider.getMessages(); + + it("should return an array of messages", () => { + assert.isArray(messages); + }); + + it("should have a valid example of each schema", () => { + Object.keys(schemas).forEach(templateName => { + const example = messages.find( + message => message.template === templateName + ); + assert.ok(example, `has a ${templateName} example`); + }); + }); + + it("should have examples that are valid", () => { + messages.forEach(example => { + assert.jsonSchema( + example.content, + schemas[example.template], + `${example.id} should be valid` + ); + }); + }); +}); |