chore(test): simplify import of becca_mocking

This commit is contained in:
Elian Doran
2025-02-06 20:55:46 +02:00
parent a767ee3d2c
commit acb858bc29
4 changed files with 137 additions and 165 deletions

View File

@@ -7,11 +7,11 @@ import type SearchResult from "../../src/services/search/search_result.js";
import type { NoteRow, NoteType } from "../../src/becca/entities/rows.js";
randtoken.generator({ source: "crypto" });
function findNoteByTitle(searchResults: Array<SearchResult>, title: string): BNote | undefined {
export function findNoteByTitle(searchResults: Array<SearchResult>, title: string): BNote | undefined {
return searchResults.map((sr) => becca.notes[sr.noteId]).find((note) => note.title === title);
}
class NoteBuilder {
export class NoteBuilder {
note: BNote;
constructor(note: BNote) {
this.note = note;
@@ -55,11 +55,11 @@ class NoteBuilder {
}
}
function id() {
export function id() {
return randtoken.generate(10);
}
function note(title: string, extraParams: Partial<NoteRow> = {}) {
export function note(title: string, extraParams: Partial<NoteRow> = {}) {
const row = Object.assign(
{
noteId: id(),
@@ -74,9 +74,3 @@ function note(title: string, extraParams: Partial<NoteRow> = {}) {
return new NoteBuilder(note);
}
export default {
NoteBuilder,
findNoteByTitle,
note
};