Skip to content

Commit 03bc937

Browse files
committed
test: use single test
1 parent 1841072 commit 03bc937

File tree

1 file changed

+10
-29
lines changed

1 file changed

+10
-29
lines changed
Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
describe('requestContextMiddleware', () => {
22

3-
it('should support dependency injection on graphql api', async () => {
3+
it('should support dependency injection on graphql and rest api', async () => {
44
const requestContextMiddleware = (req, res, next) => {
55
req.config.aCustomController = 'aCustomController';
66
next();
77
};
8-
let called = false;
9-
await reconfigureServer({
10-
requestContextMiddleware,
11-
mountGraphQL: true,
12-
graphQLPath: '/graphql',
13-
});
148

9+
let called = 0
10+
await reconfigureServer({ requestContextMiddleware, mountGraphQL: true, graphQLPath: '/graphql' });
1511
Parse.Cloud.beforeSave('_User', request => {
1612
expect(request.config.aCustomController).toEqual('aCustomController');
17-
called = true;
13+
called++;
1814
});
15+
const user = new Parse.User();
16+
user.setUsername('test');
17+
user.setPassword('test');
18+
await user.signUp();
1919

2020
await fetch('http://localhost:8378/graphql', {
2121
method: 'POST',
@@ -27,7 +27,7 @@ describe('requestContextMiddleware', () => {
2727
body: JSON.stringify({
2828
query: `
2929
mutation {
30-
createUser(input: { fields: { username: "test", password: "test" } }) {
30+
createUser(input: { fields: { username: "test2", password: "test2" } }) {
3131
user {
3232
objectId
3333
}
@@ -36,25 +36,6 @@ describe('requestContextMiddleware', () => {
3636
`,
3737
}),
3838
});
39-
expect(called).toBeTruthy();
40-
});
41-
42-
it('should support dependency injection on rest api', async () => {
43-
const requestContextMiddleware = (req, res, next) => {
44-
req.config.aCustomController = 'aCustomController';
45-
next();
46-
};
47-
48-
let called;
49-
await reconfigureServer({ requestContextMiddleware });
50-
Parse.Cloud.beforeSave('_User', request => {
51-
expect(request.config.aCustomController).toEqual('aCustomController');
52-
called = true;
53-
});
54-
const user = new Parse.User();
55-
user.setUsername('test');
56-
user.setPassword('test');
57-
await user.signUp();
58-
expect(called).toBeTruthy();
39+
expect(called).toBe(2);
5940
});
6041
});

0 commit comments

Comments
 (0)