File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -290,4 +290,38 @@ describe('leetcode_client', function() {
290290 } ) ;
291291 } ) ;
292292 } ) ; // #getSubmission
293+
294+ describe ( '#login' , function ( ) {
295+ it ( 'should ok' , function ( done ) {
296+ nock ( 'https://leetcode.com' )
297+ . get ( '/accounts/login/' )
298+ . reply ( 200 , '' , {
299+ 'Set-Cookie' : [
300+ 'csrftoken=LOGIN_CSRF_TOKEN; Max-Age=31449600; Path=/; secure'
301+ ]
302+ } ) ;
303+
304+ nock ( 'https://leetcode.com' )
305+ . post ( '/accounts/login/' )
306+ . reply ( 302 , '' , {
307+ 'Set-Cookie' : [
308+ 'csrftoken=SESSION_CSRF_TOKEN; Max-Age=31449600; Path=/; secure' ,
309+ 'PHPSESSID=SESSION_ID; Max-Age=31449600; Path=/; secure' ,
310+ "messages='Successfully signed in as Eric.'; Max-Age=31449600; Path=/; secure"
311+ ]
312+ } ) ;
313+
314+ var user = { } ;
315+ client . login ( user , function ( e , user ) {
316+ assert . equal ( e , null ) ;
317+
318+ assert . equal ( user . loginCSRF , 'LOGIN_CSRF_TOKEN' ) ;
319+ assert . equal ( user . sessionCSRF , 'SESSION_CSRF_TOKEN' ) ;
320+ assert . equal ( user . sessionId , 'SESSION_ID' ) ;
321+ assert . equal ( user . name , 'Eric' ) ;
322+
323+ done ( ) ;
324+ } ) ;
325+ } ) ;
326+ } ) ; // #login
293327} ) ;
You can’t perform that action at this time.
0 commit comments