2019-02-28 07:55:34 +00:00
|
|
|
const app = require('vn-loopback/server/server');
|
|
|
|
|
2019-02-28 08:37:42 +00:00
|
|
|
describe('Address createDefaultAddress', () => {
|
2019-02-28 07:55:34 +00:00
|
|
|
let address;
|
|
|
|
let client;
|
|
|
|
|
2019-03-01 10:50:26 +00:00
|
|
|
afterAll(async done => {
|
2019-02-28 07:55:34 +00:00
|
|
|
await client.updateAttributes({defaultAddressFk: 1});
|
|
|
|
await address.destroy();
|
2019-03-01 10:50:26 +00:00
|
|
|
|
|
|
|
done();
|
2019-02-28 07:55:34 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|