From 75f11f1fc46c35a28c0905f7316ea6779145e2fb Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Tue, 16 Aug 2011 23:08:13 -0700
Subject: feat(ng:repeat) collection items and DOM elements affinity /
stability
---
test/widgetsSpec.js | 285 ++++++++++++++++++++++++++++++++++------------------
1 file changed, 189 insertions(+), 96 deletions(-)
(limited to 'test/widgetsSpec.js')
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js
index 6fccaa48..02d0ef71 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -1,6 +1,6 @@
'use strict';
-describe("widget", function(){
+describe("widget", function() {
var compile, element, scope;
beforeEach(function() {
@@ -19,14 +19,15 @@ describe("widget", function(){
};
});
- afterEach(function(){
+ afterEach(function() {
dealoc(element);
});
- describe("input", function(){
- describe("text", function(){
- it('should input-text auto init and handle keydown/change events', function(){
+ describe("input", function() {
+
+ describe("text", function() {
+ it('should input-text auto init and handle keydown/change events', function() {
compile('');
expect(scope.name).toEqual("Misko");
expect(scope.count).toEqual(0);
@@ -49,7 +50,7 @@ describe("widget", function(){
expect(scope.count).toEqual(2);
});
- it('should not trigger eval if value does not change', function(){
+ it('should not trigger eval if value does not change', function() {
compile('');
expect(scope.name).toEqual("Misko");
expect(scope.count).toEqual(0);
@@ -58,16 +59,16 @@ describe("widget", function(){
expect(scope.count).toEqual(0);
});
- it('should allow complex refernce binding', function(){
+ it('should allow complex refernce binding', function() {
compile('
'+
''+
'
');
expect(scope.obj['abc'].name).toEqual('Misko');
});
- describe("ng:format", function(){
- it("should format text", function(){
+ describe("ng:format", function() {
+ it("should format text", function() {
compile('');
expect(scope.list).toEqual(['a', 'b', 'c']);
@@ -80,13 +81,13 @@ describe("widget", function(){
expect(scope.list).toEqual(['1', '2', '3']);
});
- it("should come up blank if null", function(){
+ it("should come up blank if null", function() {
compile('');
expect(scope.age).toBeNull();
expect(scope.$element[0].value).toEqual('');
});
- it("should show incorect text while number does not parse", function(){
+ it("should show incorect text while number does not parse", function() {
compile('');
scope.age = 123;
scope.$digest();
@@ -97,14 +98,14 @@ describe("widget", function(){
expect(scope.$element).toBeInvalid();
});
- it("should clober incorect text if model changes", function(){
+ it("should clober incorect text if model changes", function() {
compile('');
scope.age = 456;
scope.$digest();
expect(scope.$element.val()).toEqual('456');
});
- it("should not clober text if model changes due to itself", function(){
+ it("should not clober text if model changes due to itself", function() {
compile('');
scope.$element.val('a ');
@@ -128,23 +129,23 @@ describe("widget", function(){
expect(scope.list).toEqual(['a', 'b']);
});
- it("should come up blank when no value specifiend", function(){
+ it("should come up blank when no value specifiend", function() {
compile('');
scope.$digest();
expect(scope.$element.val()).toEqual('');
expect(scope.age).toEqual(null);
});
-
});
- describe("checkbox", function(){
- it("should format booleans", function(){
+
+ describe("checkbox", function() {
+ it("should format booleans", function() {
compile('');
expect(scope.name).toEqual(false);
expect(scope.$element[0].checked).toEqual(false);
});
- it('should support type="checkbox"', function(){
+ it('should support type="checkbox"', function() {
compile('');
expect(scope.checkbox).toEqual(true);
browserTrigger(element);
@@ -154,9 +155,9 @@ describe("widget", function(){
expect(scope.checkbox).toEqual(true);
});
- it("should use ng:format", function(){
+ it("should use ng:format", function() {
angularFormatter('testFormat', {
- parse: function(value){
+ parse: function(value) {
return value ? "Worked" : "Failed";
},
@@ -181,8 +182,9 @@ describe("widget", function(){
});
});
- describe("ng:validate", function(){
- it("should process ng:validate", function(){
+
+ describe("ng:validate", function() {
+ it("should process ng:validate", function() {
compile('',
jqLite(document.body));
expect(element.hasClass('ng-validation-error')).toBeTruthy();
@@ -210,9 +212,9 @@ describe("widget", function(){
expect(element.attr('ng-validation-error')).toBeFalsy();
});
- it("should not call validator if undefined/empty", function(){
+ it("should not call validator if undefined/empty", function() {
var lastValue = "NOT_CALLED";
- angularValidator.myValidator = function(value){lastValue = value;};
+ angularValidator.myValidator = function(value) {lastValue = value;};
compile('');
expect(lastValue).toEqual("NOT_CALLED");
@@ -225,19 +227,20 @@ describe("widget", function(){
});
});
- it("should ignore disabled widgets", function(){
+
+ it("should ignore disabled widgets", function() {
compile('');
expect(element.hasClass('ng-validation-error')).toBeFalsy();
expect(element.attr('ng-validation-error')).toBeFalsy();
});
- it("should ignore readonly widgets", function(){
+ it("should ignore readonly widgets", function() {
compile('');
expect(element.hasClass('ng-validation-error')).toBeFalsy();
expect(element.attr('ng-validation-error')).toBeFalsy();
});
- it("should process ng:required", function(){
+ it("should process ng:required", function() {
compile('', jqLite(document.body));
expect(element.hasClass('ng-validation-error')).toBeTruthy();
expect(element.attr('ng-validation-error')).toEqual('Required');
@@ -296,9 +299,8 @@ describe("widget", function(){
});
- describe('radio', function(){
-
- it('should support type="radio"', function(){
+ describe('radio', function() {
+ it('should support type="radio"', function() {
compile('' +
'
' +
'
' +
@@ -323,7 +325,7 @@ describe("widget", function(){
expect(scope.clicked).toEqual(1);
});
- it('should honor model over html checked keyword after', function(){
+ it('should honor model over html checked keyword after', function() {
compile('
' +
'
' +
'
' +
@@ -333,7 +335,7 @@ describe("widget", function(){
expect(scope.choose).toEqual('C');
});
- it('should honor model over html checked keyword before', function(){
+ it('should honor model over html checked keyword before', function() {
compile('
' +
'
' +
'
' +
@@ -345,8 +347,9 @@ describe("widget", function(){
});
- describe('select-one', function(){
- it('should initialize to selected', function(){
+
+ describe('select-one', function() {
+ it('should initialize to selected', function() {
compile(
'