@@ -15,6 +15,7 @@ import {
1515} from 'angular2/testing_internal' ;
1616import { ControlGroup , Control , ControlArray , Validators } from 'angular2/core' ;
1717import { ObservableWrapper } from 'angular2/src/core/facade/async' ;
18+ import { IS_DART } from '../../platform' ;
1819
1920export function main ( ) {
2021 describe ( "Form Model" , ( ) => {
@@ -116,7 +117,7 @@ export function main() {
116117 describe ( "valueChanges" , ( ) => {
117118 var c ;
118119
119- beforeEach ( ( ) => { c = new Control ( "old" ) ; } ) ;
120+ beforeEach ( ( ) => { c = new Control ( "old" , Validators . required ) ; } ) ;
120121
121122 it ( "should fire an event after the value has been updated" ,
122123 inject ( [ AsyncTestCompleter ] , ( async ) => {
@@ -128,6 +129,19 @@ export function main() {
128129 c . updateValue ( "new" ) ;
129130 } ) ) ;
130131
132+ // TODO: remove the if statement after making observable delivery sync
133+ if ( ! IS_DART ) {
134+ it ( "should update set errors and status before emitting an event" ,
135+ inject ( [ AsyncTestCompleter ] , ( async ) => {
136+ c . valueChanges . toRx ( ) . subscribe ( value => {
137+ expect ( c . valid ) . toEqual ( false ) ;
138+ expect ( c . errors ) . toEqual ( { "required" : true } ) ;
139+ async . done ( ) ;
140+ } ) ;
141+ c . updateValue ( "" ) ;
142+ } ) ) ;
143+ }
144+
131145 it ( "should return a cold observable" , inject ( [ AsyncTestCompleter ] , ( async ) => {
132146 c . updateValue ( "will be ignored" ) ;
133147 ObservableWrapper . subscribe ( c . valueChanges , ( value ) => {
0 commit comments