Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
test(macModal): Add tests demonstrating premature calls to Modal call…
Browse files Browse the repository at this point in the history
…backs.
  • Loading branch information
kastork authored and adrianlee44 committed Mar 20, 2014
1 parent b078e9d commit 2a5c1f2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/unit/modal.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ describe "Mac modal", ->
modalElement = $compile("<mac-modal id='test-modal' mac-modal-open='opened()'></mac-modal>") $rootScope
$rootScope.$digest()

expect(opened).toBe false
modal.show "test-modal"
$timeout.flush()

Expand All @@ -140,6 +141,8 @@ describe "Mac modal", ->
modalElement = $compile("<mac-modal id='test-modal' mac-modal-before-show='beforeShow()'></mac-modal>") $rootScope
$rootScope.$digest()

expect($rootScope.beforeShow).not.toHaveBeenCalled()

modal.show "test-modal"
$timeout.flush()

Expand All @@ -150,6 +153,8 @@ describe "Mac modal", ->
modalElement = $compile("<mac-modal id='test-modal' mac-modal-after-show='afterShow()'></mac-modal>") $rootScope
$rootScope.$digest()

expect($rootScope.afterShow).not.toHaveBeenCalled()

modal.show "test-modal"
$timeout.flush()

Expand All @@ -160,7 +165,12 @@ describe "Mac modal", ->
modalElement = $compile("<mac-modal id='test-modal' mac-modal-before-hide='beforeHide()'></mac-modal>") $rootScope
$rootScope.$digest()

expect($rootScope.beforeHide).not.toHaveBeenCalled()

modal.show "test-modal"

expect($rootScope.beforeHide).not.toHaveBeenCalled()

$timeout.flush()
modal.hide()

Expand All @@ -171,8 +181,13 @@ describe "Mac modal", ->
modalElement = $compile("<mac-modal id='test-modal' mac-modal-after-hide='afterHide()'></mac-modal>") $rootScope
$rootScope.$digest()

expect($rootScope.afterHide).not.toHaveBeenCalled()

modal.show "test-modal"
$timeout.flush()

expect($rootScope.afterHide).not.toHaveBeenCalled()

modal.hide()

expect($rootScope.afterHide).toHaveBeenCalled()
Expand Down

0 comments on commit 2a5c1f2

Please sign in to comment.