Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: third_party/pkg/angular/test/directive/ng_model_validators_spec.dart

Issue 176943008: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/test/directive/ng_model_validators_spec.dart
diff --git a/third_party/pkg/angular/test/directive/ng_model_validators_spec.dart b/third_party/pkg/angular/test/directive/ng_model_validators_spec.dart
index a382831db7d7f5b8daa599c196bdc4778962d59e..d42e5fb5c21310f7451cf49ae8635121a2c582df 100644
--- a/third_party/pkg/angular/test/directive/ng_model_validators_spec.dart
+++ b/third_party/pkg/angular/test/directive/ng_model_validators_spec.dart
@@ -9,41 +9,61 @@ describe('ngModel validators', () {
beforeEach(inject((TestBed tb) => _ = tb));
describe('required', () {
- it('should validate the input field if the required attribute is set', inject((Scope scope) {
- _.compile('<input type="text" ng-model="val" probe="i" required="true" />');
- Probe probe = _.rootScope.i;
+ it('should validate the input field if the required attribute is set', inject((RootScope scope) {
+ _.compile('<input type="text" ng-model="val" probe="i" required />');
+ Probe probe = _.rootScope.context['i'];
var model = probe.directive(NgModel);
model.validate();
expect(model.valid).toEqual(false);
expect(model.invalid).toEqual(true);
- _.rootScope.val = 'value';
+ _.rootScope.context['val'] = 'value';
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
}));
- it('should validate the input field depending on if ng-required is true', inject((Scope scope) {
+
+ it('should validate a number input field if the required attribute is set', inject((RootScope scope) {
+ _.compile('<input type="number" ng-model="val" probe="i" required="true" />');
+ Probe probe = _.rootScope.context['i'];
+ var model = probe.directive(NgModel);
+
+ model.validate();
+ expect(model.valid).toEqual(false);
+ expect(model.invalid).toEqual(true);
+
+ _.rootScope.context['val'] = 5;
+ model.validate();
+
+ expect(model.valid).toEqual(true);
+ expect(model.invalid).toEqual(false);
+ }));
+
+
+ it('should validate the input field depending on if ng-required is true', inject((RootScope scope) {
_.compile('<input type="text" ng-model="val" probe="i" ng-required="requireMe" />');
- Probe probe = _.rootScope.i;
+ Probe probe = _.rootScope.context['i'];
var model = probe.directive(NgModel);
+ _.rootScope.apply();
+
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['requireMe'] = true;
+ _.rootScope.apply(() {
+ _.rootScope.context['requireMe'] = true;
});
model.validate();
expect(model.valid).toEqual(false);
expect(model.invalid).toEqual(true);
- _.rootScope.$apply(() {
- _.rootScope['requireMe'] = false;
+ _.rootScope.apply(() {
+ _.rootScope.context['requireMe'] = false;
});
model.validate();
@@ -53,25 +73,25 @@ describe('ngModel validators', () {
});
describe('[type="url"]', () {
- it('should validate the input field given a valid or invalid URL', inject((Scope scope) {
+ it('should validate the input field given a valid or invalid URL', inject((RootScope scope) {
_.compile('<input type="url" ng-model="val" probe="i" />');
- Probe probe = _.rootScope.i;
+ Probe probe = _.rootScope.context['i'];
var model = probe.directive(NgModel);
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = 'googledotcom';
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = 'googledotcom';
});
model.validate();
expect(model.valid).toEqual(false);
expect(model.invalid).toEqual(true);
- _.rootScope.$apply(() {
- _.rootScope['val'] = 'http://www.google.com';
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = 'http://www.google.com';
});
model.validate();
@@ -81,25 +101,25 @@ describe('ngModel validators', () {
});
describe('[type="email"]', () {
- it('should validate the input field given a valid or invalid email address', inject((Scope scope) {
+ it('should validate the input field given a valid or invalid email address', inject((RootScope scope) {
_.compile('<input type="email" ng-model="val" probe="i" />');
- Probe probe = _.rootScope.i;
+ Probe probe = _.rootScope.context['i'];
var model = probe.directive(NgModel);
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = 'matiasatemail.com';
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = 'matiasatemail.com';
});
model.validate();
expect(model.valid).toEqual(false);
expect(model.invalid).toEqual(true);
- _.rootScope.$apply(() {
- _.rootScope['val'] = 'matias@gmail.com';
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = 'matias@gmail.com';
});
model.validate();
@@ -109,17 +129,17 @@ describe('ngModel validators', () {
});
describe('[type="number"]', () {
- it('should validate the input field given a valid or invalid number', inject((Scope scope) {
+ it('should validate the input field given a valid or invalid number', inject((RootScope scope) {
_.compile('<input type="number" ng-model="val" probe="i" />');
- Probe probe = _.rootScope.i;
+ Probe probe = _.rootScope.context['i'];
var model = probe.directive(NgModel);
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = '11';
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = '11';
});
model.validate();
@@ -127,16 +147,16 @@ describe('ngModel validators', () {
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = 10;
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = 10;
});
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = 'twelve';
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = 'twelve';
});
model.validate();
@@ -146,36 +166,36 @@ describe('ngModel validators', () {
});
describe('pattern', () {
- it('should validate the input field if a ng-pattern attribute is provided', inject((Scope scope) {
+ it('should validate the input field if a ng-pattern attribute is provided', inject((RootScope scope) {
_.compile('<input type="text" ng-pattern="myPattern" ng-model="val" probe="i" />');
- Probe probe = _.rootScope.i;
+ Probe probe = _.rootScope.context['i'];
var model = probe.directive(NgModel);
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "abc";
- _.rootScope['myPattern'] = "[a-z]+";
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "abc";
+ _.rootScope.context['myPattern'] = "[a-z]+";
});
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "abc";
- _.rootScope['myPattern'] = "[0-9]+";
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "abc";
+ _.rootScope.context['myPattern'] = "[0-9]+";
});
model.validate();
expect(model.valid).toEqual(false);
expect(model.invalid).toEqual(true);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "123";
- _.rootScope['myPattern'] = "123";
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "123";
+ _.rootScope.context['myPattern'] = "123";
});
model.validate();
@@ -183,33 +203,33 @@ describe('ngModel validators', () {
expect(model.invalid).toEqual(false);
}));
- it('should validate the input field if a pattern attribute is provided', inject((Scope scope) {
+ it('should validate the input field if a pattern attribute is provided', inject((RootScope scope) {
_.compile('<input type="text" pattern="[0-5]+" ng-model="val" probe="i" />');
- Probe probe = _.rootScope.i;
+ Probe probe = _.rootScope.context['i'];
var model = probe.directive(NgModel);
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "abc";
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "abc";
});
model.validate();
expect(model.valid).toEqual(false);
expect(model.invalid).toEqual(true);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "012345";
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "012345";
});
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "6789";
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "6789";
});
model.validate();
@@ -219,25 +239,25 @@ describe('ngModel validators', () {
});
describe('minlength', () {
- it('should validate the input field if a minlength attribute is provided', inject((Scope scope) {
+ it('should validate the input field if a minlength attribute is provided', inject((RootScope scope) {
_.compile('<input type="text" minlength="5" ng-model="val" probe="i" />');
- Probe probe = _.rootScope.i;
+ Probe probe = _.rootScope.context['i'];
var model = probe.directive(NgModel);
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "abc";
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "abc";
});
model.validate();
expect(model.valid).toEqual(false);
expect(model.invalid).toEqual(true);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "abcdef";
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "abcdef";
});
model.validate();
@@ -245,27 +265,27 @@ describe('ngModel validators', () {
expect(model.invalid).toEqual(false);
}));
- it('should validate the input field if a ng-minlength attribute is provided', inject((Scope scope) {
+ it('should validate the input field if a ng-minlength attribute is provided', inject((RootScope scope) {
_.compile('<input type="text" ng-minlength="len" ng-model="val" probe="i" />');
- Probe probe = _.rootScope.i;
+ Probe probe = _.rootScope.context['i'];
var model = probe.directive(NgModel);
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "abcdef";
- _.rootScope['len'] = 3;
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "abcdef";
+ _.rootScope.context['len'] = 3;
});
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "abc";
- _.rootScope['len'] = 5;
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "abc";
+ _.rootScope.context['len'] = 5;
});
model.validate();
@@ -275,25 +295,25 @@ describe('ngModel validators', () {
});
describe('maxlength', () {
- it('should validate the input field if a maxlength attribute is provided', inject((Scope scope) {
+ it('should validate the input field if a maxlength attribute is provided', inject((RootScope scope) {
_.compile('<input type="text" maxlength="5" ng-model="val" probe="i" />');
- Probe probe = _.rootScope.i;
+ Probe probe = _.rootScope.context['i'];
var model = probe.directive(NgModel);
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "abcdef";
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "abcdef";
});
model.validate();
expect(model.valid).toEqual(false);
expect(model.invalid).toEqual(true);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "abc";
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "abc";
});
model.validate();
@@ -301,27 +321,27 @@ describe('ngModel validators', () {
expect(model.invalid).toEqual(false);
}));
- it('should validate the input field if a ng-maxlength attribute is provided', inject((Scope scope) {
+ it('should validate the input field if a ng-maxlength attribute is provided', inject((RootScope scope) {
_.compile('<input type="text" ng-maxlength="len" ng-model="val" probe="i" />');
- Probe probe = _.rootScope.i;
+ Probe probe = _.rootScope.context['i'];
var model = probe.directive(NgModel);
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "abcdef";
- _.rootScope['len'] = 6;
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "abcdef";
+ _.rootScope.context['len'] = 6;
});
model.validate();
expect(model.valid).toEqual(true);
expect(model.invalid).toEqual(false);
- _.rootScope.$apply(() {
- _.rootScope['val'] = "abc";
- _.rootScope['len'] = 1;
+ _.rootScope.apply(() {
+ _.rootScope.context['val'] = "abc";
+ _.rootScope.context['len'] = 1;
});
model.validate();

Powered by Google App Engine
This is Rietveld 408576698