mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 14:39: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 }) => {
|
notebookTest().then(async ({ db, id }) => {
|
||||||
let notebook = db.notebooks.notebook(id);
|
let notebook = db.notebooks.notebook(id);
|
||||||
await notebook.pin();
|
await notebook.pin();
|
||||||
|
notebook = db.notebooks.notebook(id);
|
||||||
expect(notebook.data.pinned).toBe(true);
|
expect(notebook.data.pinned).toBe(true);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -43,8 +44,10 @@ test("unpin a notebook", () =>
|
|||||||
notebookTest().then(async ({ db, id }) => {
|
notebookTest().then(async ({ db, id }) => {
|
||||||
let notebook = db.notebooks.notebook(id);
|
let notebook = db.notebooks.notebook(id);
|
||||||
await notebook.pin();
|
await notebook.pin();
|
||||||
|
notebook = db.notebooks.notebook(id);
|
||||||
expect(notebook.data.pinned).toBe(true);
|
expect(notebook.data.pinned).toBe(true);
|
||||||
await notebook.pin();
|
await notebook.pin();
|
||||||
|
notebook = db.notebooks.notebook(id);
|
||||||
expect(notebook.data.pinned).toBe(false);
|
expect(notebook.data.pinned).toBe(false);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -52,6 +55,7 @@ test("favorite a notebook", () =>
|
|||||||
notebookTest().then(async ({ db, id }) => {
|
notebookTest().then(async ({ db, id }) => {
|
||||||
let notebook = db.notebooks.notebook(id);
|
let notebook = db.notebooks.notebook(id);
|
||||||
await notebook.favorite();
|
await notebook.favorite();
|
||||||
|
notebook = db.notebooks.notebook(id);
|
||||||
expect(notebook.data.favorite).toBe(true);
|
expect(notebook.data.favorite).toBe(true);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -59,8 +63,10 @@ test("unfavorite a notebook", () =>
|
|||||||
notebookTest().then(async ({ db, id }) => {
|
notebookTest().then(async ({ db, id }) => {
|
||||||
let notebook = db.notebooks.notebook(id);
|
let notebook = db.notebooks.notebook(id);
|
||||||
await notebook.favorite();
|
await notebook.favorite();
|
||||||
|
notebook = db.notebooks.notebook(id);
|
||||||
expect(notebook.data.favorite).toBe(true);
|
expect(notebook.data.favorite).toBe(true);
|
||||||
await notebook.favorite();
|
await notebook.favorite();
|
||||||
|
notebook = db.notebooks.notebook(id);
|
||||||
expect(notebook.data.favorite).toBe(false);
|
expect(notebook.data.favorite).toBe(false);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ export default class Notebook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggle(prop) {
|
toggle(prop) {
|
||||||
this.notebook[prop] = !this.notebook[prop];
|
return this.notebooks.add({
|
||||||
return this.notebooks.add(this.notebook);
|
id: this.notebook.id,
|
||||||
|
[prop]: !this.notebook[prop]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pin() {
|
pin() {
|
||||||
|
|||||||
Reference in New Issue
Block a user