import { A_SUGGESTION_ID, A_USER_ID, SOME_DATE, SOME_LANGUAGE, SOME_NEWER_DATE, SOME_OTHER_LANGUAGE, } from "../../../../utils/tests/testData"; import SuggestionsMetadata from "../../../suggestions/repositories/suggestionsMetadata.entity"; import { getSuggestionsMetadataRepository } from "../../../suggestions/repositories/suggestionsMetadata.repository"; function createGenericSuggestion(): SuggestionsMetadata { const suggestion = new SuggestionsMetadata(); suggestion.user = A_USER_ID; suggestion.suggestionId = A_SUGGESTION_ID; suggestion.time = SOME_DATE; suggestion.language = SOME_LANGUAGE; suggestion.filename = "a filename"; return suggestion; } export async function persistMultipleLanguageSuggestions(): Promise { const suggestions = [SOME_LANGUAGE, SOME_LANGUAGE, SOME_OTHER_LANGUAGE].map( (language) => ({ ...createGenericSuggestion(), language, }) ); await getSuggestionsMetadataRepository().save(suggestions); } export async function persistOldAndNewSuggestions(): Promise { const suggestions = [SOME_DATE, SOME_NEWER_DATE].map((time) => ({ ...createGenericSuggestion(), time, })); await getSuggestionsMetadataRepository().save(suggestions); }