Skip to content

Commit aa53bb3

Browse files
committed
test(boot): add options and fix tests
1 parent fbb68b2 commit aa53bb3

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

template/test/server/boot.spec.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ import path from 'path';
55
import request from 'supertest';
66
{{#extended}}
77
import initialAccount from '../../server/initial-data/maintenance-account.json';
8-
import TimeStamp from 'loopback-ds-timestamp-mixin';
98
{{/extended}}
109

1110
describe('boot process', () => {
1211
let server;
12+
const options = {
13+
appRootDir: path.resolve(__dirname, '../../server'),
14+
scriptExtensions: ['.js', '.json', '.node', '.ejs'],
15+
}
1316
beforeEach((done) => {
1417
server = loopback();
15-
boot(server, path.resolve(__dirname, '../../server'), () => {
16-
{{#extended}}
17-
server.loopback.modelBuilder.mixins.define('TimeStamp', TimeStamp);
18-
{{/extended}}
19-
done();
20-
});
18+
boot(server, options, done);
2119
});
2220

2321
afterEach((done) => {
@@ -30,8 +28,8 @@ describe('boot process', () => {
3028
const conn = server.listen(8000, () => {
3129
request(server).get('/api').then((res) => {
3230
expect(res.statusCode).toBe(200);
33-
expect(res.body).toHavePropertyOfType('started');
34-
expect(res.body).toHavePropertyOfType('uptime');
31+
expect(res.body).toHaveProperty('started');
32+
expect(res.body).toHaveProperty('uptime');
3533
conn.close(done);
3634
});
3735
});
@@ -46,7 +44,7 @@ describe('boot process', () => {
4644

4745
describe('email configuration', () => {
4846
it('should have Email model', () => {
49-
expect(server.models).toHavePropertyOfType('Email');
47+
expect(server.models).toHaveProperty('Email');
5048
});
5149

5250
it('Email model should send email', (done) => {
@@ -62,14 +60,14 @@ describe('boot process', () => {
6260

6361
describe('create-admin.js', () => {
6462
it('should have Account model', () => {
65-
expect(server.models).toHavePropertyOfType('Account');
63+
expect(server.models).toHaveProperty('Account');
6664
});
6765

6866
it('should create a default admin user', () => {
6967
return server.models.Account.find().then((res) => {
7068
expect(res).toHaveLength(1);
71-
expect(res[0]).toHavePropertyOfType('createdAt');
72-
expect(res[0]).toHavePropertyOfType('updatedAt');
69+
expect(res[0]).toHaveProperty('createdAt');
70+
expect(res[0]).toHaveProperty('updatedAt');
7371
expect(res[0].id).toEqual(1);
7472
expect(res[0].email).toEqual(initialAccount.email);
7573
expect(res[0].password).toBeDefined();
@@ -79,8 +77,8 @@ describe('boot process', () => {
7977
it('should create a default admin role', () => {
8078
return server.models.Role.find().then((res) => {
8179
expect(res).toHaveLength(1);
82-
expect(res[0]).toHavePropertyOfType('created');
83-
expect(res[0]).toHavePropertyOfType('modified');
80+
expect(res[0]).toHaveProperty('created');
81+
expect(res[0]).toHaveProperty('modified');
8482
expect(res[0].id).toEqual(1);
8583
expect(res[0].name).toEqual('admin');
8684
});

0 commit comments

Comments
 (0)