aboutsummaryrefslogtreecommitdiffstats
path: root/test/widget
diff options
context:
space:
mode:
Diffstat (limited to 'test/widget')
-rw-r--r--test/widget/formSpec.js20
-rw-r--r--test/widget/inputSpec.js84
-rw-r--r--test/widget/selectSpec.js70
3 files changed, 87 insertions, 87 deletions
diff --git a/test/widget/formSpec.js b/test/widget/formSpec.js
index 7c575c33..7d136dd8 100644
--- a/test/widget/formSpec.js
+++ b/test/widget/formSpec.js
@@ -1,35 +1,35 @@
'use strict';
-describe('form', function(){
+describe('form', function() {
var doc;
- afterEach(function(){
+ afterEach(function() {
dealoc(doc);
});
- it('should attach form to DOM', function(){
+ it('should attach form to DOM', function() {
doc = angular.element('<form>');
var scope = angular.compile(doc)();
expect(doc.data('$form')).toBeTruthy();
});
- it('should prevent form submission', function(){
+ it('should prevent form submission', function() {
var startingUrl = '' + window.location;
doc = angular.element('<form name="myForm"><input type=submit val=submit>');
var scope = angular.compile(doc)();
browserTrigger(doc.find('input'));
waitsFor(
- function(){ return true; },
+ function() { return true; },
'let browser breath, so that the form submision can manifest itself', 10);
- runs(function(){
+ runs(function() {
expect('' + window.location).toEqual(startingUrl);
});
});
- it('should publish form to scope', function(){
+ it('should publish form to scope', function() {
doc = angular.element('<form name="myForm">');
var scope = angular.compile(doc)();
expect(scope.myForm).toBeTruthy();
@@ -38,7 +38,7 @@ describe('form', function(){
});
- it('should have ng-valide/ng-invalid style', function(){
+ it('should have ng-valide/ng-invalid style', function() {
doc = angular.element('<form name="myForm"><input type=text ng:model=text required>');
var scope = angular.compile(doc)();
scope.text = 'misko';
@@ -54,7 +54,7 @@ describe('form', function(){
});
- it('should chain nested forms', function(){
+ it('should chain nested forms', function() {
doc = angular.element('<ng:form name=parent><ng:form name=child><input type=text ng:model=text name=text>');
var scope = angular.compile(doc)();
var parent = scope.parent;
@@ -71,7 +71,7 @@ describe('form', function(){
});
- it('should chain nested forms in repeater', function(){
+ it('should chain nested forms in repeater', function() {
doc = angular.element('<ng:form name=parent>' +
'<ng:form ng:repeat="f in forms" name=child><input type=text ng:model=text name=text>');
var scope = angular.compile(doc)();
diff --git a/test/widget/inputSpec.js b/test/widget/inputSpec.js
index 31f8c59c..d8d7f928 100644
--- a/test/widget/inputSpec.js
+++ b/test/widget/inputSpec.js
@@ -1,6 +1,6 @@
'use strict';
-describe('widget: input', function(){
+describe('widget: input', function() {
var compile = null, element = null, scope = null, defer = null;
var doc = null;
@@ -21,13 +21,13 @@ describe('widget: input', function(){
};
});
- afterEach(function(){
+ afterEach(function() {
dealoc(element);
dealoc(doc);
});
- describe('text', function(){
+ describe('text', function() {
var scope = null,
form = null,
formElement = null,
@@ -46,7 +46,7 @@ describe('widget: input', function(){
};
- it('should bind update scope from model', function(){
+ it('should bind update scope from model', function() {
createInput();
expect(scope.form.name.$required).toBe(false);
scope.name = 'misko';
@@ -55,7 +55,7 @@ describe('widget: input', function(){
});
- it('should require', function(){
+ it('should require', function() {
createInput({required:''});
expect(scope.form.name.$required).toBe(true);
scope.$digest();
@@ -66,10 +66,10 @@ describe('widget: input', function(){
});
- it('should call $destroy on element remove', function(){
+ it('should call $destroy on element remove', function() {
createInput();
var log = '';
- form.$on('$destroy', function(){
+ form.$on('$destroy', function() {
log += 'destroy;';
});
inputElement.remove();
@@ -77,10 +77,10 @@ describe('widget: input', function(){
});
- it('should update the model and trim input', function(){
+ it('should update the model and trim input', function() {
createInput();
var log = '';
- scope.change = function(){
+ scope.change = function() {
log += 'change();';
};
inputElement.val(' a ');
@@ -91,14 +91,14 @@ describe('widget: input', function(){
});
- it('should change non-html5 types to text', function(){
+ it('should change non-html5 types to text', function() {
doc = angular.element('<form name="form"><input type="abc" ng:model="name"></form>');
scope = angular.compile(doc)();
expect(doc.find('input').attr('type')).toEqual('text');
});
- it('should not change html5 types to text', function(){
+ it('should not change html5 types to text', function() {
doc = angular.element('<form name="form"><input type="number" ng:model="name"></form>');
scope = angular.compile(doc)();
expect(doc.find('input')[0].getAttribute('type')).toEqual('number');
@@ -106,10 +106,10 @@ describe('widget: input', function(){
});
- describe("input", function(){
+ describe("input", function() {
- describe("text", function(){
- it('should input-text auto init and handle keydown/change events', function(){
+ describe("text", function() {
+ it('should input-text auto init and handle keydown/change events', function() {
compile('<input type="text" ng:model="name"/>');
scope.name = 'Adam';
@@ -130,7 +130,7 @@ describe('widget: input', function(){
});
- it('should not trigger eval if value does not change', function(){
+ it('should not trigger eval if value does not change', function() {
compile('<input type="text" ng:model="name" ng:change="count = count + 1" ng:init="count=0"/>');
scope.name = 'Misko';
scope.$digest();
@@ -143,7 +143,7 @@ describe('widget: input', function(){
});
- it('should allow complex reference binding', function(){
+ it('should allow complex reference binding', function() {
compile('<div>'+
'<input type="text" ng:model="obj[\'abc\'].name"/>'+
'</div>');
@@ -153,8 +153,8 @@ describe('widget: input', function(){
});
- describe("ng:format", function(){
- it("should format text", function(){
+ describe("ng:format", function() {
+ it("should format text", function() {
compile('<input type="list" ng:model="list"/>');
scope.list = ['x', 'y', 'z'];
@@ -168,14 +168,14 @@ describe('widget: input', function(){
});
- it("should render as blank if null", function(){
+ it("should render as blank if null", function() {
compile('<input type="text" ng:model="age" ng:format="number" ng:init="age=null"/>');
expect(scope.age).toBeNull();
expect(scope.$element[0].value).toEqual('');
});
- it("should show incorrect text while number does not parse", function(){
+ it("should show incorrect text while number does not parse", function() {
compile('<input type="number" ng:model="age"/>');
scope.age = 123;
scope.$digest();
@@ -195,7 +195,7 @@ describe('widget: input', function(){
});
- it("should not clobber text if model changes due to itself", function(){
+ it("should not clobber text if model changes due to itself", function() {
// When the user types 'a,b' the 'a,' stage parses to ['a'] but if the
// $parseModel function runs it will change to 'a', in essence preventing
// the user from ever typying ','.
@@ -227,7 +227,7 @@ describe('widget: input', function(){
});
- it("should come up blank when no value specified", function(){
+ it("should come up blank when no value specified", function() {
compile('<input type="number" ng:model="age"/>');
scope.$digest();
expect(scope.$element.val()).toEqual('');
@@ -236,15 +236,15 @@ describe('widget: input', function(){
});
- describe("checkbox", function(){
- it("should format booleans", function(){
+ describe("checkbox", function() {
+ it("should format booleans", function() {
compile('<input type="checkbox" ng:model="name" ng:init="name=false"/>');
expect(scope.name).toBe(false);
expect(scope.$element[0].checked).toBe(false);
});
- it('should support type="checkbox" with non-standard capitalization', function(){
+ it('should support type="checkbox" with non-standard capitalization', function() {
compile('<input type="checkBox" ng:model="checkbox"/>');
browserTrigger(element);
@@ -255,7 +255,7 @@ describe('widget: input', function(){
});
- it('should allow custom enumeration', function(){
+ it('should allow custom enumeration', function() {
compile('<input type="checkbox" ng:model="name" true-value="ano" false-value="nie"/>');
scope.name='ano';
@@ -280,7 +280,7 @@ describe('widget: input', function(){
});
- it("should process required", function(){
+ it("should process required", function() {
compile('<input type="text" ng:model="price" name="p" required/>', jqLite(document.body));
expect(scope.$service('$formFactory').rootForm.p.$required).toBe(true);
expect(element.hasClass('ng-invalid')).toBeTruthy();
@@ -320,7 +320,7 @@ describe('widget: input', function(){
});
- describe('textarea', function(){
+ describe('textarea', function() {
it("should process textarea", function() {
compile('<textarea ng:model="name"></textarea>');
@@ -341,8 +341,8 @@ describe('widget: input', function(){
});
- describe('radio', function(){
- it('should support type="radio"', function(){
+ describe('radio', function() {
+ it('should support type="radio"', function() {
compile('<div>' +
'<input type="radio" name="r" ng:model="chose" value="A"/>' +
'<input type="radio" name="r" ng:model="chose" value="B"/>' +
@@ -366,7 +366,7 @@ describe('widget: input', function(){
});
- it('should honor model over html checked keyword after', function(){
+ it('should honor model over html checked keyword after', function() {
compile('<div ng:init="choose=\'C\'">' +
'<input type="radio" ng:model="choose" value="A""/>' +
'<input type="radio" ng:model="choose" value="B" checked/>' +
@@ -380,7 +380,7 @@ describe('widget: input', function(){
});
- it('should honor model over html checked keyword before', function(){
+ it('should honor model over html checked keyword before', function() {
compile('<div ng:init="choose=\'A\'">' +
'<input type="radio" ng:model="choose" value="A""/>' +
'<input type="radio" ng:model="choose" value="B" checked/>' +
@@ -395,22 +395,22 @@ describe('widget: input', function(){
});
- it('should ignore text widget which have no name', function(){
+ it('should ignore text widget which have no name', function() {
compile('<input type="text"/>');
expect(scope.$element.attr('ng-exception')).toBeFalsy();
expect(scope.$element.hasClass('ng-exception')).toBeFalsy();
});
- it('should ignore checkbox widget which have no name', function(){
+ it('should ignore checkbox widget which have no name', function() {
compile('<input type="checkbox"/>');
expect(scope.$element.attr('ng-exception')).toBeFalsy();
expect(scope.$element.hasClass('ng-exception')).toBeFalsy();
});
- it('should report error on assignment error', function(){
- expect(function(){
+ it('should report error on assignment error', function() {
+ expect(function() {
compile('<input type="text" ng:model="throw \'\'">');
}).toThrow("Syntax Error: Token '''' is an unexpected token at column 7 of the expression [throw ''] starting at [''].");
$logMock.error.logs.shift();
@@ -418,8 +418,8 @@ describe('widget: input', function(){
});
- describe('scope declaration', function(){
- it('should read the declaration from scope', function(){
+ describe('scope declaration', function() {
+ it('should read the declaration from scope', function() {
var input, $formFactory;
element = angular.element('<input type="@MyType" ng:model="abc">');
scope = angular.scope();
@@ -451,18 +451,18 @@ describe('widget: input', function(){
});
- describe('text subtypes', function(){
+ describe('text subtypes', function() {
function itShouldVerify(type, validList, invalidList, params, fn) {
- describe(type, function(){
+ describe(type, function() {
forEach(validList, function(value){
- it('should validate "' + value + '"', function(){
+ it('should validate "' + value + '"', function() {
setup(value);
expect(scope.$element).toBeValid();
});
});
forEach(invalidList, function(value){
- it('should NOT validate "' + value + '"', function(){
+ it('should NOT validate "' + value + '"', function() {
setup(value);
expect(scope.$element).toBeInvalid();
});
diff --git a/test/widget/selectSpec.js b/test/widget/selectSpec.js
index 6adf8b93..ad9dab18 100644
--- a/test/widget/selectSpec.js
+++ b/test/widget/selectSpec.js
@@ -1,6 +1,6 @@
'use strict';
-describe('select', function(){
+describe('select', function() {
var compile = null, element = null, scope = null, $formFactory = null;
beforeEach(function() {
@@ -20,12 +20,12 @@ describe('select', function(){
};
});
- afterEach(function(){
+ afterEach(function() {
dealoc(element);
});
- describe('select-one', function(){
+ describe('select-one', function() {
it('should compile children of a select without a name, but not create a model for it',
function() {
@@ -41,7 +41,7 @@ describe('select', function(){
expect(scope.$element.text()).toBe('foobarC');
});
- it('should require', function(){
+ it('should require', function() {
compile('<select name="select" ng:model="selection" required ng:change="log=log+\'change;\'">' +
'<option value=""></option>' +
'<option value="c">C</option>' +
@@ -67,7 +67,7 @@ describe('select', function(){
expect(scope.log).toEqual('change;');
});
- it('should not be invalid if no require', function(){
+ it('should not be invalid if no require', function() {
compile('<select name="select" ng:model="selection">' +
'<option value=""></option>' +
'<option value="c">C</option>' +
@@ -80,8 +80,8 @@ describe('select', function(){
});
- describe('select-multiple', function(){
- it('should support type="select-multiple"', function(){
+ describe('select-multiple', function() {
+ it('should support type="select-multiple"', function() {
compile('<select ng:model="selection" multiple>' +
'<option>A</option>' +
'<option>B</option>' +
@@ -91,7 +91,7 @@ describe('select', function(){
expect(element[0].childNodes[0].selected).toEqual(true);
});
- it('should require', function(){
+ it('should require', function() {
compile('<select name="select" ng:model="selection" multiple required>' +
'<option>A</option>' +
'<option>B</option>' +
@@ -117,7 +117,7 @@ describe('select', function(){
});
- describe('ng:options', function(){
+ describe('ng:options', function() {
var select, scope;
function createSelect(attrs, blank, unknown){
@@ -152,19 +152,19 @@ describe('select', function(){
}, blank, unknown);
}
- afterEach(function(){
+ afterEach(function() {
dealoc(select);
dealoc(scope);
});
- it('should throw when not formated "? for ? in ?"', function(){
- expect(function(){
+ it('should throw when not formated "? for ? in ?"', function() {
+ expect(function() {
compile('<select ng:model="selected" ng:options="i dont parse"></select>');
}).toThrow("Expected ng:options in form of '_select_ (as _label_)? for (_key_,)?_value_ in" +
" _collection_' but got 'i dont parse'.");
});
- it('should render a list', function(){
+ it('should render a list', function() {
createSingleSelect();
scope.values = [{name:'A'}, {name:'B'}, {name:'C'}];
scope.selected = scope.values[0];
@@ -176,7 +176,7 @@ describe('select', function(){
expect(sortedHtml(options[2])).toEqual('<option value="2">C</option>');
});
- it('should render an object', function(){
+ it('should render an object', function() {
createSelect({
'ng:model':'selected',
'ng:options': 'value as key for (key, value) in object'
@@ -197,7 +197,7 @@ describe('select', function(){
expect(options[3].selected).toEqual(true);
});
- it('should grow list', function(){
+ it('should grow list', function() {
createSingleSelect();
scope.values = [];
scope.$digest();
@@ -217,7 +217,7 @@ describe('select', function(){
expect(sortedHtml(select.find('option')[1])).toEqual('<option value="1">B</option>');
});
- it('should shrink list', function(){
+ it('should shrink list', function() {
createSingleSelect();
scope.values = [{name:'A'}, {name:'B'}, {name:'C'}];
scope.selected = scope.values[0];
@@ -241,7 +241,7 @@ describe('select', function(){
expect(select.find('option').length).toEqual(1); // we add back the special empty option
});
- it('should shrink and then grow list', function(){
+ it('should shrink and then grow list', function() {
createSingleSelect();
scope.values = [{name:'A'}, {name:'B'}, {name:'C'}];
scope.selected = scope.values[0];
@@ -259,7 +259,7 @@ describe('select', function(){
expect(select.find('option').length).toEqual(3);
});
- it('should update list', function(){
+ it('should update list', function() {
createSingleSelect();
scope.values = [{name:'A'}, {name:'B'}, {name:'C'}];
scope.selected = scope.values[0];
@@ -275,7 +275,7 @@ describe('select', function(){
expect(sortedHtml(options[2])).toEqual('<option value="2">D</option>');
});
- it('should preserve existing options', function(){
+ it('should preserve existing options', function() {
createSingleSelect(true);
scope.values = [];
@@ -296,8 +296,8 @@ describe('select', function(){
expect(jqLite(select.find('option')[0]).text()).toEqual('blank');
});
- describe('binding', function(){
- it('should bind to scope value', function(){
+ describe('binding', function() {
+ it('should bind to scope value', function() {
createSingleSelect();
scope.values = [{name:'A'}, {name:'B'}];
scope.selected = scope.values[0];
@@ -309,7 +309,7 @@ describe('select', function(){
expect(select.val()).toEqual('1');
});
- it('should bind to scope value and group', function(){
+ it('should bind to scope value and group', function() {
createSelect({
'ng:model':'selected',
'ng:options':'item.name group by item.group for item in values'
@@ -342,7 +342,7 @@ describe('select', function(){
expect(select.val()).toEqual('0');
});
- it('should bind to scope value through experession', function(){
+ it('should bind to scope value through experession', function() {
createSelect({'ng:model':'selected', 'ng:options':'item.id as item.name for item in values'});
scope.values = [{id:10, name:'A'}, {id:20, name:'B'}];
scope.selected = scope.values[0].id;
@@ -354,7 +354,7 @@ describe('select', function(){
expect(select.val()).toEqual('1');
});
- it('should bind to object key', function(){
+ it('should bind to object key', function() {
createSelect({
'ng:model':'selected',
'ng:options':'key as value for (key, value) in object'
@@ -369,7 +369,7 @@ describe('select', function(){
expect(select.val()).toEqual('blue');
});
- it('should bind to object value', function(){
+ it('should bind to object value', function() {
createSelect({
'ng:model':'selected',
'ng:options':'value as key for (key, value) in object'
@@ -384,7 +384,7 @@ describe('select', function(){
expect(select.val()).toEqual('blue');
});
- it('should insert a blank option if bound to null', function(){
+ it('should insert a blank option if bound to null', function() {
createSingleSelect();
scope.values = [{name:'A'}];
scope.selected = null;
@@ -399,7 +399,7 @@ describe('select', function(){
expect(select.find('option').length).toEqual(1);
});
- it('should reuse blank option if bound to null', function(){
+ it('should reuse blank option if bound to null', function() {
createSingleSelect(true);
scope.values = [{name:'A'}];
scope.selected = null;
@@ -414,7 +414,7 @@ describe('select', function(){
expect(select.find('option').length).toEqual(2);
});
- it('should insert a unknown option if bound to something not in the list', function(){
+ it('should insert a unknown option if bound to something not in the list', function() {
createSingleSelect();
scope.values = [{name:'A'}];
scope.selected = {};
@@ -430,8 +430,8 @@ describe('select', function(){
});
});
- describe('on change', function(){
- it('should update model on change', function(){
+ describe('on change', function() {
+ it('should update model on change', function() {
createSingleSelect();
scope.values = [{name:'A'}, {name:'B'}];
scope.selected = scope.values[0];
@@ -443,7 +443,7 @@ describe('select', function(){
expect(scope.selected).toEqual(scope.values[1]);
});
- it('should update model on change through expression', function(){
+ it('should update model on change through expression', function() {
createSelect({'ng:model':'selected', 'ng:options':'item.id as item.name for item in values'});
scope.values = [{id:10, name:'A'}, {id:20, name:'B'}];
scope.selected = scope.values[0].id;
@@ -455,7 +455,7 @@ describe('select', function(){
expect(scope.selected).toEqual(scope.values[1].id);
});
- it('should update model to null on change', function(){
+ it('should update model to null on change', function() {
createSingleSelect(true);
scope.values = [{name:'A'}, {name:'B'}];
scope.selected = scope.values[0];
@@ -468,8 +468,8 @@ describe('select', function(){
});
});
- describe('select-many', function(){
- it('should read multiple selection', function(){
+ describe('select-many', function() {
+ it('should read multiple selection', function() {
createMultiSelect();
scope.values = [{name:'A'}, {name:'B'}];
@@ -492,7 +492,7 @@ describe('select', function(){
expect(select.find('option')[1].selected).toEqual(true);
});
- it('should update model on change', function(){
+ it('should update model on change', function() {
createMultiSelect();
scope.values = [{name:'A'}, {name:'B'}];