chore(test): clean tests of if directive

Closes #1017
This commit is contained in:
Marc Laval 2015-03-19 14:21:45 +01:00
parent 0f20c39f42
commit ab5ed6f2ec

View File

@ -145,40 +145,7 @@ export function main() {
})); }));
if (!IS_DARTIUM) { if (!IS_DARTIUM) {;
it('should leave the element if the condition is a non-empty string (JS)', inject([AsyncTestCompleter], (async) => {
compileWithTemplate('<div><copy-me template="if stringCondition">hello</copy-me></div>').then((pv) => {
createView(pv);
cd.detectChanges();
expect(DOM.querySelectorAll(view.nodes[0], 'copy-me').length).toEqual(1);
expect(DOM.getText(view.nodes[0])).toEqual('hello');
async.done();
});
}));
it('should leave the element if the condition is an object (JS)', inject([AsyncTestCompleter], (async) => {
compileWithTemplate('<div><copy-me template="if objectCondition">hello</copy-me></div>').then((pv) => {
createView(pv);
cd.detectChanges();
expect(DOM.querySelectorAll(view.nodes[0], 'copy-me').length).toEqual(1);
expect(DOM.getText(view.nodes[0])).toEqual('hello');
async.done();
});
}));
it('should remove the element if the condition is null (JS)', inject([AsyncTestCompleter], (async) => {
compileWithTemplate('<div><copy-me template="if nullCondition">hello</copy-me></div>').then((pv) => {
createView(pv);
cd.detectChanges();
expect(DOM.querySelectorAll(view.nodes[0], 'copy-me').length).toEqual(0);
expect(DOM.getText(view.nodes[0])).toEqual('');
async.done();
});
}));
it('should not add the element twice if the condition goes from true to true (JS)', inject([AsyncTestCompleter], (async) => { it('should not add the element twice if the condition goes from true to true (JS)', inject([AsyncTestCompleter], (async) => {
compileWithTemplate('<div><copy-me template="if numberCondition">hello</copy-me></div>').then((pv) => { compileWithTemplate('<div><copy-me template="if numberCondition">hello</copy-me></div>').then((pv) => {
createView(pv); createView(pv);
@ -231,8 +198,6 @@ class TestComponent {
numberCondition: number; numberCondition: number;
stringCondition: string; stringCondition: string;
functionCondition: Function; functionCondition: Function;
objectCondition: any;
nullCondition: any;
constructor() { constructor() {
this.booleanCondition = true; this.booleanCondition = true;
this.numberCondition = 1; this.numberCondition = 1;
@ -240,7 +205,5 @@ class TestComponent {
this.functionCondition = function(s, n){ this.functionCondition = function(s, n){
return s == "foo" && n == 1; return s == "foo" && n == 1;
}; };
this.objectCondition = {};
this.nullCondition = null;
} }
} }