unit tests for DockerfilePathSelectComponent
This commit is contained in:
parent
38e40665a7
commit
5ef4357dec
1 changed files with 35 additions and 4 deletions
|
@ -10,50 +10,81 @@ describe("DockerfilePathSelectComponent", () => {
|
|||
|
||||
beforeEach(() => {
|
||||
component = new DockerfilePathSelectComponent();
|
||||
currentPath = '/';
|
||||
isValidPath = false;
|
||||
paths = ['/'];
|
||||
supportsFullListing = true;
|
||||
component.currentPath = currentPath;
|
||||
component.isValidPath = isValidPath;
|
||||
component.paths = paths;
|
||||
component.supportsFullListing = supportsFullListing;
|
||||
});
|
||||
|
||||
describe("$onChanges", () => {
|
||||
|
||||
it("sets valid path flag to true if current path is valid", () => {
|
||||
component.$onChanges({});
|
||||
|
||||
expect(component.isValidPath).toBe(true);
|
||||
});
|
||||
|
||||
it("sets valid path flag to false if current path is invalid", () => {
|
||||
component.currentPath = "asdfdsf";
|
||||
component.$onChanges({});
|
||||
|
||||
expect(component.isValidPath).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setPath", () => {
|
||||
var newPath: string;
|
||||
|
||||
it("sets current path to given path", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
newPath = '/conf';
|
||||
});
|
||||
|
||||
it("sets selected path to null", () => {
|
||||
it("sets current path to given path", () => {
|
||||
component.setPath(newPath);
|
||||
|
||||
expect(component.currentPath).toEqual(newPath);
|
||||
});
|
||||
|
||||
it("sets valid path flag to true if given path is valid", () => {
|
||||
component.setPath(newPath);
|
||||
|
||||
expect(component.isValidPath).toBe(true);
|
||||
});
|
||||
|
||||
it("sets valid path flag to false if given path is invalid", () => {
|
||||
component.setPath("asdfsadfs");
|
||||
|
||||
expect(component.isValidPath).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setCurrentPath", () => {
|
||||
var newPath: string;
|
||||
|
||||
it("sets current path and selected path to given path", () => {
|
||||
beforeEach(() => {
|
||||
newPath = '/conf';
|
||||
});
|
||||
|
||||
it("sets current path to given path", () => {
|
||||
component.setSelectedPath(newPath);
|
||||
|
||||
expect(component.currentPath).toEqual(newPath);
|
||||
});
|
||||
|
||||
it("sets valid path flag to true if given path is valid", () => {
|
||||
component.setSelectedPath(newPath);
|
||||
|
||||
expect(component.isValidPath).toBe(true);
|
||||
});
|
||||
|
||||
it("sets valid path flag to false if given path is invalid", () => {
|
||||
component.setSelectedPath("a;lskjdf;ldsa");
|
||||
|
||||
expect(component.isValidPath).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
Reference in a new issue