From 21c725f1a12d1de758cab6e4c4fafc5c420eb565 Mon Sep 17 00:00:00 2001
From: Vojta Jina
Date: Wed, 15 Feb 2012 17:16:02 -0800
Subject: refactor(forms): Even better forms
- remove $formFactory completely
- remove parallel scope hierarchy (forms, widgets)
- use new compiler features (widgets, forms are controllers)
- any directive can add formatter/parser (validators, convertors)
Breaks no custom input types
Breaks removed integer input type
Breaks remove list input type (ng-list directive instead)
Breaks inputs bind only blur event by default (added ng:bind-change directive)
---
test/widget/selectSpec.js | 806 ++++++++++++++++++++++++++++------------------
1 file changed, 499 insertions(+), 307 deletions(-)
(limited to 'test/widget/selectSpec.js')
diff --git a/test/widget/selectSpec.js b/test/widget/selectSpec.js
index 00bc2192..9db47c05 100644
--- a/test/widget/selectSpec.js
+++ b/test/widget/selectSpec.js
@@ -1,60 +1,69 @@
'use strict';
describe('select', function() {
- var compile = null, element = null, scope = null;
+ var scope, formElement, element, $compile;
- beforeEach(inject(function($compile, $rootScope) {
+ function compile(html) {
+ formElement = jqLite('
');
+ element = formElement.find('select');
+ $compile(formElement)(scope);
+ scope.$apply();
+ }
+
+ beforeEach(inject(function($injector, $rootScope) {
scope = $rootScope;
- element = null;
- compile = function(html, parent) {
- if (parent) {
- parent.html(html);
- element = parent.children();
- } else {
- element = jqLite(html);
- }
- element = $compile(element)($rootScope);
- scope.$apply();
- return scope;
- };
+ $compile = $injector.get('$compile');
+ formElement = element = null;
}));
afterEach(function() {
- dealoc(element);
+ dealoc(formElement);
});
describe('select-one', function() {
- it('should compile children of a select without a name, but not create a model for it',
+ it('should compile children of a select without a ng:model, but not create a model for it',
function() {
compile('');
- scope.a = 'foo';
- scope.b = 'bar';
- scope.$digest();
+ scope.$apply(function() {
+ scope.a = 'foo';
+ scope.b = 'bar';
+ });
expect(element.text()).toBe('foobarC');
});
- it('should require', inject(function($formFactory) {
- compile('