#524 backend clone.js unit tests

This commit is contained in:
Carlos Jimenez 2018-08-06 12:00:29 +02:00
parent 7367792d91
commit 084896c69a
1 changed files with 10 additions and 1 deletions

View File

@ -12,10 +12,19 @@ describe('item clone()', () => {
nextItemId = nextAvailableId.id;
});
it('should', async() => {
it('should clone the given item and it should have the expected id', async() => {
let itemFk = 1;
let result = await app.models.Item.clone(itemFk);
expect(result).toEqual(nextItemId);
});
it('should attempt to clone the given item but give an error as it doesnt exist', async() => {
try {
let itemFk = 999;
await app.models.Item.clone(itemFk);
} catch (error) {
expect(error.toString()).toContain('Cannot convert undefined or null to object');
}
});
});