mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-21 14:09:34 +01:00
fix: don't mutate the notebook object
This commit is contained in:
@@ -36,6 +36,7 @@ test("pin a notebook", () =>
|
||||
notebookTest().then(async ({ db, id }) => {
|
||||
let notebook = db.notebooks.notebook(id);
|
||||
await notebook.pin();
|
||||
notebook = db.notebooks.notebook(id);
|
||||
expect(notebook.data.pinned).toBe(true);
|
||||
}));
|
||||
|
||||
@@ -43,8 +44,10 @@ test("unpin a notebook", () =>
|
||||
notebookTest().then(async ({ db, id }) => {
|
||||
let notebook = db.notebooks.notebook(id);
|
||||
await notebook.pin();
|
||||
notebook = db.notebooks.notebook(id);
|
||||
expect(notebook.data.pinned).toBe(true);
|
||||
await notebook.pin();
|
||||
notebook = db.notebooks.notebook(id);
|
||||
expect(notebook.data.pinned).toBe(false);
|
||||
}));
|
||||
|
||||
@@ -52,6 +55,7 @@ test("favorite a notebook", () =>
|
||||
notebookTest().then(async ({ db, id }) => {
|
||||
let notebook = db.notebooks.notebook(id);
|
||||
await notebook.favorite();
|
||||
notebook = db.notebooks.notebook(id);
|
||||
expect(notebook.data.favorite).toBe(true);
|
||||
}));
|
||||
|
||||
@@ -59,8 +63,10 @@ test("unfavorite a notebook", () =>
|
||||
notebookTest().then(async ({ db, id }) => {
|
||||
let notebook = db.notebooks.notebook(id);
|
||||
await notebook.favorite();
|
||||
notebook = db.notebooks.notebook(id);
|
||||
expect(notebook.data.favorite).toBe(true);
|
||||
await notebook.favorite();
|
||||
notebook = db.notebooks.notebook(id);
|
||||
expect(notebook.data.favorite).toBe(false);
|
||||
}));
|
||||
|
||||
|
||||
@@ -25,8 +25,10 @@ export default class Notebook {
|
||||
}
|
||||
|
||||
toggle(prop) {
|
||||
this.notebook[prop] = !this.notebook[prop];
|
||||
return this.notebooks.add(this.notebook);
|
||||
return this.notebooks.add({
|
||||
id: this.notebook.id,
|
||||
[prop]: !this.notebook[prop]
|
||||
});
|
||||
}
|
||||
|
||||
pin() {
|
||||
|
||||
Reference in New Issue
Block a user