87 lines
2.2 KiB
TypeScript
87 lines
2.2 KiB
TypeScript
|
import { ContextPathSelectComponent } from './context-path-select.component';
|
||
|
|
||
|
|
||
|
describe("ContextPathSelectComponent", () => {
|
||
|
var component: ContextPathSelectComponent;
|
||
|
var currentContext: string;
|
||
|
var isValidContext: boolean;
|
||
|
var contexts: string[];
|
||
|
|
||
|
beforeEach(() => {
|
||
|
component = new ContextPathSelectComponent();
|
||
|
currentContext = '/';
|
||
|
isValidContext = false;
|
||
|
contexts = ['/'];
|
||
|
component.currentContext = currentContext;
|
||
|
component.isValidContext = isValidContext;
|
||
|
component.contexts = contexts;
|
||
|
});
|
||
|
|
||
|
describe("$onChanges", () => {
|
||
|
|
||
|
it("sets valid context flag to true if current context is valid", () => {
|
||
|
component.$onChanges({});
|
||
|
|
||
|
expect(component.isValidContext).toBe(true);
|
||
|
});
|
||
|
|
||
|
it("sets valid context flag to false if current context is invalid", () => {
|
||
|
component.currentContext = "asdfdsf";
|
||
|
component.$onChanges({});
|
||
|
|
||
|
expect(component.isValidContext).toBe(false);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe("setcontext", () => {
|
||
|
var newContext: string;
|
||
|
|
||
|
beforeEach(() => {
|
||
|
newContext = '/conf';
|
||
|
});
|
||
|
|
||
|
it("sets current context to given context", () => {
|
||
|
component.setContext(newContext);
|
||
|
|
||
|
expect(component.currentContext).toEqual(newContext);
|
||
|
});
|
||
|
|
||
|
it("sets valid context flag to true if given context is valid", () => {
|
||
|
component.setContext(newContext);
|
||
|
|
||
|
expect(component.isValidContext).toBe(true);
|
||
|
});
|
||
|
|
||
|
it("sets valid context flag to false if given context is invalid", () => {
|
||
|
component.setContext("asdfsadfs");
|
||
|
|
||
|
expect(component.isValidContext).toBe(false);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe("setCurrentcontext", () => {
|
||
|
var context: string;
|
||
|
|
||
|
beforeEach(() => {
|
||
|
context = '/conf';
|
||
|
});
|
||
|
|
||
|
it("sets current context to given context", () => {
|
||
|
component.setSelectedContext(context);
|
||
|
|
||
|
expect(component.currentContext).toEqual(context);
|
||
|
});
|
||
|
|
||
|
it("sets valid context flag to true if given context is valid", () => {
|
||
|
component.setSelectedContext(context);
|
||
|
|
||
|
expect(component.isValidContext).toBe(true);
|
||
|
});
|
||
|
|
||
|
it("sets valid context flag to false if given context is invalid", () => {
|
||
|
component.setSelectedContext("a;lskjdf;ldsa");
|
||
|
|
||
|
expect(component.isValidContext).toBe(false);
|
||
|
});
|
||
|
});
|
||
|
});
|