Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Commit

Permalink
test(bcAsyncInput): add tests for cancel and save
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Jan 22, 2016
1 parent 575ff78 commit 47edeb9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/directives/bc-async-input_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,26 @@ describe 'bcAsyncInput Directive', ->
it 'should return true if the view is equal to the model', ->
isoScope.bcAsyncForm.input.$setViewValue('oldValue')
expect(isoScope.bcAsyncForm.$valid).toBe(false)

describe 'cancel', ->

beforeEach ->
isoScope.bcAsyncForm.input.$setViewValue('newValue')
isoScope.cancel()

it 'should not save if cancelled', ->
expect(isoScope.form.newValue).toBe('oldValue')

it 'should be pristine', ->
expect(isoScope.bcAsyncForm.$pristine).toBe(true)

describe 'save', ->

beforeEach ->
isoScope.onSave = (newValue, success, error) ->
success()

it 'should validate when save() is called', ->
spyOn(isoScope, 'validate').and.callThrough()
isoScope.save()
expect(isoScope.validate).toHaveBeenCalled()

0 comments on commit 47edeb9

Please sign in to comment.