unpkg/server/utils/__tests__/getFileContentType-test.js

36 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-02-18 02:00:56 +00:00
const getFileContentType = require("../getFileContentType");
2017-08-18 19:57:42 +00:00
2017-11-25 21:25:01 +00:00
it("gets a content type of text/plain for LICENSE|README|CHANGES|AUTHORS|Makefile", () => {
2018-02-18 02:00:56 +00:00
expect(getFileContentType("AUTHORS")).toBe("text/plain");
expect(getFileContentType("CHANGES")).toBe("text/plain");
expect(getFileContentType("LICENSE")).toBe("text/plain");
expect(getFileContentType("Makefile")).toBe("text/plain");
expect(getFileContentType("PATENTS")).toBe("text/plain");
expect(getFileContentType("README")).toBe("text/plain");
});
2017-08-18 19:57:42 +00:00
2017-11-25 21:25:01 +00:00
it("gets a content type of text/plain for .*rc files", () => {
2018-02-18 02:00:56 +00:00
expect(getFileContentType(".eslintrc")).toBe("text/plain");
expect(getFileContentType(".babelrc")).toBe("text/plain");
expect(getFileContentType(".anythingrc")).toBe("text/plain");
});
2017-08-18 19:57:42 +00:00
2017-11-25 21:25:01 +00:00
it("gets a content type of text/plain for .git* files", () => {
2018-02-18 02:00:56 +00:00
expect(getFileContentType(".gitignore")).toBe("text/plain");
expect(getFileContentType(".gitanything")).toBe("text/plain");
});
2017-08-18 19:57:42 +00:00
2017-11-25 21:25:01 +00:00
it("gets a content type of text/plain for .*ignore files", () => {
2018-02-18 02:00:56 +00:00
expect(getFileContentType(".eslintignore")).toBe("text/plain");
expect(getFileContentType(".anythingignore")).toBe("text/plain");
});
2017-08-18 19:57:42 +00:00
2017-11-25 21:25:01 +00:00
it("gets a content type of text/plain for .ts files", () => {
2018-02-18 02:00:56 +00:00
expect(getFileContentType("app.ts")).toBe("text/plain");
expect(getFileContentType("app.d.ts")).toBe("text/plain");
});
2017-08-18 19:57:42 +00:00
2017-11-25 21:25:01 +00:00
it("gets a content type of text/plain for .flow files", () => {
2018-02-18 02:00:56 +00:00
expect(getFileContentType("app.js.flow")).toBe("text/plain");
});