8000 test(account): improve test coverage · InCuca/vue-loopback@dafddda · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit dafddda

Browse files
committed
test(account): improve test coverage
1 parent bc62f54 commit dafddda

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

template/server/models/account.spec.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import request from 'supertest';
22
import createLoopback from '~/test/utils/create-loopback';
33
import AccountFactory from './account';
4-
import { host } from '../config.json';
4+
import {host} from '../config.json';
55

66
describe('Account unit', () => {
77
const AccountMock = {
@@ -31,6 +31,10 @@ describe('Account unit', () => {
3131
AccountMock.on.mockImplementation((_, fn) => {
3232
fn(infoMock);
3333
});
34+
console.log = jest.fn();
35+
AccountMock.app.models.Email.send.mockImplementation((_, errFn) => {
36+
errFn();
37+
});
3438
AccountFactory(AccountMock);
3539
expect(AccountMock.app.models.Email.send).toBeCalledWith(
3640
expect.objectContaining({
@@ -43,10 +47,32 @@ describe('Account unit', () => {
4347
}),
4448
expect.any(Function),
4549
);
50+
expect(console.log).toBeCalledWith(
51+
expect.any(String),
52+
expect.stringContaining(infoMock.email)
53+
);
54+
});
55+
56+
it('console log when Email send throws', () => {
57+
const infoMock = {
58+
email: 'foo@bar.net',
59+
accessToken: {
60+
id: 'foobar',
61+
},
62+
};
63+
AccountMock.on.mockImplementation((_, fn) => {
64+
fn(infoMock);
65+
});
66+
console.log = jest.fn();
67+
AccountMock.app.models.Email.send.mockImplementation((_, errFn) => {
68+
errFn('foo');
69+
});
70+
AccountFactory(AccountMock);
71+
expect(console.log).toBeCalledWith('foo');
4672
});
4773
});
4874

49-
describe('Account', () => {
75+
describe('Account e2e', () => {
5076
const email = '936ue5+4bnywbeje42pw@sharklasers.com';
5177
let server, testAccount, Account;
5278

0 commit comments

Comments
 (0)
0