22import loopback from 'loopback' ;
33import boot from 'loopback-boot' ;
44import path from 'path' ;
5+ import request from 'supertest' ;
56{ { #extended} }
67import initialAccount from '../../server/initial-data/maintenance-account.json' ;
78{ { / e x t e n d e d } }
89
910describe ( 'boot process' , ( ) => {
1011 let server ;
11- const options = {
12- appRootDir : path . resolve ( __dirname , '../../server' ) ,
13- } ;
1412 beforeEach ( ( done ) => {
1513 server = loopback ( ) ;
16- boot ( server , options , done ) ;
14+ boot (
15+ server ,
16+ path . resolve ( __dirname , '../../server' ) ,
17+ done
18+ ) ;
1719 } ) ;
1820
1921 afterEach ( ( done ) => {
@@ -25,7 +27,7 @@ describe('boot process', () => {
2527 it ( 'should return server status by root.js' , ( done ) => {
2628 const conn = server . listen ( 8000 , ( ) => {
2729 request ( server ) . get ( '/api' ) . then ( ( res ) => {
28- expect ( res ) . to . status ( 200 ) ;
30+ expect ( res . statusCode ) . toBe ( 200 ) ;
2931 expect ( res . body ) . toHavePropertyOfType ( 'started' ) ;
3032 expect ( res . body ) . toHavePropertyOfType ( 'uptime' ) ;
3133 conn . close ( done ) ;
@@ -63,18 +65,18 @@ describe('boot process', () => {
6365
6466 it ( 'should create a default admin user' , ( ) => {
6567 return server . models . Account . find ( ) . then ( ( res ) => {
66- expect ( res ) . to . lengthOf ( 1 ) ;
68+ expect ( res ) . toHaveLength ( 1 ) ;
6769 expect ( res [ 0 ] ) . toHavePropertyOfType ( 'createdAt' ) ;
6870 expect ( res [ 0 ] ) . toHavePropertyOfType ( 'updatedAt' ) ;
6971 expect ( res [ 0 ] . id ) . toEqual ( 1 ) ;
7072 expect ( res [ 0 ] . email ) . toEqual ( initialAccount . email ) ;
71- expect ( res [ 0 ] . password ) . toEqual ( 'string' ) ;
73+ expect ( res [ 0 ] . password ) . toBeDefined ( ) ;
7274 } ) ;
7375 } ) ;
7476
7577 it ( 'should create a default admin role' , ( ) => {
7678 return server . models . Role . find ( ) . then ( ( res ) => {
77- expect ( res ) . to . lengthOf ( 1 ) ;
79+ expect ( res ) . toHaveLength ( 1 ) ;
7880 expect ( res [ 0 ] ) . toHavePropertyOfType ( 'created' ) ;
7981 expect ( res [ 0 ] ) . toHavePropertyOfType ( 'modified' ) ;
8082 expect ( res [ 0 ] . id ) . toEqual ( 1 ) ;
@@ -85,7 +87,7 @@ describe('boot process', () => {
8587 it ( 'should create RoleMapping entry for admin' , ( ) => {
8688 const RoleMapping = server . models . RoleMapping ;
8789 return RoleMapping . find ( ) . then ( ( res ) => {
88- expect ( res ) . to . lengthOf ( 1 ) ;
90+ expect ( res ) . toHaveLength ( 1 ) ;
8991 expect ( res [ 0 ] . id ) . toEqual ( 1 ) ;
9092 expect ( res [ 0 ] . roleId ) . toEqual ( 1 ) ;
9193 expect ( res [ 0 ] . principalId ) . toEqual ( 1 ) ;
0 commit comments