Skip to content

Commit

Permalink
test(ng_model_spec): el.selectionStart and el.selectionEnd are handle…
Browse files Browse the repository at this point in the history
…d differently on IE
  • Loading branch information
vicb committed Aug 30, 2014
1 parent 9c0b1a7 commit cb40e76
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions test/directive/ng_model_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ void main() {
expect(element.selectionEnd).toEqual(2);

scope.apply('model = "xyz"');

// Value updated. selectionStart/End changed.
// Value updated. selectionStart/End changed. IE reports 0 for both, other browsers report 3
expect(element.value).toEqual('xyz');
expect(element.selectionStart).toEqual(3);
expect(element.selectionEnd).toEqual(3);
expect(element.selectionStart).not.toEqual(1);
expect(element.selectionEnd).not.toEqual(2);
});

it('should only render the input value upon the next digest', (Scope scope) {
Expand Down Expand Up @@ -365,11 +364,10 @@ void main() {
expect(element.selectionEnd).toEqual(2);

scope.apply('model = "xyz"');

// Value updated. selectionStart/End changed. IE reports 0 for both, other browsers report 3
expect(element.value).toEqual('xyz');
expect(element.selectionStart).toEqual(3);
expect(element.selectionEnd).toEqual(3);
});
expect(element.selectionStart).not.toEqual(1);
expect(element.selectionEnd).not.toEqual(2); });

it('should only render the input value upon the next digest', (Scope scope) {
_.compile('<input type="password" ng-model="model" probe="p">');
Expand Down Expand Up @@ -440,10 +438,10 @@ void main() {
expect(element.selectionEnd).toEqual(2);

scope.apply('model = "xyz"');

// Value updated. selectionStart/End changed. IE reports 0 for both, other browsers report 3
expect(element.value).toEqual('xyz');
expect(element.selectionStart).toEqual(3);
expect(element.selectionEnd).toEqual(3);
expect(element.selectionStart).not.toEqual(1);
expect(element.selectionEnd).not.toEqual(2);
});

it('should only render the input value upon the next digest', (Scope scope) {
Expand Down Expand Up @@ -526,10 +524,10 @@ void main() {
expect(element.selectionEnd).toEqual(2);

scope.apply('model = "xyz"');

// Value updated. selectionStart/End changed. IE reports 0 for both, other browsers report 3
expect(element.value).toEqual('xyz');
expect(element.selectionStart).toEqual(3);
expect(element.selectionEnd).toEqual(3);
expect(element.selectionStart).not.toEqual(1);
expect(element.selectionEnd).not.toEqual(2);
});

it('should only render the input value upon the next digest', (Scope scope) {
Expand Down Expand Up @@ -721,11 +719,11 @@ void main() {

scope.apply('model = "xyz"');

// Setting the value on a textarea doesn't update the selection the way it
// does on input elements. This stays unchanged.
scope.apply('model = "xyz"');
// Value updated. selectionStart/End changed. IE reports 0 for both, other browsers report 3
expect(element.value).toEqual('xyz');
expect(element.selectionStart).toEqual(0);
expect(element.selectionEnd).toEqual(0);
expect(element.selectionStart).not.toEqual(1);
expect(element.selectionEnd).not.toEqual(2);
});

it('should only render the input value upon the next digest', (Scope scope) {
Expand Down

0 comments on commit cb40e76

Please sign in to comment.