Skip to content

Commit

Permalink
Repro of #1195
Browse files Browse the repository at this point in the history
  • Loading branch information
dfahlander committed Dec 16, 2020
1 parent dbcc43e commit 8d2638d
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion test/tests-crud-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import Dexie from 'dexie';
import {module, stop, start, test, asyncTest, equal, ok} from 'QUnit';
import {resetDatabase, supports, spawnedTest} from './dexie-unittest-utils';
import {resetDatabase, supports, spawnedTest, promisedTest} from './dexie-unittest-utils';

let Promise = Dexie.Promise,
all = Promise.all,
Expand Down Expand Up @@ -766,3 +766,34 @@ spawnedTest("deleting using Collection.delete()", function*(){
yield db.table1.where('id').between(0,2).delete(); // delete
}));
});

promisedTest("issue #1195 Update with array as value adds number objects", async ()=>{
await expect([{
op: "create",
key: 1,
value: {id:1}
},{
op: "update",
key: 1,
obj: {id:1},
mods: {authors: [{foo: "bar"}]},
updatedObj: {id:1, authors: [{foo: "bar"}]},
},{
op: "update",
key: 1,
obj: {id:1, authors: [{foo: "bar"}]},
mods: {authors: []},
updatedObj: {id:1, authors: []},
},{
op: "update",
key: 1,
obj: {id:1, authors: []},
mods: {authors: [{name: "foo"}, {name: "bar"}]},
updatedObj: {id:1, authors: [{name: "foo"}, {name: "bar"}]},
}], ()=>db.transaction('rw', db.table1, async ()=>{
await db.table1.add({id:1});
await db.table1.put({id:1, authors: [{foo: "bar"}]});
await db.table1.put({id:1, authors: []});
await db.table1.put({id:1, authors: [{name: "foo"}, {name: "bar"}]});
}));
});

0 comments on commit 8d2638d

Please sign in to comment.