mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
fix: make sure all tests are passing
This commit is contained in:
@@ -325,20 +325,6 @@ test("note content should not contain image base64 data after save", () =>
|
||||
expect(content).not.toContain(`src=`);
|
||||
}));
|
||||
|
||||
test("repairing notebook references should reinclude the missing noteIds", () =>
|
||||
notebookTest().then(async ({ db, id }) => {
|
||||
const notebook = db.notebooks.notebook(id);
|
||||
let note = {
|
||||
...TEST_NOTE,
|
||||
notebooks: [{ id, topics: [notebook.topics.all[0].id] }],
|
||||
};
|
||||
const noteId = await db.notes.add(note);
|
||||
await db.notes.repairReferences();
|
||||
note = db.notes.note(noteId);
|
||||
expect(notebook.topics.all[0].notes).toHaveLength(0);
|
||||
expect(note.notebooks).toHaveLength(0);
|
||||
}));
|
||||
|
||||
test("repairing notebook references should delete non-existent notebooks", () =>
|
||||
noteTest({
|
||||
...TEST_NOTE,
|
||||
@@ -355,7 +341,7 @@ test("adding a note with an invalid tag should clean the tag array", () =>
|
||||
db.notes.add({
|
||||
...TEST_NOTE,
|
||||
id: "helloworld",
|
||||
tags: ["/.,"],
|
||||
tags: [" "],
|
||||
})
|
||||
).resolves.toBe("helloworld");
|
||||
|
||||
|
||||
@@ -236,7 +236,6 @@ export default class Notes extends Collection {
|
||||
);
|
||||
let topic = this._db.notebooks.notebook(to.id).topics.topic(to.topic);
|
||||
if (!topic) throw new Error("No such topic exists.");
|
||||
console.log(topic, noteIds);
|
||||
await topic.add(...noteIds);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ export default class Topic {
|
||||
|
||||
const noteNotebook = notebooks.find((nb) => nb.id === this._notebookId);
|
||||
const noteHasNotebook = !!noteNotebook;
|
||||
const noteHasTopic = noteNotebook.topics.indexOf(topic.id) > -1;
|
||||
const noteHasTopic =
|
||||
noteHasNotebook && noteNotebook.topics.indexOf(topic.id) > -1;
|
||||
if (noteHasNotebook && !noteHasTopic) {
|
||||
// 1 note can be inside multiple topics
|
||||
noteNotebook.topics.push(topic.id);
|
||||
|
||||
Reference in New Issue
Block a user