53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
const app = require(`${servicesDir}/client/server/server`);
|
|
|
|
describe('Client crud', () => {
|
|
afterAll(async() => {
|
|
await app.models.ClientContact.destroyById(4113);
|
|
});
|
|
|
|
it('should perfom a query to create new contacts', async() => {
|
|
let data = {
|
|
delete: [],
|
|
create: [
|
|
{id: 4113, clientFk: 101, name: 'My contact', phone: '111111111'}
|
|
],
|
|
update: []
|
|
};
|
|
|
|
await app.models.ClientContact.crud(data);
|
|
let contacts = await app.models.ClientContact.find();
|
|
|
|
expect(contacts.length).toEqual(5);
|
|
});
|
|
|
|
it('should perfom a query to update contacts', async() => {
|
|
let data = {
|
|
delete: [],
|
|
create: [],
|
|
update: [
|
|
{id: 4113, name: 'My contact 2 updated', phone: '222222222'}
|
|
]
|
|
};
|
|
|
|
await app.models.ClientContact.crud(data);
|
|
let contacts = await app.models.ClientContact.findById(4113);
|
|
|
|
expect(contacts.name).toEqual('My contact 2 updated');
|
|
expect(contacts.phone).toEqual('222222222');
|
|
});
|
|
|
|
it('should perfom a query to delete contacts', async() => {
|
|
let data = {
|
|
delete: [4113],
|
|
create: [],
|
|
update: []
|
|
};
|
|
|
|
await app.models.ClientContact.crud(data);
|
|
|
|
let contacts = await app.models.ClientContact.find();
|
|
|
|
expect(contacts.length).toEqual(4);
|
|
});
|
|
});
|