Skip to content

Commit 5c65914

Browse files
committed
fix all TODOs
1 parent cc6c3a2 commit 5c65914

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

test/e2e/RunScenario.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ describe('POST api/runs', () => {
8585
Accept: 'application/json'
8686
}).send(params);
8787

88-
expect(res.status).to.equal(200);
89-
// TODO ? does not throw error.
88+
expect(res.status).to.equal(400);
9089
});
9190

9291
it('should throw 400 error when source is missing', async () => {

test/e2e/SubmitScenario.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ describe('POST api/submissions', () => {
9898
Accept: 'application/json'
9999
}).send(params);
100100

101-
// TODO WRONG, didn't throw error
102-
expect(res.body.result).to.equal(expectedResult);
103-
expect(res.status).to.equal(200);
101+
expect(res.status).to.equal(400);
104102
});
105103

106104
it('should throw error for source missing', async () => {

test/unit/validators/ApiKeyValidator.spec.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,25 @@ describe('API Key Validtors', async () => {
8282

8383
it('should NOT reject api with a whitelist domain', async () => {
8484
const currentKey = 'SDLKJFLSJDKCWEKRJC';
85+
const domainExample = 'www.google.com';
8586

8687
await DB.apikeys.create({
8788
key: currentKey,
88-
whitelist_domains: ['Referer']
89+
whitelist_domains: [domainExample]
8990
});
9091

9192
const req: Request = {
9293
header(name): any {
9394
if (name === 'Authorization') {
94-
return `Bearer ${currentKey}`
95+
return `Bearer ${currentKey}`;
96+
}
97+
if (name === 'Referer') {
98+
return domainExample;
9599
}
96100
}
97101
};
98102

99-
// TODO code is wrong
100-
// expect(checkValidApiKey(req)).to.not.be.rejected;
103+
expect(checkValidApiKey(req)).to.not.be.rejected;
101104
});
102105

103106
it('should NOT reject api with whitelist ip/domain as "*"', async () => {

test/unit/validators/RunValidator.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ describe('RunValidator', async () => {
5252
};
5353

5454
await runValidator.POST(req, res, nextSpy);
55-
// TODO WRONG
56-
// expect(sentStatus).to.equal(400);
57-
// expect(sentData.err.message).to.equal('"lang" is required');
58-
// expect(nextSpy.calledOnce).to.be.false;
55+
expect(sentStatus).to.equal(400);
56+
expect(nextSpy.calledOnce).to.be.false;
5957
});
6058

6159
it('should throw an error when source is missing', async () => {

test/unit/validators/SubmitValidator.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@ describe('SubmitValidator', async () => {
6464
};
6565

6666
await submitValidator.POST(req, res, nextSpy);
67-
// TODO WRONG
68-
// expect(sentStatus).to.equal(400);
69-
// expect(sentData.err.message).to.equal('"lang" is required');
70-
// expect(nextSpy.calledOnce).to.be.false;
67+
68+
expect(sentStatus).to.equal(400);
69+
expect(nextSpy.calledOnce).to.be.false;
7170
});
7271

7372
it('should throw an error when source is missing', async () => {

0 commit comments

Comments
 (0)