@@ -171,15 +171,19 @@ describe('plugin:leetcode', function() {
171171 } ) ; // #getCategoryProblems
172172
173173 describe ( '#getProblem' , function ( ) {
174+ beforeEach ( function ( ) {
175+ PROBLEM . locked = false ;
176+ } ) ;
177+
174178 it ( 'should ok' , function ( done ) {
175179 nock ( 'https://leetcode.com' )
176- . get ( '/problems/find-the-difference ' )
177- . replyWithFile ( 200 , './test/mock/find-the-difference.html.20170714 ' ) ;
180+ . post ( '/graphql ' )
181+ . replyWithFile ( 200 , './test/mock/find-the-difference.json.20171216 ' ) ;
178182
179183 plugin . getProblem ( PROBLEM , function ( e , problem ) {
180184 assert . equal ( e , null ) ;
181- assert . equal ( problem . totalAC , '73.2K ' ) ;
182- assert . equal ( problem . totalSubmit , '142K ' ) ;
185+ assert . equal ( problem . totalAC , '89.7K ' ) ;
186+ assert . equal ( problem . totalSubmit , '175.7K ' ) ;
183187 assert . equal ( problem . desc ,
184188 [
185189 '' ,
@@ -203,7 +207,7 @@ describe('plugin:leetcode', function() {
203207 ''
204208 ] . join ( '\r\n' ) ) ;
205209
206- assert . equal ( problem . templates . length , 11 ) ;
210+ assert . equal ( problem . templates . length , 12 ) ;
207211
208212 assert . equal ( problem . templates [ 0 ] . value , 'cpp' ) ;
209213 assert . equal ( problem . templates [ 0 ] . text , 'C++' ) ;
@@ -221,7 +225,7 @@ describe('plugin:leetcode', function() {
221225 assert . equal ( problem . templates [ 1 ] . text , 'Java' ) ;
222226 assert . equal ( problem . templates [ 1 ] . defaultCode ,
223227 [
224- 'public class Solution {' ,
228+ 'class Solution {' ,
225229 ' public char findTheDifference(String s, String t) {' ,
226230 ' ' ,
227231 ' }' ,
@@ -333,15 +337,23 @@ describe('plugin:leetcode', function() {
333337 '}'
334338 ] . join ( '\n' ) ) ;
335339
340+ assert . equal ( problem . templates [ 11 ] . value , 'kotlin' ) ;
341+ assert . equal ( problem . templates [ 11 ] . text , 'Kotlin' ) ;
342+ assert . equal ( problem . templates [ 11 ] . defaultCode ,
343+ [
344+ 'class Solution {' ,
345+ ' fun findTheDifference(s: String, t: String): Char {' ,
346+ ' ' ,
347+ ' }' ,
348+ '}'
349+ ] . join ( '\n' ) ) ;
350+
336351 done ( ) ;
337352 } ) ;
338353 } ) ;
339354
340355 it ( 'should fail if no permission for locked' , function ( done ) {
341356 PROBLEM . locked = true ;
342- nock ( 'https://leetcode.com' )
343- . get ( '/problems/find-the-difference' )
344- . replyWithFile ( 200 , './test/mock/locked.html.20161015' ) ;
345357
346358 plugin . getProblem ( PROBLEM , function ( e , problem ) {
347359 assert . equal ( e , 'failed to load locked problem!' ) ;
@@ -350,9 +362,7 @@ describe('plugin:leetcode', function() {
350362 } ) ;
351363
352364 it ( 'should fail if session expired' , function ( done ) {
353- nock ( 'https://leetcode.com' )
354- . get ( '/problems/find-the-difference' )
355- . reply ( 403 ) ;
365+ nock ( 'https://leetcode.com' ) . post ( '/graphql' ) . reply ( 403 ) ;
356366
357367 plugin . getProblem ( PROBLEM , function ( e , problem ) {
358368 assert . equal ( e , session . errors . EXPIRED ) ;
@@ -361,9 +371,7 @@ describe('plugin:leetcode', function() {
361371 } ) ;
362372
363373 it ( 'should fail if http error' , function ( done ) {
364- nock ( 'https://leetcode.com' )
365- . get ( '/problems/find-the-difference' )
366- . reply ( 500 ) ;
374+ nock ( 'https://leetcode.com' ) . post ( '/graphql' ) . reply ( 500 ) ;
367375
368376 plugin . getProblem ( PROBLEM , function ( e , problem ) {
369377 assert . deepEqual ( e , { msg : 'http error' , statusCode : 500 } ) ;
@@ -372,9 +380,7 @@ describe('plugin:leetcode', function() {
372380 } ) ;
373381
374382 it ( 'should fail if unknown error' , function ( done ) {
375- nock ( 'https://leetcode.com' )
376- . get ( '/problems/find-the-difference' )
377- . replyWithError ( 'unknown error!' ) ;
383+ nock ( 'https://leetcode.com' ) . post ( '/graphql' ) . replyWithError ( 'unknown error!' ) ;
378384
379385 plugin . getProblem ( PROBLEM , function ( e , problem ) {
380386 assert . equal ( e . message , 'unknown error!' ) ;
0 commit comments