Created
September 8, 2023 00:57
-
-
Save mandemeskel/ea6f37fd541286df5246e74f5e5f6a8f to your computer and use it in GitHub Desktop.
constructor tests for a query class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createNqbMock from "@tests/shared/nqb_mock" | |
const nqb_mock = createNqbMock() | |
const qb_mock = { | |
sendRequest: nqb_mock.mockSendRequest, | |
} | |
import UnpaidInvoicesFromDateQueryTapi from "./unpaid_invoices_from_date_query_tapi" | |
import unpaidInvoicesFromDateQueryFactory, { UnpaidInvoicesFromDateQuery } from "@qb/query_wrappers/unpaid_invoices_from_date_query" | |
import { QbApiType } from "@qb/request" | |
import date_abstraction, { DateWrapper } from "@/libs/date_abstraction" | |
describe('UnpaidInvoicesFromDateQuery.constructor', () => { | |
it('stops prior batch queries to clear QB memory', () => { | |
const query = createTestingApi() | |
query.expectToStopPriorBatchQuery() | |
}) | |
it('keeps track of the current instance', () => { | |
const query = createTestingApi() | |
query.expectToKeepTrackOfCurrentInstance() | |
}) | |
it('saves the from date and batch size', () => { | |
const batch_size = 100 | |
const from_date = date_abstraction.oneYearAgo() | |
const query = createTestingApi(from_date, batch_size) | |
query.expectToSaveBatchSize(batch_size) | |
query.expectToSaveFromDate(from_date) | |
}) | |
it('creates a new query to find unpaid invoices by date', () => { | |
const query = createTestingApi() | |
query.expectToCreateUnpaidInvoicesBatchQuery() | |
}) | |
it('creates a new count unpaid invoices from date query', () => { | |
const query = createTestingApi() | |
query.expectToCreateCountUnpaidInvoicesQuery() | |
}) | |
}) | |
function createTestingApi( | |
from_date: DateWrapper = date_abstraction.oneYearAgo(), | |
batch_size: number = 100, | |
) { | |
return new UnpaidInvoicesFromDateQueryTapi( | |
qb_mock, from_date, batch_size | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment