mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 02:06:18 +01:00
show Content if currect file is no directory
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// @flow
|
||||
|
||||
import type { Repository } from "@scm-manager/ui-types";
|
||||
import type { Repository, File } from "@scm-manager/ui-types";
|
||||
import configureMockStore from "redux-mock-store";
|
||||
import thunk from "redux-thunk";
|
||||
import fetchMock from "fetch-mock";
|
||||
@@ -14,7 +14,8 @@ import {
|
||||
isFetchSourcesPending,
|
||||
default as reducer,
|
||||
getSources,
|
||||
fetchSourcesSuccess
|
||||
fetchSourcesSuccess,
|
||||
isDirectory
|
||||
} from "./sources";
|
||||
|
||||
const sourcesUrl =
|
||||
@@ -79,6 +80,42 @@ const collection = {
|
||||
}
|
||||
};
|
||||
|
||||
const noDirectory: File = {
|
||||
name: "src",
|
||||
path: "src",
|
||||
directory: true,
|
||||
length: 176,
|
||||
revision: "abc",
|
||||
_links: {
|
||||
self: {
|
||||
href:
|
||||
"http://localhost:8081/scm/rest/api/v2/repositories/scm/core/sources/76aae4bb4ceacf0e88938eb5b6832738b7d537b4/src"
|
||||
}
|
||||
},
|
||||
_embedded: collection
|
||||
};
|
||||
|
||||
const directory: File = {
|
||||
name: "package.json",
|
||||
path: "package.json",
|
||||
directory: false,
|
||||
description: "bump version",
|
||||
length: 780,
|
||||
lastModified: "2017-07-31T11:17:19Z",
|
||||
revision: "abc",
|
||||
_links: {
|
||||
self: {
|
||||
href:
|
||||
"http://localhost:8081/scm/rest/api/v2/repositories/scm/core/content/76aae4bb4ceacf0e88938eb5b6832738b7d537b4/package.json"
|
||||
},
|
||||
history: {
|
||||
href:
|
||||
"http://localhost:8081/scm/rest/api/v2/repositories/scm/core/sources/history/76aae4bb4ceacf0e88938eb5b6832738b7d537b4/package.json"
|
||||
}
|
||||
},
|
||||
_embedded: {}
|
||||
};
|
||||
|
||||
describe("sources fetch", () => {
|
||||
const mockStore = configureMockStore([thunk]);
|
||||
|
||||
@@ -168,6 +205,28 @@ describe("reducer tests", () => {
|
||||
});
|
||||
|
||||
describe("selector tests", () => {
|
||||
it("should return false if it is no directory", () => {
|
||||
const state = {
|
||||
sources: {
|
||||
"scm/core/abc/src/main/package.json": {
|
||||
noDirectory
|
||||
}
|
||||
}
|
||||
};
|
||||
expect(
|
||||
isDirectory(state, repository, "abc", "src/main/package.json")
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should return true if it is directory", () => {
|
||||
const state = {
|
||||
sources: {
|
||||
"scm/core/abc/src": noDirectory
|
||||
}
|
||||
};
|
||||
expect(isDirectory(state, repository, "abc", "src")).toBe(true);
|
||||
});
|
||||
|
||||
it("should return null", () => {
|
||||
expect(getSources({}, repository)).toBeFalsy();
|
||||
});
|
||||
@@ -181,7 +240,7 @@ describe("selector tests", () => {
|
||||
expect(getSources(state, repository)).toBe(collection);
|
||||
});
|
||||
|
||||
it("should return the source collection without revision and path", () => {
|
||||
it("should return the source collection with revision and path", () => {
|
||||
const state = {
|
||||
sources: {
|
||||
"scm/core/abc/src/main": collection
|
||||
|
||||
Reference in New Issue
Block a user