@@ -3310,76 +3310,37 @@ describe('input', function() {
3310
3310
expect ( scope . form . alias . $error . step ) . toBeFalsy ( ) ;
3311
3311
} ) ;
3312
3312
3313
- it ( 'should adjust the element and model value if the step value changes on-the-fly' , function ( ) {
3314
- scope . step = 10 ;
3315
- var inputElm = helper . compileInput ( '<input type="range" ng-model="value" name="alias" step="{{step}}" />' ) ;
3316
-
3317
- helper . changeInputValueTo ( '5' ) ;
3318
- expect ( inputElm ) . toBeValid ( ) ;
3319
- expect ( scope . value ) . toBe ( 10 ) ;
3320
-
3321
- // Step changes, but value matches
3322
- scope . $apply ( 'step = 5' ) ;
3323
- expect ( inputElm ) . toBeValid ( ) ;
3324
- expect ( scope . value ) . toBe ( 10 ) ;
3325
- expect ( inputElm . val ( ) ) . toBe ( '10' ) ;
3326
-
3327
- // Step changes, value does not match
3328
- scope . $apply ( 'step = 6' ) ;
3329
- expect ( inputElm ) . toBeValid ( ) ;
3330
- expect ( scope . value ) . toBe ( 12 ) ;
3331
- expect ( inputElm . val ( ) ) . toBe ( '12' ) ;
3332
-
3333
- // null is ignored
3334
- scope . $apply ( 'step = null' ) ;
3335
- expect ( inputElm ) . toBeValid ( ) ;
3336
- expect ( scope . value ) . toBe ( 12 ) ;
3337
- expect ( inputElm . val ( ) ) . toBe ( '12' ) ;
3338
-
3339
- // Step val as string
3340
- scope . $apply ( 'step = "7"' ) ;
3341
- expect ( inputElm ) . toBeValid ( ) ;
3342
- expect ( scope . value ) . toBe ( 14 ) ;
3343
- expect ( inputElm . val ( ) ) . toBe ( '14' ) ;
3344
-
3345
- // unparsable string is ignored
3346
- scope . step = 'abc' ;
3347
- scope . $digest ( ) ;
3348
- expect ( inputElm ) . toBeValid ( ) ;
3349
- expect ( scope . value ) . toBe ( 14 ) ;
3350
- expect ( inputElm . val ( ) ) . toBe ( '14' ) ;
3351
- } ) ;
3352
-
3353
3313
} else {
3354
3314
it ( 'should validate if "range" is not implemented' , function ( ) {
3355
- var inputElm = helper . compileInput ( '<input type="range" ng-model="value" name="alias" step="10" />' ) ;
3315
+ scope . step = 10 ;
3316
+ scope . value = 20 ;
3317
+ var inputElm = helper . compileInput ( '<input type="range" ng-model="value" name="alias" step="{{step}}" />' ) ;
3356
3318
3357
- scope . $apply ( 'value = 20' ) ;
3358
- expect ( inputElm . val ( ) ) . to ( '20' ) ;
3319
+ expect ( inputElm . val ( ) ) . toBe ( '20' ) ;
3359
3320
expect ( inputElm ) . toBeValid ( ) ;
3360
3321
expect ( scope . value ) . toBe ( 20 ) ;
3361
3322
expect ( scope . form . alias . $error . step ) . toBeFalsy ( ) ;
3362
3323
3363
3324
helper . changeInputValueTo ( '18' ) ;
3364
3325
expect ( inputElm ) . toBeInvalid ( ) ;
3365
- expect ( inputElm . val ( ) ) . to ( '18' ) ;
3326
+ expect ( inputElm . val ( ) ) . toBe ( '18' ) ;
3366
3327
expect ( scope . value ) . toBeUndefined ( ) ;
3367
3328
expect ( scope . form . alias . $error . step ) . toBeTruthy ( ) ;
3368
3329
3369
3330
helper . changeInputValueTo ( '10' ) ;
3370
3331
expect ( inputElm ) . toBeValid ( ) ;
3371
- expect ( inputElm . val ( ) ) . to ( '10' ) ;
3332
+ expect ( inputElm . val ( ) ) . toBe ( '10' ) ;
3372
3333
expect ( scope . value ) . toBe ( 10 ) ;
3373
3334
expect ( scope . form . alias . $error . step ) . toBeFalsy ( ) ;
3374
3335
3375
3336
scope . $apply ( 'value = 12' ) ;
3376
3337
expect ( inputElm ) . toBeInvalid ( ) ;
3377
- expect ( inputElm . val ( ) ) . to ( '12' ) ;
3338
+ expect ( inputElm . val ( ) ) . toBe ( '12' ) ;
3378
3339
expect ( scope . value ) . toBe ( 12 ) ;
3379
3340
expect ( scope . form . alias . $error . step ) . toBeTruthy ( ) ;
3380
3341
} ) ;
3381
3342
3382
- it ( 'should validate even if the max value changes on-the-fly' , function ( ) {
3343
+ it ( 'should validate even if the step value changes on-the-fly' , function ( ) {
3383
3344
scope . step = 10 ;
3384
3345
var inputElm = helper . compileInput ( '<input type="range" ng-model="value" name="alias" step="{{step}}" />' ) ;
3385
3346
@@ -3391,13 +3352,13 @@ describe('input', function() {
3391
3352
scope . $apply ( 'step = 5' ) ;
3392
3353
expect ( inputElm . val ( ) ) . toBe ( '10' ) ;
3393
3354
expect ( inputElm ) . toBeValid ( ) ;
3394
- expect ( scope . value ) . toBeUndefined ( ) ;
3355
+ expect ( scope . value ) . toBe ( 10 ) ;
3395
3356
expect ( scope . form . alias . $error . step ) . toBeFalsy ( ) ;
3396
3357
3397
3358
// Step changes, value does not match
3398
3359
scope . $apply ( 'step = 6' ) ;
3399
3360
expect ( inputElm ) . toBeInvalid ( ) ;
3400
- expect ( scope . value ) . toBe ( 10 ) ;
3361
+ expect ( scope . value ) . toBeUndefined ( ) ;
3401
3362
expect ( inputElm . val ( ) ) . toBe ( '10' ) ;
3402
3363
expect ( scope . form . alias . $error . step ) . toBeTruthy ( ) ;
3403
3364
@@ -3428,9 +3389,10 @@ describe('input', function() {
3428
3389
describe ( 'ngStep' , function ( ) {
3429
3390
3430
3391
it ( 'should validate' , function ( ) {
3431
- var inputElm = helper . compileInput ( '<input type="range" ng-model="value" name="alias" ng-step="5" />' ) ;
3392
+ scope . step = 5 ;
3393
+ scope . value = 5 ;
3394
+ var inputElm = helper . compileInput ( '<input type="range" ng-model="value" name="alias" ng-step="step" />' ) ;
3432
3395
3433
- scope . $apply ( 'value = 5' ) ;
3434
3396
expect ( inputElm ) . toBeValid ( ) ;
3435
3397
expect ( inputElm . val ( ) ) . toBe ( '5' ) ;
3436
3398
expect ( scope . value ) . toBe ( 5 ) ;
0 commit comments