Skip to content

Commit

Permalink
Tests verify that #1740 was actually resolved...
Browse files Browse the repository at this point in the history
...by previous commit
  • Loading branch information
dfahlander committed Jun 12, 2023
1 parent 3888406 commit c8d504e
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions test/tests-whereclause.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ db.version(2).stores({
people: "[name+number],name,number",
friends: "++id,name,age",
chart: '[patno+row+col], patno',
chaps: "++id,[name+number+shoeSize]",
chaps: "++id,[name+number+age]",
multiMulti: "id,*tags,*categories"
});

Expand Down Expand Up @@ -753,7 +753,7 @@ asyncTest("startsWithAnyOfIgnoreCase()", function () {
}).finally(start);
});

promisedTest("where({key: value})", async ()=>{
promisedTest("where({key: value})", async () => {
let readme = await db.files.where({filename: "README"}).first();
ok (readme, 'Should get a result for db.files.get({filename: "README"});');
equal (readme.extension, ".TXT", "Should get README.TXT");
Expand Down Expand Up @@ -782,6 +782,26 @@ promisedTest("where({key: value})", async ()=>{
});
});

promisedTest("where({notIndexed: value}) should not return emtpy result", async () => {
await db.chaps.add({name: "Chaplin", number: 1, age: 134, notIndexed: 'foo'});
try {
let chaplin = await db.chaps.where({name: "Chaplin", notIndexed: "foo"}).first();
if (!chaplin) {
ok(false, "Got empty result when data exists matching the query. If we're not using an index we should not get an empty result but an error.");
} else {
ok(chaplin,
"Ok, so we got a result even though 'notIndexed' is not indexed at all. "+
"This is not expected but ok if the result would be valid"
);
equal(chaplin.name, "Chaplin", "Got the correct data Chaplin!");
}
} catch (e) {
ok(true, `Got error: "${e}" because 'notIndexed' is not indexed at all. This is also ok.`);
}
});



promisedTest("orderBy(['idx1','idx2'])", async () => {
if (!supports("compound")) {
ok(true, "Browser does not support compound indexes. Ignoring test.");
Expand Down Expand Up @@ -819,19 +839,19 @@ promisedTest("Virtual Index", async () => {
await db.chaps.bulkAdd([{
name: "David",
number: 2,
shoeSize: 43
age: 29
},{
name: "David",
number: 3,
shoeSize: 44
age: 39
},{
name: "David",
number: 1,
shoeSize: 45
age: 49
},{
name: "Mambo",
number: 5,
shoeSize: 46
age: 55
}]);

// Verify that Dexie can use the [name+number] index to query name only:
Expand Down

0 comments on commit c8d504e

Please sign in to comment.