File tree 3 files changed +17
-28
lines changed
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' ;
2
2
import DB from 'models'
3
3
4
4
export 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
+ } )
18
16
}
17
+ }
19
18
}
Original file line number Diff line number Diff line change @@ -23,11 +23,6 @@ const source = `
23
23
const stdin = 'Success' ;
24
24
const expectedOutput = 'Success' ;
25
25
26
-
27
- function delay ( ms : number ) {
28
- return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
29
- }
30
-
31
26
describe ( 'POST api/runs' , ( ) => {
32
27
before ( async ( ) => {
33
28
await DB . apikeys . create ( {
@@ -171,7 +166,7 @@ describe('POST api/runs', () => {
171
166
expect ( res . status ) . to . equal ( 200 ) ;
172
167
173
168
// there is a delay of 1000 for onSuccess, so setting 2000ms delay here.
174
- await delay ( 2000 ) ;
169
+ await utils . delay ( 2000 ) ;
175
170
const resultResponse = await chai . request ( app ) . get ( `/api/result/${ res . body . id } ` ) . set ( {
176
171
Authorization : 'Bearer 7718330d2794406c980bdbded6c9dc1d' ,
177
172
Accept : 'application/json'
@@ -209,7 +204,7 @@ describe('POST api/runs', () => {
209
204
app2 . use ( '/' , router ) ;
210
205
} ) ;
211
206
212
- await delay ( 2000 ) ;
207
+ await utils . delay ( 2000 ) ;
213
208
214
209
expect ( res . body . id ) . to . exist ;
215
210
expect ( res . status ) . to . equal ( 200 ) ;
Original file line number Diff line number Diff line change @@ -35,11 +35,6 @@ const testcases = [
35
35
] ;
36
36
const expectedResult = 'Success' ;
37
37
38
-
39
- function delay ( ms : number ) {
40
- return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
41
- }
42
-
43
38
describe ( 'POST api/submissions' , ( ) => {
44
39
before ( async ( ) => {
45
40
await DB . apikeys . create ( {
@@ -171,7 +166,7 @@ describe('POST api/submissions', () => {
171
166
172
167
173
168
// there is a delay of 1000 for onSuccess, so setting 2000ms delay here.
174
- await delay ( 2000 ) ;
169
+ await utils . delay ( 2000 ) ;
175
170
const resultResponse = await chai . request ( app ) . get ( `/api/result/${ res . body . id } ` ) . set ( {
176
171
Authorization : 'Bearer 7718330d2794406c980bdbded6c9dc1d' ,
177
172
Accept : 'application/json'
@@ -210,7 +205,7 @@ describe('POST api/submissions', () => {
210
205
app2 . use ( '/' , router ) ;
211
206
} ) ;
212
207
213
- await delay ( 2000 ) ;
208
+ await utils . delay ( 2000 ) ;
214
209
215
210
expect ( res . body . id ) . to . exist ;
216
211
expect ( res . status ) . to . equal ( 200 ) ;
You can’t perform that action at this time.
0 commit comments