Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e0e904d

Browse files
read token from .env
1 parent c2c2409 commit e0e904d

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

‎test/posts.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,24 @@ describe('Posts', () => {
3333
};
3434

3535
const res = await request
36-
.post('posts')
36+
.post('postss')
3737
.set('Authorization', `Bearer ${TOKEN}`)
3838
.send(data);
3939

40-
expect(res.body.data).to.deep.include('data');
40+
expect(res.body.data).to.deep.include(data);
4141
postId = res.body.data.id;
4242
});
4343

4444
// dependent on previous test
4545
it('posts/:id', async () => {
46-
await request
47-
.get(`posts/${postId}`)
48-
.set('Authorization', `Bearer ${TOKEN}`)
49-
.expect(200);
46+
if (postId) {
47+
await request
48+
.get(`posts/${postId}`)
49+
.set('Authorization', `Bearer ${TOKEN}`)
50+
.expect(200);
51+
} else {
52+
throw new Error`postId is invalid ${postId}`();
53+
}
5054
});
5155
});
5256

‎test/users-advanced.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ const request = supertest('https://gorest.co.in/public-api/');
33

44
import { expect } from 'chai';
55

6-
const TOKEN =
7-
'f23c96ab955134d34fb15a05c891320a81c0a6a309c9f481604e380d19bef872';
6+
const TOKEN = process.env.TOKEN;
87

98
describe('Users', () => {
109
let userId;

‎test/users.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ const request = supertest('https://gorest.co.in/public-api/');
33

44
import { expect } from 'chai';
55

6-
const TOKEN =
7-
'f23c96ab955134d34fb15a05c891320a81c0a6a309c9f481604e380d19bef872';
6+
const TOKEN = process.env.TOKEN;
87

98
describe('Users', () => {
109
it('GET /users', () => {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /