2018-10-15 16:45:54 +02:00
|
|
|
//@flow
|
|
|
|
|
import fetchMock from "fetch-mock";
|
2018-10-29 11:50:55 +01:00
|
|
|
import { getContent, getLanguage } from "./SourcecodeViewer";
|
2018-10-15 16:45:54 +02:00
|
|
|
|
|
|
|
|
describe("get content", () => {
|
2018-10-29 11:50:55 +01:00
|
|
|
const CONTENT_URL = "/repositories/scmadmin/TestRepo/content/testContent";
|
2018-10-15 16:45:54 +02:00
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
fetchMock.reset();
|
|
|
|
|
fetchMock.restore();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should return content", done => {
|
|
|
|
|
fetchMock.getOnce("/api/v2" + CONTENT_URL, "This is a testContent");
|
|
|
|
|
|
|
|
|
|
getContent(CONTENT_URL).then(content => {
|
|
|
|
|
expect(content).toBe("This is a testContent");
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
2018-10-29 11:50:55 +01:00
|
|
|
|
2018-10-29 13:19:16 +01:00
|
|
|
describe("get correct language type", () => {
|
2018-10-29 11:50:55 +01:00
|
|
|
it("should return javascript", () => {
|
|
|
|
|
expect(getLanguage("application/javascript")).toBe("javascript");
|
|
|
|
|
});
|
|
|
|
|
it("should return text", () => {
|
|
|
|
|
expect(getLanguage("text/plain")).toBe("plain");
|
|
|
|
|
});
|
2018-10-29 13:19:16 +01:00
|
|
|
it("should return go", () => {
|
|
|
|
|
expect(getLanguage("text/x-go")).toBe("go");
|
|
|
|
|
});
|
|
|
|
|
it("should return java", () => {
|
|
|
|
|
expect(getLanguage("text/x-java-source")).toBe("java");
|
|
|
|
|
});
|
|
|
|
|
it("should return markdown", () => {
|
|
|
|
|
expect(getLanguage("text/x-web-markdown")).toBe("markdown");
|
|
|
|
|
});
|
2018-10-29 11:50:55 +01:00
|
|
|
});
|