2017-05-22 20:59:12 +00:00
|
|
|
import { DockerfilePathSelectComponent, PathChangeEvent } from './dockerfile-path-select.component';
|
2017-02-17 23:46:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe("DockerfilePathSelectComponent", () => {
|
|
|
|
var component: DockerfilePathSelectComponent;
|
|
|
|
var currentPath: string;
|
|
|
|
var isValidPath: boolean;
|
|
|
|
var paths: string[];
|
|
|
|
var supportsFullListing: boolean;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
component = new DockerfilePathSelectComponent();
|
2017-02-17 23:58:52 +00:00
|
|
|
currentPath = '/';
|
|
|
|
isValidPath = false;
|
|
|
|
paths = ['/'];
|
|
|
|
supportsFullListing = true;
|
|
|
|
component.currentPath = currentPath;
|
|
|
|
component.isValidPath = isValidPath;
|
|
|
|
component.paths = paths;
|
|
|
|
component.supportsFullListing = supportsFullListing;
|
2017-02-17 23:46:43 +00:00
|
|
|
});
|
|
|
|
|
2017-04-05 21:14:08 +00:00
|
|
|
describe("ngOnChanges", () => {
|
2017-02-17 23:46:43 +00:00
|
|
|
|
|
|
|
it("sets valid path flag to true if current path is valid", () => {
|
2017-04-05 21:14:08 +00:00
|
|
|
component.ngOnChanges({});
|
2017-02-17 23:46:43 +00:00
|
|
|
|
2017-02-17 23:58:52 +00:00
|
|
|
expect(component.isValidPath).toBe(true);
|
2017-02-17 23:46:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("sets valid path flag to false if current path is invalid", () => {
|
2017-02-17 23:58:52 +00:00
|
|
|
component.currentPath = "asdfdsf";
|
2017-04-05 21:14:08 +00:00
|
|
|
component.ngOnChanges({});
|
2017-02-17 23:46:43 +00:00
|
|
|
|
2017-02-17 23:58:52 +00:00
|
|
|
expect(component.isValidPath).toBe(false);
|
2017-02-17 23:46:43 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("setPath", () => {
|
2017-02-17 23:58:52 +00:00
|
|
|
var newPath: string;
|
2017-02-17 23:46:43 +00:00
|
|
|
|
2017-02-17 23:58:52 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
newPath = '/conf';
|
2017-02-17 23:46:43 +00:00
|
|
|
});
|
|
|
|
|
2017-02-17 23:58:52 +00:00
|
|
|
it("sets current path to given path", () => {
|
|
|
|
component.setPath(newPath);
|
2017-02-17 23:46:43 +00:00
|
|
|
|
2017-02-17 23:58:52 +00:00
|
|
|
expect(component.currentPath).toEqual(newPath);
|
2017-02-17 23:46:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("sets valid path flag to true if given path is valid", () => {
|
2017-02-17 23:58:52 +00:00
|
|
|
component.setPath(newPath);
|
2017-02-17 23:46:43 +00:00
|
|
|
|
2017-02-17 23:58:52 +00:00
|
|
|
expect(component.isValidPath).toBe(true);
|
2017-02-17 23:46:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("sets valid path flag to false if given path is invalid", () => {
|
2017-02-17 23:58:52 +00:00
|
|
|
component.setPath("asdfsadfs");
|
2017-02-17 23:46:43 +00:00
|
|
|
|
2017-02-17 23:58:52 +00:00
|
|
|
expect(component.isValidPath).toBe(false);
|
2017-02-17 23:46:43 +00:00
|
|
|
});
|
2017-05-22 20:59:12 +00:00
|
|
|
|
|
|
|
it("emits output event indicating Dockerfile path has changed", (done) => {
|
|
|
|
component.pathChanged.subscribe((event: PathChangeEvent) => {
|
|
|
|
expect(event.path).toEqual(newPath);
|
|
|
|
expect(event.isValid).toBe(component.isValidPath);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
component.setPath(newPath);
|
|
|
|
});
|
2017-02-17 23:46:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("setCurrentPath", () => {
|
2017-02-17 23:58:52 +00:00
|
|
|
var newPath: string;
|
2017-02-17 23:46:43 +00:00
|
|
|
|
2017-02-17 23:58:52 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
newPath = '/conf';
|
|
|
|
});
|
|
|
|
|
|
|
|
it("sets current path to given path", () => {
|
|
|
|
component.setSelectedPath(newPath);
|
2017-02-17 23:46:43 +00:00
|
|
|
|
2017-02-17 23:58:52 +00:00
|
|
|
expect(component.currentPath).toEqual(newPath);
|
2017-02-17 23:46:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("sets valid path flag to true if given path is valid", () => {
|
2017-02-17 23:58:52 +00:00
|
|
|
component.setSelectedPath(newPath);
|
2017-02-17 23:46:43 +00:00
|
|
|
|
2017-02-17 23:58:52 +00:00
|
|
|
expect(component.isValidPath).toBe(true);
|
2017-02-17 23:46:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("sets valid path flag to false if given path is invalid", () => {
|
2017-02-17 23:58:52 +00:00
|
|
|
component.setSelectedPath("a;lskjdf;ldsa");
|
2017-02-17 23:46:43 +00:00
|
|
|
|
2017-02-17 23:58:52 +00:00
|
|
|
expect(component.isValidPath).toBe(false);
|
2017-02-17 23:46:43 +00:00
|
|
|
});
|
2017-05-22 20:59:12 +00:00
|
|
|
|
|
|
|
it("emits output event indicating Dockerfile path has changed", (done) => {
|
|
|
|
component.pathChanged.subscribe((event: PathChangeEvent) => {
|
|
|
|
expect(event.path).toEqual(newPath);
|
|
|
|
expect(event.isValid).toBe(component.isValidPath);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
component.setSelectedPath(newPath);
|
|
|
|
});
|
2017-02-17 23:46:43 +00:00
|
|
|
});
|
2017-05-22 20:59:12 +00:00
|
|
|
});
|