SnippetsTestMessageProvider.test.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import EOYSnippetSchema from "../../../content-src/asrouter/templates/EOYSnippet/EOYSnippet.schema.json";
  2. import SimpleBelowSearchSnippetSchema from "../../../content-src/asrouter/templates/SimpleBelowSearchSnippet/SimpleBelowSearchSnippet.schema.json";
  3. import SimpleSnippetSchema from "../../../content-src/asrouter/templates/SimpleSnippet/SimpleSnippet.schema.json";
  4. import {SnippetsTestMessageProvider} from "../../../lib/SnippetsTestMessageProvider.jsm";
  5. import SubmitFormSnippetSchema from "../../../content-src/asrouter/templates/SubmitFormSnippet/SubmitFormSnippet.schema.json";
  6. const schemas = {
  7. "simple_snippet": SimpleSnippetSchema,
  8. "newsletter_snippet": SubmitFormSnippetSchema,
  9. "fxa_signup_snippet": SubmitFormSnippetSchema,
  10. "send_to_device_snippet": SubmitFormSnippetSchema,
  11. "eoy_snippet": EOYSnippetSchema,
  12. "simple_below_search_snippet": SimpleBelowSearchSnippetSchema,
  13. };
  14. describe("SnippetsTestMessageProvider", () => {
  15. let messages = SnippetsTestMessageProvider.getMessages();
  16. it("should return an array of messages", () => {
  17. assert.isArray(messages);
  18. });
  19. it("should have a valid example of each schema", () => {
  20. Object.keys(schemas).forEach(templateName => {
  21. const example = messages.find(message => message.template === templateName);
  22. assert.ok(example, `has a ${templateName} example`);
  23. });
  24. });
  25. it("should have examples that are valid", () => {
  26. messages.forEach(example => {
  27. assert.jsonSchema(example.content, schemas[example.template], `${example.id} should be valid`);
  28. });
  29. });
  30. });