36 lines
1001 B
JavaScript
36 lines
1001 B
JavaScript
|
const app = require('vn-loopback/server/server');
|
||
|
|
||
|
fdescribe('Address createDefaultAddress', () => {
|
||
|
let address;
|
||
|
let client;
|
||
|
|
||
|
afterAll(async() => {
|
||
|
await client.updateAttributes({defaultAddressFk: 1});
|
||
|
await address.destroy();
|
||
|
});
|
||
|
|
||
|
it('should verify that client defaultAddressFk is untainted', async() => {
|
||
|
client = await app.models.Client.findById(101);
|
||
|
|
||
|
expect(client.defaultAddressFk).toEqual(1);
|
||
|
});
|
||
|
|
||
|
it('should create a new address and set as a client default address', async() => {
|
||
|
let data = {
|
||
|
address: {
|
||
|
clientFk: 101,
|
||
|
nickname: 'My address',
|
||
|
street: 'Wall Street',
|
||
|
city: 'New York',
|
||
|
|
||
|
},
|
||
|
isDefaultAddress: true
|
||
|
};
|
||
|
|
||
|
address = await app.models.Address.createDefaultAddress(data);
|
||
|
client = await app.models.Client.findById(101);
|
||
|
|
||
|
expect(client.defaultAddressFk).toEqual(address.id);
|
||
|
});
|
||
|
});
|