@@ -149,4 +149,68 @@ describe('leetcode_client', function() {
149149 } ) ;
150150 } ) ;
151151 } ) ; // #getProblem
152+
153+ describe ( '#testProblem' , function ( ) {
154+ it ( 'should ok' , function ( done ) {
155+ var problem = {
156+ id : 389 ,
157+ name : 'Find the Difference' ,
158+ key : 'find-the-difference' ,
159+ link : 'https://leetcode.com/problems/find-the-difference' ,
160+ locked : false ,
161+ file : '/dev/null'
162+ } ;
163+
164+ nock ( 'https://leetcode.com' )
165+ . post ( '/problems/find-the-difference/interpret_solution/' )
166+ . reply ( 200 , '{"interpret_expected_id": "id1", "interpret_id": "id2"}' ) ;
167+
168+ nock ( 'https://leetcode.com' )
169+ . get ( '/submissions/detail/id1/check/' )
170+ . reply ( 200 , '{"state": "SUCCESS"}' ) ;
171+
172+ nock ( 'https://leetcode.com' )
173+ . get ( '/submissions/detail/id2/check/' )
174+ . reply ( 200 , '{"state": "SUCCESS"}' ) ;
175+
176+ client . testProblem ( problem , function ( e , results ) {
177+ assert . equal ( e , null ) ;
178+ assert . deepEqual ( results ,
179+ [
180+ { name : 'Your' , state : 'SUCCESS' } ,
181+ { name : 'Expected' , state : 'SUCCESS' }
182+ ] ) ;
183+
184+ done ( ) ;
185+ } ) ;
186+ } ) ;
187+ } ) ; // #testProblem
188+
189+ describe ( '#submitProblem' , function ( ) {
190+ it ( 'should ok' , function ( done ) {
191+ var problem = {
192+ id : 389 ,
193+ name : 'Find the Difference' ,
194+ key : 'find-the-difference' ,
195+ link : 'https://leetcode.com/problems/find-the-difference' ,
196+ locked : false ,
197+ file : '/dev/null'
198+ } ;
199+
200+ nock ( 'https://leetcode.com' )
201+ . post ( '/problems/find-the-difference/submit/' )
202+ . reply ( 200 , '{"submission_id": "id1"}' ) ;
203+
204+ nock ( 'https://leetcode.com' )
205+ . get ( '/submissions/detail/id1/check/' )
206+ . reply ( 200 , '{"state": "SUCCESS"}' ) ;
207+
208+ client . submitProblem ( problem , function ( e , results ) {
209+ assert . equal ( e , null ) ;
210+ assert . deepEqual ( results , [ { name : 'Your' , state : 'SUCCESS' } ] ) ;
211+
212+ done ( ) ;
213+ } ) ;
214+ } ) ;
215+ } ) ; // #submitProblem
152216} ) ;
0 commit comments