editorutils.spec.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import { getEditorLangForMimeType } from "../editorutils"
  2. describe("getEditorLangForMimeType", () => {
  3. test("returns 'json' for valid JSON mimes", () => {
  4. expect(getEditorLangForMimeType("application/json")).toMatch("json")
  5. expect(getEditorLangForMimeType("application/hal+json")).toMatch("json")
  6. expect(getEditorLangForMimeType("application/vnd.api+json")).toMatch("json")
  7. })
  8. test("returns 'xml' for valid XML mimes", () => {
  9. expect(getEditorLangForMimeType("application/xml")).toMatch("xml")
  10. })
  11. test("returns 'html' for valid HTML mimes", () => {
  12. expect(getEditorLangForMimeType("text/html")).toMatch("html")
  13. })
  14. test("returns 'text/x-yaml' for plain text mime", () => {
  15. expect(getEditorLangForMimeType("text/plain")).toMatch("text/x-yaml")
  16. })
  17. test("returns 'text/x-yaml' for unimplemented mimes", () => {
  18. expect(getEditorLangForMimeType("image/gif")).toMatch("text/x-yaml")
  19. })
  20. test("returns 'text/x-yaml' for null/undefined mimes", () => {
  21. expect(getEditorLangForMimeType(null)).toMatch("text/x-yaml")
  22. expect(getEditorLangForMimeType(undefined)).toMatch("text/x-yaml")
  23. })
  24. })