Skip to content

Commit 816bcd5

Browse files
author
Walker Leite
committed
refactor(test): change to jest sintax
1 parent 044a3eb commit 816bcd5

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

template/test/client/app.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ describe('App.vue', () => {
4040

4141
{{#extended}}
4242
it('should render router component', () => {
43-
expect(vm.$el.innerHTML).to.equal('mocked component');
44-
expect(vm.$el.getAttribute('id')).to.equal('app');
43+
expect(vm.$el.innerHTML).toEqual('mocked component');
44+
expect(vm.$el.getAttribute('id')).toEqual('app');
4545
});
4646
{{else}}
4747
it('should render correct content', () => {
4848
const newVm = new Constructor().$mount();
4949
return Vue.nextTick().then(() => {
50-
expect(newVm.$el.innerHTML).to.equal('Hello World!');
50+
expect(newVm.$el.innerHTML).toEqual('Hello World!');
5151
});
5252
});
5353
{{/extended}}

template/test/client/components/HelloWorld.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('HelloWorld.vue', () => {
77
it('should render correct content', () => {
88
const vm = new Constructor().$mount();
99
return Vue.nextTick().then(() => {
10-
expect(vm.$el.innerHTML).to.include(
10+
expect(vm.$el.innerHTML).toContain(
1111
'Hello World! This content is restricted.'
1212
);
1313
});

template/test/server/account.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ describe('Account', () => {
2121
});
2222

2323
it('has been correctly declared', () => {
24-
expect(Account).to.inherits(app.models.User);
24+
expect(Account).toInherits(app.models.User);
2525
});
2626

2727
it('should send reset email to test user', () => request(app)
2828
.post('/api/Accounts/reset')
2929
.send({email})
30-
.then(res => expect(res).to.have.status(204))).slow(5000).timeout(30000);
30+
.then(res => expect(res).to.status(204))).slow(5000).timeout(30000);
3131
});

template/test/server/boot.spec.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ describe('boot process', () => {
2525
it('should return server status by root.js', (done) => {
2626
const conn = server.listen(8000, () => {
2727
request(server).get('/api').then((res) => {
28-
expect(res).to.have.status(200);
29-
expect(res.body).to.have.property('started');
30-
expect(res.body).to.have.property('uptime');
28+
expect(res).to.status(200);
29+
expect(res.body).toHavePropertyOfType('started');
30+
expect(res.body).toHavePropertyOfType('uptime');
3131
conn.close(done);
3232
});
3333
});
@@ -36,13 +36,13 @@ describe('boot process', () => {
3636
{{#extended}}
3737
describe('authentication.js', () => {
3838
it('should enable authentication by authentication.js', () => {
39-
expect(server.isAuthEnabled).to.equal(true);
39+
expect(server.isAuthEnabled).toEqual(true);
4040
});
4141
});
4242

4343
describe('email configuration', () => {
4444
it('should have Email model', () => {
45-
expect(server.models).has.property('Email');
45+
expect(server.models).toHavePropertyOfType('Email');
4646
});
4747

4848
it('Email model should send email', (done) => {
@@ -58,38 +58,38 @@ describe('boot process', () => {
5858

5959
describe('create-admin.js', () => {
6060
it('should have Account model', () => {
61-
expect(server.models).has.property('Account');
61+
expect(server.models).toHavePropertyOfType('Account');
6262
});
6363

6464
it('should create a default admin user', () => {
6565
return server.models.Account.find().then((res) => {
66-
expect(res).to.have.lengthOf(1);
67-
expect(res[0]).to.have.property('createdAt');
68-
expect(res[0]).to.have.property('updatedAt');
69-
expect(res[0].id).to.equal(1);
70-
expect(res[0].email).to.equal(initialAccount.email);
71-
expect(res[0].password).to.be.an('string');
66+
expect(res).to.lengthOf(1);
67+
expect(res[0]).toHavePropertyOfType('createdAt');
68+
expect(res[0]).toHavePropertyOfType('updatedAt');
69+
expect(res[0].id).toEqual(1);
70+
expect(res[0].email).toEqual(initialAccount.email);
71+
expect(res[0].password).toEqual('string');
7272
});
7373
});
7474

7575
it('should create a default admin role', () => {
7676
return server.models.Role.find().then((res) => {
77-
expect(res).to.have.lengthOf(1);
78-
expect(res[0]).to.have.property('created');
79-
expect(res[0]).to.have.property('modified');
80-
expect(res[0].id).to.equal(1);
81-
expect(res[0].name).to.equal('admin');
77+
expect(res).to.lengthOf(1);
78+
expect(res[0]).toHavePropertyOfType('created');
79+
expect(res[0]).toHavePropertyOfType('modified');
80+
expect(res[0].id).toEqual(1);
81+
expect(res[0].name).toEqual('admin');
8282
});
8383
});
8484

8585
it('should create RoleMapping entry for admin', () => {
8686
const RoleMapping = server.models.RoleMapping;
8787
return RoleMapping.find().then((res) => {
88-
expect(res).to.have.lengthOf(1);
89-
expect(res[0].id).to.equal(1);
90-
expect(res[0].roleId).to.equal(1);
91-
expect(res[0].principalId).to.equal(1);
92-
expect(res[0].principalType).to.equal(RoleMapping.USER);
88+
expect(res).to.lengthOf(1);
89+
expect(res[0].id).toEqual(1);
90+
expect(res[0].roleId).toEqual(1);
91+
expect(res[0].principalId).toEqual(1);
92+
expect(res[0].principalType).toEqual(RoleMapping.USER);
9393
});
9494
});
9595
});

template/test/server/index.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ describe('Project Index', () => {
1010

1111
it('should serve client files', (done) => {
1212
request(server).get('/index.html').end((err, res) => {
13-
expect(err).to.be.equal(null);
14-
expect(res).to.have.status(200);
13+
expect(err).toEqual(null);
14+
expect(res).to.status(200);
1515
done();
1616
});
1717
});

0 commit comments

Comments
 (0)