From 0df93fd49c1687b2eddaa79faa1c0adbef82bf72 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Wed, 7 Apr 2010 10:17:15 -0700
Subject: clean up, fixes for app
---
test/directivesSpec.js | 7 +++++--
test/widgetsSpec.js | 33 ++++++++++++++++++++++++++++-----
2 files changed, 33 insertions(+), 7 deletions(-)
(limited to 'test')
diff --git a/test/directivesSpec.js b/test/directivesSpec.js
index 0a7e3c18..74aa942b 100644
--- a/test/directivesSpec.js
+++ b/test/directivesSpec.js
@@ -162,13 +162,16 @@ describe("directives", function(){
this.greeting = 'hello';
};
window.Greeter.prototype = {
+ init: function(){
+ this.suffix = '!';
+ },
greet: function(name) {
- return this.greeting + ' ' + name;
+ return this.greeting + ' ' + name + this.suffix;
}
};
var scope = compile('
');
expect(scope.greeting).toEqual('hello');
- expect(scope.greet('misko')).toEqual('hello misko');
+ expect(scope.greet('misko')).toEqual('hello misko!');
delete window.Greeter;
});
});
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js
index 1669aa68..312a7f2b 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -189,14 +189,36 @@ describe("input widget", function(){
});
it('should switch on value change', function(){
- compile('first
second
');
+ compile('first:{{name}}
second:{{name}}
');
expect(element.html()).toEqual('');
scope.select = 1;
scope.$eval();
- expect(element.text()).toEqual('first');
+ expect(element.text()).toEqual('first:');
+ scope.name="shyam";
+ scope.$eval();
+ expect(element.text()).toEqual('first:shyam');
scope.select = 2;
scope.$eval();
- expect(element.text()).toEqual('second');
+ scope.name = 'misko';
+ scope.$eval();
+ expect(element.text()).toEqual('second:misko');
+ });
+});
+
+describe('ng:switch', function(){
+ it("should match urls", function(){
+ var scope = compile('{{name}}
');
+ scope.url = '/Book/Moby';
+ scope.$init();
+ expect(scope.$element.text()).toEqual('Moby');
+ });
+
+ it('should call init on switch', function(){
+ var scope = compile('{{name}}
');
+ scope.url = 'a';
+ scope.$init();
+ expect(scope.name).toEqual(undefined);
+ expect(scope.$element.text()).toEqual('works');
});
});
@@ -204,10 +226,11 @@ describe('ng:include', function(){
it('should include on external file', function() {
var element = jqLite('');
var scope = compile(element);
- scope.$browser.xhr.expect('GET', 'myUrl').respond('hello');
+ scope.$browser.xhr.expect('GET', 'myUrl').respond('{{1+2}}');
scope.$init();
expect(sortedHtml(element)).toEqual('');
scope.$browser.xhr.flush();
- expect(sortedHtml(element)).toEqual('hello');
+ expect(element.text()).toEqual('3');
});
});
+
--
cgit v1.2.3