2018-10-15 16:45:54 +02:00
|
|
|
//@flow
|
|
|
|
|
import fetchMock from "fetch-mock";
|
2018-10-29 14:53:24 +01:00
|
|
|
import {
|
|
|
|
|
getContent,
|
2018-10-29 15:57:31 +01:00
|
|
|
getLanguage
|
2018-10-29 14:53:24 +01:00
|
|
|
} 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", () => {
|
2018-10-29 14:53:24 +01:00
|
|
|
expect(getLanguage("JAVASCRIPT")).toBe("javascript");
|
2018-10-29 13:19:16 +01:00
|
|
|
});
|
2018-10-29 14:53:24 +01:00
|
|
|
it("should return nothing for plain text", () => {
|
|
|
|
|
expect(getLanguage("")).toBe("");
|
2018-10-29 13:19:16 +01:00
|
|
|
});
|
2018-10-29 11:50:55 +01:00
|
|
|
});
|