core: add more lookup tests

This commit is contained in:
Abdullah Atta
2024-02-19 16:35:39 +05:00
parent 974221d938
commit cd55f443d9

View File

@@ -17,7 +17,13 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { noteTest, TEST_NOTE, notebookTest, TEST_NOTEBOOK2 } from "./utils";
import {
noteTest,
TEST_NOTE,
notebookTest,
TEST_NOTEBOOK2,
databaseTest
} from "./utils";
import { test, expect } from "vitest";
const content = {
@@ -64,3 +70,28 @@ test("search notebooks", () =>
let filtered = await db.lookup.notebooks("Description").ids();
expect(filtered.length).toBeGreaterThan(0);
}));
test("search should not return trashed notes", () =>
databaseTest().then(async (db) => {
const id = await db.notes.add({
title: "world is a heavy tune"
});
await db.notes.moveToTrash(id);
const filtered = await db.lookup.notes("heavy tune").ids();
expect(filtered).toHaveLength(0);
}));
test("search should return restored notes", () =>
databaseTest().then(async (db) => {
const id = await db.notes.add({
title: "world is a heavy tune"
});
await db.notes.moveToTrash(id);
await db.trash.restore(id);
const filtered = await db.lookup.notes("heavy tune").ids();
expect(filtered).toHaveLength(1);
}));