Skip to content

Commit

Permalink
test save
Browse files Browse the repository at this point in the history
  • Loading branch information
diegobordeu committed Nov 28, 2019
1 parent a5acecc commit a78a3a2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
25 changes: 25 additions & 0 deletions test/models/table/save/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,28 @@ describe('TABLE GATEWAY: save', () => { // eslint-disable-line
});
});
});

describe('TABLE save: when a input is an Array', () => { // eslint-disable-line

const arrayToTest = [];
const len = 40000;

before(async () => { // eslint-disable-line
await knex('coffee').del();
for (let i = 0; i < len; i++) {
arrayToTest.push({
name: `${i}`,
price: i,
});
}
});

it('save a array', async () => { // eslint-disable-line
await Coffee.saveBunch([...arrayToTest]);
const saved = await knex('coffee').select('*').orderBy('price');
for (let i = 0; i < saved.length; i++) {
delete saved[i].id;
}
assert.deepEqual(arrayToTest, saved);
});
});
1 change: 0 additions & 1 deletion test/models/table/saveBunch/saveBunch.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ describe('TABLE saveBunch: integration', () => { // eslint-disable-line
it('save a array', async () => { // eslint-disable-line
await Coffee.saveBunch([...arrayToTest]);
const saved = await knex('coffee').select('*').orderBy('price');
// console.log(saved);
for (let i = 0; i < saved.length; i++) {
delete saved[i].id;
}
Expand Down

0 comments on commit a78a3a2

Please sign in to comment.