#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 app = require(`${servicesDir}/item/server/server`);
|
||||||
const model = {
|
|
||||||
remoteMethod: () => {}
|
|
||||||
};
|
|
||||||
let Loopback = require('../../../test-helpers/loopback');
|
|
||||||
Loopback.init(model);
|
|
||||||
|
|
||||||
Loopback.rawSql(model);
|
|
||||||
clone(model);
|
|
||||||
|
|
||||||
// disabled test while loopback findOne method isnt extended to model yet.
|
|
||||||
describe('item clone()', () => {
|
describe('item clone()', () => {
|
||||||
it('should', () => {
|
let nextItemId;
|
||||||
|
|
||||||
// let itemFk = 1;
|
beforeEach(async() => {
|
||||||
// model.clone(itemFk)
|
let query = `SELECT i1.id + 1 as id FROM vn.item i1
|
||||||
// .then(response => {
|
LEFT JOIN vn.item i2 ON i1.id + 1 = i2.id
|
||||||
// expect(response).toEqual('whatever');
|
WHERE i2.id IS NULL ORDER BY i1.id LIMIT 1`;
|
||||||
// done();
|
|
||||||
// });
|
[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