@@ -7,10 +7,8 @@ import root from '../../server/boot/root.js';
77import auth from '../../server/boot/authentication.js' ;
88import createAdmin from '../../server/boot/create-admin.js' ;
99
10- import initialAccount from '../../server/initial-data/manutencao-account' ;
11- import initialProf from '../../server/initial-data/example1-professor' ;
12- import initialAula from '../../server/initial-data/example1-aula' ;
13- import initialAluno from '../../server/initial-data/example1-aluno' ;
10+ import initialAccount from '../../server/initial-data/maintenance-account' ;
11+
1412{ { / e x t e n d e d } }
1513describe ( 'boot process' , ( ) => {
1614 { { #extended} }
@@ -63,5 +61,43 @@ describe('boot process', () => {
6361 } , done ) ;
6462 } ) . slow ( 5000 ) . timeout ( 30000 ) ;
6563 } ) ;
64+
65+ describe ( 'create-admin.js' , ( ) => {
66+ it ( 'should have Account model' , ( ) => {
67+ expect ( server . models ) . has . property ( 'Account' ) ;
68+ } ) ;
69+
70+ it ( 'should create a default admin user' , ( ) => {
71+ return server . models . Account . find ( ) . then ( res => {
72+ expect ( res ) . to . have . lengthOf ( 1 ) ;
73+ expect ( res [ 0 ] ) . to . have . property ( 'createdAt' ) ;
74+ expect ( res [ 0 ] ) . to . have . property ( 'updatedAt' ) ;
75+ expect ( res [ 0 ] . id ) . to . equal ( 1 ) ;
76+ expect ( res [ 0 ] . email ) . to . equal ( initialAccount . email ) ;
77+ expect ( res [ 0 ] . password ) . to . be . an ( 'string' ) ;
78+ } ) ;
79+ } ) ;
80+
81+ it ( 'should create a default admin role' , ( ) => {
82+ return server . models . Role . find ( ) . then ( res => {
83+ expect ( res ) . to . have . lengthOf ( 1 ) ;
84+ expect ( res [ 0 ] ) . to . have . property ( 'created' ) ;
85+ expect ( res [ 0 ] ) . to . have . property ( 'modified' ) ;
86+ expect ( res [ 0 ] . id ) . to . equal ( 1 ) ;
87+ expect ( res [ 0 ] . name ) . to . equal ( 'admin' ) ;
88+ } ) ;
89+ } ) ;
90+
91+ it ( 'should create RoleMapping entry for admin' , ( ) => {
92+ const RoleMapping = server . models . RoleMapping ;
93+ return RoleMapping . find ( ) . then ( res => {
94+ expect ( res ) . to . have . lengthOf ( 1 ) ;
95+ expect ( res [ 0 ] . id ) . to . equal ( 1 ) ;
96+ expect ( res [ 0 ] . roleId ) . to . equal ( 1 ) ;
97+ expect ( res [ 0 ] . principalId ) . to . equal ( 1 ) ;
98+ expect ( res [ 0 ] . principalType ) . to . equal ( RoleMapping . USER ) ;
99+ } ) ;
100+ } ) ;
101+ } ) ;
66102 { { / e x t e n d e d } }
67103} ) ;
0 commit comments