fix: do not get undefined items

This commit is contained in:
thecodrr
2020-04-21 12:23:51 +05:00
parent f9f7e3471d
commit 1c253b2170
2 changed files with 7 additions and 1 deletions

View File

@@ -4,10 +4,16 @@ import {
notebookTest, notebookTest,
TEST_NOTE, TEST_NOTE,
TEST_NOTEBOOK, TEST_NOTEBOOK,
databaseTest,
} from "./utils"; } from "./utils";
beforeEach(() => StorageInterface.clear()); beforeEach(() => StorageInterface.clear());
test("trash should be empty", () =>
databaseTest().then((db) => {
expect(db.trash.all.length).toBe(0);
}));
test("permanently delete a note", () => test("permanently delete a note", () =>
noteTest().then(async ({ db, id }) => { noteTest().then(async ({ db, id }) => {
const note = db.notes.note(id); const note = db.notes.note(id);

View File

@@ -79,7 +79,7 @@ export default class CachedCollection {
getAllItems(sortFn = (u) => u.dateCreated) { getAllItems(sortFn = (u) => u.dateCreated) {
let items = []; let items = [];
this.map.forEach((value) => { this.map.forEach((value) => {
if (value.deleted) return; if (!value || value.deleted) return;
items[items.length] = value; items[items.length] = value;
}); });
return sort(items).desc(sortFn); return sort(items).desc(sortFn);