@@ -20,6 +20,7 @@ describe('leetcode_client', function() {
2020 msg : 'session expired, please login again' ,
2121 statusCode : - 1
2222 } ;
23+ var URL_ALGORITHMS = 'https://leetcode.com/api/problems/algorithms/' ;
2324
2425 before ( function ( ) {
2526 config . init ( ) ;
@@ -46,10 +47,10 @@ describe('leetcode_client', function() {
4647
4748 it ( 'should ok' , function ( done ) {
4849 config . AUTO_LOGIN = true ;
49- nock ( config . URL_PROBLEMS ) . get ( '/' ) . reply ( 403 ) ;
50- nock ( config . URL_PROBLEMS ) . get ( '/' ) . replyWithFile ( 200 , './test/mock/problems.json.20160911' ) ;
50+ nock ( URL_ALGORITHMS ) . get ( '/' ) . reply ( 403 ) ;
51+ nock ( URL_ALGORITHMS ) . get ( '/' ) . replyWithFile ( 200 , './test/mock/problems.json.20160911' ) ;
5152
52- client . getProblems ( USER , function ( e , problems ) {
53+ client . getProblems ( 'algorithms' , USER , function ( e , problems ) {
5354 assert . equal ( e , null ) ;
5455 assert . equal ( problems . length , 377 ) ;
5556 done ( ) ;
@@ -58,19 +59,19 @@ describe('leetcode_client', function() {
5859
5960 it ( 'should fail if no auto login' , function ( done ) {
6061 config . AUTO_LOGIN = false ;
61- nock ( config . URL_PROBLEMS ) . get ( '/' ) . reply ( 403 ) ;
62+ nock ( URL_ALGORITHMS ) . get ( '/' ) . reply ( 403 ) ;
6263
63- client . getProblems ( USER , function ( e , problems ) {
64+ client . getProblems ( 'algorithms' , USER , function ( e , problems ) {
6465 assert . deepEqual ( e , EXPIRED_ERROR ) ;
6566 done ( ) ;
6667 } ) ;
6768 } ) ;
6869
6970 it ( 'should fail if other error' , function ( done ) {
7071 config . AUTO_LOGIN = true ;
71- nock ( config . URL_PROBLEMS ) . get ( '/' ) . reply ( 503 ) ;
72+ nock ( URL_ALGORITHMS ) . get ( '/' ) . reply ( 503 ) ;
7273
73- client . getProblems ( USER , function ( e , problems ) {
74+ client . getProblems ( 'algorithms' , USER , function ( e , problems ) {
7475 var expected = {
7576 msg : 'http error' ,
7677 statusCode : 503
@@ -82,13 +83,13 @@ describe('leetcode_client', function() {
8283
8384 it ( 'should fail if http error in relogin' , function ( done ) {
8485 config . AUTO_LOGIN = true ;
85- nock ( config . URL_PROBLEMS ) . get ( '/' ) . reply ( 403 ) ;
86- nock ( config . URL_PROBLEMS ) . get ( '/' ) . reply ( 403 ) ;
86+ nock ( URL_ALGORITHMS ) . get ( '/' ) . reply ( 403 ) ;
87+ nock ( URL_ALGORITHMS ) . get ( '/' ) . reply ( 403 ) ;
8788 core . login = function ( user , cb ) {
8889 return cb ( 'unknown error!' ) ;
8990 } ;
9091
91- client . getProblems ( USER , function ( e , problems ) {
92+ client . getProblems ( 'algorithms' , USER , function ( e , problems ) {
9293 assert . deepEqual ( e , EXPIRED_ERROR ) ;
9394 done ( ) ;
9495 } ) ;
@@ -97,9 +98,9 @@ describe('leetcode_client', function() {
9798
9899 describe ( '#getProblems' , function ( ) {
99100 it ( 'should ok' , function ( done ) {
100- nock ( config . URL_PROBLEMS ) . get ( '/' ) . replyWithFile ( 200 , './test/mock/problems.json.20160911' ) ;
101+ nock ( URL_ALGORITHMS ) . get ( '/' ) . replyWithFile ( 200 , './test/mock/problems.json.20160911' ) ;
101102
102- client . getProblems ( USER , function ( e , problems ) {
103+ client . getProblems ( 'algorithms' , USER , function ( e , problems ) {
103104 assert . equal ( e , null ) ;
104105 assert . equal ( problems . length , 377 ) ;
105106 done ( ) ;
@@ -108,9 +109,9 @@ describe('leetcode_client', function() {
108109
109110 it ( 'should fail if not login' , function ( done ) {
110111 config . AUTO_LOGIN = false ;
111- nock ( config . URL_PROBLEMS ) . get ( '/' ) . replyWithFile ( 200 , './test/mock/problems.nologin.json.20161015' ) ;
112+ nock ( URL_ALGORITHMS ) . get ( '/' ) . replyWithFile ( 200 , './test/mock/problems.nologin.json.20161015' ) ;
112113
113- client . getProblems ( USER , function ( e , problems ) {
114+ client . getProblems ( 'algorithms' , USER , function ( e , problems ) {
114115 assert . deepEqual ( e , EXPIRED_ERROR ) ;
115116 done ( ) ;
116117 } ) ;
0 commit comments