File tree Expand file tree Collapse file tree 3 files changed +17
-28
lines changed Expand file tree Collapse file tree 3 files changed +17
-28
lines changed Original file line number Diff line number Diff line change 1- import { Request , Response } from " express" ;
1+ import { Request , Response } from ' express' ;
22import DB from 'models'
33
44export default {
5- async sendResult ( req : Request , res : Response ) {
6- const submissionId = req . params . id ? parseInt ( req . params . id ) : null
7- if ( ! submissionId ) {
8- res . status ( 400 ) . json ( { err : 'SubmissionId not found' } )
9- }
10- else {
11- DB . submissions . findByPk ( submissionId )
12- . then ( ( submission ) => {
13- res . status ( 200 ) . json ( submission . results )
14- } ) . catch ( ( err ) => {
15- res . status ( 404 ) . json ( { err : 'Submission not found' } )
16- } )
17- }
5+ async sendResult ( req : Request , res : Response ) {
6+ const submissionId = req . params . id ? parseInt ( req . params . id ) : null
7+ if ( ! submissionId ) {
8+ res . status ( 400 ) . json ( { err : 'SubmissionId not found' } )
9+ } else {
10+ DB . submissions . findByPk ( submissionId )
11+ . then ( ( submission ) => {
12+ res . status ( 200 ) . json ( submission . results )
13+ } ) . catch ( ( err ) => {
14+ res . status ( 404 ) . json ( { err : 'Submission not found' } )
15+ } )
1816 }
17+ }
1918}
Original file line number Diff line number Diff line change @@ -23,11 +23,6 @@ const source = `
2323const stdin = 'Success' ;
2424const expectedOutput = 'Success' ;
2525
26-
27- function delay ( ms : number ) {
28- return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
29- }
30-
3126describe ( 'POST api/runs' , ( ) => {
3227 before ( async ( ) => {
3328 await DB . apikeys . create ( {
@@ -171,7 +166,7 @@ describe('POST api/runs', () => {
171166 expect ( res . status ) . to . equal ( 200 ) ;
172167
173168 // there is a delay of 1000 for onSuccess, so setting 2000ms delay here.
174- await delay ( 2000 ) ;
169+ await utils . delay ( 2000 ) ;
175170 const resultResponse = await chai . request ( app ) . get ( `/api/result/${ res . body . id } ` ) . set ( {
176171 Authorization : 'Bearer 7718330d2794406c980bdbded6c9dc1d' ,
177172 Accept : 'application/json'
@@ -209,7 +204,7 @@ describe('POST api/runs', () => {
209204 app2 . use ( '/' , router ) ;
210205 } ) ;
211206
212- await delay ( 2000 ) ;
207+ await utils . delay ( 2000 ) ;
213208
214209 expect ( res . body . id ) . to . exist ;
215210 expect ( res . status ) . to . equal ( 200 ) ;
Original file line number Diff line number Diff line change @@ -35,11 +35,6 @@ const testcases = [
3535] ;
3636const expectedResult = 'Success' ;
3737
38-
39- function delay ( ms : number ) {
40- return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
41- }
42-
4338describe ( 'POST api/submissions' , ( ) => {
4439 before ( async ( ) => {
4540 await DB . apikeys . create ( {
@@ -171,7 +166,7 @@ describe('POST api/submissions', () => {
171166
172167
173168 // there is a delay of 1000 for onSuccess, so setting 2000ms delay here.
174- await delay ( 2000 ) ;
169+ await utils . delay ( 2000 ) ;
175170 const resultResponse = await chai . request ( app ) . get ( `/api/result/${ res . body . id } ` ) . set ( {
176171 Authorization : 'Bearer 7718330d2794406c980bdbded6c9dc1d' ,
177172 Accept : 'application/json'
@@ -210,7 +205,7 @@ describe('POST api/submissions', () => {
210205 app2 . use ( '/' , router ) ;
211206 } ) ;
212207
213- await delay ( 2000 ) ;
208+ await utils . delay ( 2000 ) ;
214209
215210 expect ( res . body . id ) . to . exist ;
216211 expect ( res . status ) . to . equal ( 200 ) ;
You can’t perform that action at this time.
0 commit comments