#192 item clone test CR Joan
This commit is contained in:
parent
6f162c774e
commit
b959982911
|
@ -1,11 +0,0 @@
|
|||
const app = require('../../../../item/server/server');
|
||||
let ctx = {isNewInstance: true, instance: {}};
|
||||
describe('Item availableId()', () => {
|
||||
it('should define ctx.instance.id with the expected id', async() => {
|
||||
let Item = app.models.Item;
|
||||
|
||||
await Item.availableId(ctx);
|
||||
|
||||
expect(ctx.instance.id).toEqual(6);
|
||||
});
|
||||
});
|
|
@ -1,22 +1,21 @@
|
|||
const clone = require('../clone');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
let Loopback = require('../../../test-helpers/loopback');
|
||||
Loopback.init(model);
|
||||
const app = require(`${servicesDir}/item/server/server`);
|
||||
|
||||
Loopback.rawSql(model);
|
||||
clone(model);
|
||||
|
||||
// disabled test while loopback findOne method isnt extended to model yet.
|
||||
describe('item clone()', () => {
|
||||
it('should', () => {
|
||||
let nextItemId;
|
||||
|
||||
// let itemFk = 1;
|
||||
// model.clone(itemFk)
|
||||
// .then(response => {
|
||||
// expect(response).toEqual('whatever');
|
||||
// done();
|
||||
// });
|
||||
beforeEach(async() => {
|
||||
let query = `SELECT i1.id + 1 as id FROM vn.item i1
|
||||
LEFT JOIN vn.item i2 ON i1.id + 1 = i2.id
|
||||
WHERE i2.id IS NULL ORDER BY i1.id LIMIT 1`;
|
||||
|
||||
[nextAvailableId] = await app.models.Item.rawSql(query);
|
||||
nextItemId = nextAvailableId.id;
|
||||
});
|
||||
|
||||
it('should', async() => {
|
||||
let itemFk = 1;
|
||||
let result = await app.models.Item.clone(itemFk);
|
||||
|
||||
expect(result).toEqual(nextItemId);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue