File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Workshop/03. Unit-testing/public/test Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,13 @@ describe('Tests', function() {
2424 requester . getJSON . restore ( ) ;
2525 } ) ;
2626
27+ it ( 'expect dataService.cookies() to make exactly one getJSON call' , function ( done ) {
28+ dataService . cookies ( )
29+ . then ( ( ) => {
30+ expect ( requester . getJSON . calledOnce ) . to . be . true ;
31+ } )
32+ . then ( done , done ) ;
33+ } )
2734 it ( 'expect dataService.cookies() to make correct getJSON call' , function ( done ) {
2835 dataService . cookies ( )
2936 . then ( obj => {
@@ -55,6 +62,13 @@ describe('Tests', function() {
5562 requester . postJSON . restore ( ) ;
5663 } ) ;
5764
65+ it ( 'expect postJSON to be called once' , function ( done ) {
66+ dataService . register ( user )
67+ . then ( ( ) => {
68+ expect ( requester . postJSON . calledOnce ) . to . be . true ;
69+ } )
70+ . then ( done , done ) ;
71+ } ) ;
5872 it ( 'expect dataService.register() to make correct postJSON call' , function ( done ) {
5973 dataService . register ( user )
6074 . then ( ( ) => {
@@ -129,6 +143,13 @@ describe('Tests', function() {
129143 localStorage . clear ( ) ;
130144 } ) ;
131145
146+ it ( 'expect putJSON to be called once' , function ( done ) {
147+ dataService . login ( user )
148+ . then ( ( ) => {
149+ expect ( requester . putJSON . calledOnce ) . to . be . true ;
150+ } )
151+ . then ( done , done ) ;
152+ } ) ;
132153 it ( 'expect dataService.login() to make correct putJSON call' , function ( done ) {
133154 dataService . login ( user )
134155 . then ( ( ) => {
You can’t perform that action at this time.
0 commit comments