aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/BinderTest.js4
-rw-r--r--test/servicesSpec.js36
-rw-r--r--test/widgetsSpec.js10
3 files changed, 36 insertions, 14 deletions
diff --git a/test/BinderTest.js b/test/BinderTest.js
index 67800e62..9c5c5dc6 100644
--- a/test/BinderTest.js
+++ b/test/BinderTest.js
@@ -721,13 +721,13 @@ BinderTest.prototype.testItShouldSelectTheCorrectRadioBox = function() {
var male = jqLite(c.node[0].childNodes[1]);
female.click();
- assertEquals("female", c.scope.$get("sex"));
+ assertEquals("female", c.scope.sex);
assertEquals(true, female[0].checked);
assertEquals(false, male[0].checked);
assertEquals("female", female.val());
male.click();
- assertEquals("male", c.scope.$get("sex"));
+ assertEquals("male", c.scope.sex);
assertEquals(false, female[0].checked);
assertEquals(true, male[0].checked);
assertEquals("male", male.val());
diff --git a/test/servicesSpec.js b/test/servicesSpec.js
index 5a6bcedc..b92975d0 100644
--- a/test/servicesSpec.js
+++ b/test/servicesSpec.js
@@ -13,15 +13,37 @@ describe("services", function(){
expect(scope.$window).toEqual(window);
});
- it("should inject $anchor", function(){
- scope.$anchor('#path?key=value');
- expect(scope.$anchor.path).toEqual("path");
- expect(scope.$anchor.param).toEqual({key:'value'});
+ it("should inject $location", function(){
+ scope.$location('http://host:123/p/a/t/h.html?query=value#path?key=value');
+ expect(scope.$location.href).toEqual("http://host:123/p/a/t/h.html?query=value#path?key=value");
+ expect(scope.$location.protocol).toEqual("http");
+ expect(scope.$location.host).toEqual("host");
+ expect(scope.$location.port).toEqual("123");
+ expect(scope.$location.path).toEqual("/p/a/t/h.html");
+ expect(scope.$location.search).toEqual({query:'value'});
+ expect(scope.$location.hash).toEqual('path?key=value');
+ expect(scope.$location.hashPath).toEqual('path');
+ expect(scope.$location.hashSearch).toEqual({key:'value'});
- scope.$anchor.path = 'page=http://path';
- scope.$anchor.param = {k:'a=b'};
+ scope.$location.hashPath = 'page=http://path';
+ scope.$location.hashSearch = {k:'a=b'};
- expect(scope.$anchor()).toEqual('page=http://path?k=a%3Db');
+ expect(scope.$location()).toEqual('http://host:123/p/a/t/h.html?query=value#path?key=valuepage=http://path?k=a%3Db');
+ });
+
+ it('should parse file://', function(){
+ scope.$location('file:///Users/Shared/misko/work/angular.js/scenario/widgets.html');
+ expect(scope.$location.href).toEqual("file:///Users/Shared/misko/work/angular.js/scenario/widgets.html");
+ expect(scope.$location.protocol).toEqual("file");
+ expect(scope.$location.host).toEqual("");
+ expect(scope.$location.port).toEqual(null);
+ expect(scope.$location.path).toEqual("/Users/Shared/misko/work/angular.js/scenario/widgets.html");
+ expect(scope.$location.search).toEqual({});
+ expect(scope.$location.hash).toEqual('');
+ expect(scope.$location.hashPath).toEqual('');
+ expect(scope.$location.hashSearch).toEqual({});
+ expect(scope.$location()).toEqual('file:///Users/Shared/misko/work/angular.js/scenario/widgets.html');
});
+
});
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js
index 6123e229..6c47e5dd 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -114,23 +114,23 @@ describe("input widget", function(){
it('should type="checkbox"', function(){
compile('<input type="checkbox" name="checkbox" checked ng-change="action = true"/>');
- expect(scope.$get('checkbox')).toEqual(true);
+ expect(scope.checkbox).toEqual(true);
element.click();
- expect(scope.$get('checkbox')).toEqual(false);
- expect(scope.$get('action')).toEqual(true);
+ expect(scope.checkbox).toEqual(false);
+ expect(scope.action).toEqual(true);
element.click();
- expect(scope.$get('checkbox')).toEqual(true);
+ expect(scope.checkbox).toEqual(true);
});
it('should type="radio"', function(){
compile('<div>' +
'<input type="radio" name="chose" value="A" ng-change="clicked = 1"/>' +
'<input type="radio" name="chose" value="B" checked ng-change="clicked = 2"/>' +
+ '<input type="radio" name="chose" value="C" ng-change="clicked = 3"/>' +
'</div>');
var a = element[0].childNodes[0];
var b = element[0].childNodes[1];
expect(scope.chose).toEqual('B');
- expect(scope.clicked).not.toBeDefined();
scope.chose = 'A';
scope.$eval();
expect(a.checked).toEqual(true);