|
1 |
| -import app from '../../server/server'; |
| 1 | +import request from 'supertest'; |
| 2 | +import createLoopback from './utils/create-loopback'; |
2 | 3 |
|
3 | 4 | describe('Account', () => {
|
4 |
| - const Account = app.models.Account; |
5 | 5 | const email = '936ue5+4bnywbeje42pw@sharklasers.com';
|
| 6 | + let server; |
6 | 7 | let testAccount;
|
| 8 | + let Account; |
7 | 9 |
|
8 |
| - beforeEach(() => { |
9 |
| - const appStarted = new Promise(res => app.addListener('started', res)); |
10 |
| - app.start(); |
11 |
| - return appStarted.then(() => Account |
12 |
| - .create({email, password: 'IuhEW7HI#&HUH3'}) |
13 |
| - .then((acc) => { |
14 |
| - testAccount = acc; |
15 |
| - })); |
| 10 | + beforeEach(async () => { |
| 11 | + server = await createLoopback(); |
| 12 | + Account = server.models.Account; |
| 13 | + testAccount = await Account.create({ |
| 14 | + email, |
| 15 | + password: 'IuhEW7HI#&HUH3' |
| 16 | + }); |
16 | 17 | });
|
17 | 18 |
|
18 |
| - afterEach(() => { |
19 |
| - Account.destroyById(testAccount.id); |
20 |
| - app.close(); |
21 |
| - }); |
| 19 | + afterEach(() => Account.destroyById(testAccount.id)); |
22 | 20 |
|
23 | 21 | it('has been correctly declared', () => {
|
24 |
| - expect(Account).toInherits(app.models.User); |
| 22 | + expect(Account).toInherits(server.models.User); |
25 | 23 | });
|
26 | 24 |
|
27 |
| - it('should send reset email to test user', () => request(app) |
| 25 | + it('should send reset email to test user', () => request(server) |
28 | 26 | .post('/api/Accounts/reset')
|
29 |
| - .send({email}) |
30 |
| - .then(res => expect(res).to.status(204))).slow(5000).timeout(30000); |
| 27 | + .send({ email }) |
| 28 | + .expect(204), |
| 29 | + 30000, |
| 30 | + ); |
31 | 31 | });
|
0 commit comments