feat: add get favorites

This commit is contained in:
thecodrr
2019-12-17 17:22:25 +05:00
parent 1c81034d57
commit 2e2258603a
2 changed files with 9 additions and 0 deletions

View File

@@ -80,6 +80,11 @@ test("update note", async () => {
expect(note.colors).toStrictEqual(["red", "blue"]);
});
test("get favorites", () => {
let favorites = db.getFavorites();
expect(favorites.length).toBeGreaterThan(0);
});
test("note with text longer than 150 characters should have ... in the headline", () => {
let note = db.getNote(TEST_NOTE.dateCreated);
expect(note.headline.includes("...")).toBe(true);

View File

@@ -55,6 +55,10 @@ class Database {
return extractValues(this.notes).reverse();
}
getFavorites() {
return tfun.filter(".favorite = true")(extractValues(this.notes));
}
/**
* Group notes by given criteria
* @param {string} by One from 'abc', 'month', 'year' or 'week'. Leave it empty for default grouping.