File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,4 +61,33 @@ describe( 'Auth', () => {
6161 done ( )
6262 } )
6363 } )
64+
65+ it ( 'should create an account with valid credentials' , ( done ) => {
66+ stub ( ( data , handler ) => {
67+ const { username, password } = JSON . parse ( data )
68+ const response = new EventEmitter ( )
69+ equal ( username , 'username' )
70+ equal ( password , 'password' )
71+
72+ handler ( response )
73+ response . emit ( 'data' , '{\"access_token\": \"secret-token\"}' )
74+ response . emit ( 'end' ) ;
75+ } )
76+
77+ auth . create ( 'username' , 'password' )
78+ . then ( ( user ) => {
79+ equal ( user . access_token , 'secret-token' )
80+ done ( )
81+ } )
82+ } )
83+
84+ it ( 'should fail to create an account with invalid credentials' , ( done ) => {
85+ stubResponse ( 'this is not json' )
86+
87+ auth . create ( 'username' , 'bad-password' )
88+ . catch ( ( e ) => {
89+ equal ( e . message , 'this is not json' )
90+ done ( )
91+ } )
92+ } )
6493} )
You can’t perform that action at this time.
0 commit comments