@orieljs/testing 0.1.0-alpha.15 → 0.1.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -1
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Application, ModelInstance, InertiaPage, Encrypter, Session, View, Authenticatable, Container, AuthFactory, ServiceProvider, ServiceProviderClass, DatabaseManager, Row, ExceptionHandler, ViewFactory, Class, Token, EventDispatcher, Listener, PendingBatchOptions, Job, BusDispatcher, PendingChain, PendingBatch, Batch, QueuePayload, QueueManager, Queue, QueueJob, MailManager, Mailable, Address, MailRecipient, Mailer, PendingMail, SentMessage, MailTransport, Notifiable, NotificationDispatcher, Notification, NotificationChannel, Filesystem, PutOptions, UploadedFile, FilesystemManager } from '@orieljs/contracts';
|
|
1
|
+
import { Application, ModelInstance, InertiaPage, Encrypter, Session, View, Authenticatable, Container, AuthFactory, ServiceProvider, ServiceProviderClass, DatabaseManager, Row, ExceptionHandler, ViewFactory, Class, Token, EventDispatcher, Listener, PendingBatchOptions, Job, BusDispatcher, PendingChain, PendingBatch, Batch, QueuePayload, QueueManager, Queue, QueueJob, QueueJobEvent, QueueJobFailedEvent, MailManager, Mailable, Address, MailRecipient, Mailer, PendingMail, SentMessage, MailTransport, Notifiable, NotificationDispatcher, Notification, NotificationChannel, Filesystem, PutOptions, UploadedFile, FilesystemManager } from '@orieljs/contracts';
|
|
2
2
|
|
|
3
3
|
/** A date the tests travel to: a Date, an ISO string or milliseconds since the epoch. */
|
|
4
4
|
type TravelDate = Date | string | number;
|
|
@@ -868,6 +868,10 @@ declare class QueueFake implements QueueManager {
|
|
|
868
868
|
/** Removes the jobs size() counts and returns how many. */
|
|
869
869
|
clear(queue?: string): Promise<number>;
|
|
870
870
|
extend(_driver: string, _factory: (config: Record<string, unknown>) => Queue): void;
|
|
871
|
+
/** The real manager's, so a job pushed past the fake still reaches the callback. */
|
|
872
|
+
before(callback: (event: QueueJobEvent) => unknown): void;
|
|
873
|
+
after(callback: (event: QueueJobEvent) => unknown): void;
|
|
874
|
+
failing(callback: (event: QueueJobFailedEvent) => unknown): void;
|
|
871
875
|
/** Pushed at least once; a number asserts the count; a filter gets (job, queue, connection). */
|
|
872
876
|
assertPushed<J extends Job>(job: Target<J>, callback?: CountOrFilter<[J, string | undefined, string | undefined]>): void;
|
|
873
877
|
assertPushedTimes<J extends Job>(job: Target<J>, times?: number): void;
|
package/dist/index.js
CHANGED
|
@@ -465,7 +465,10 @@ function connectionsOf(test) {
|
|
|
465
465
|
}
|
|
466
466
|
async function beginTransactions(test, connections) {
|
|
467
467
|
const levels = connections.map((connection) => connection.transactionLevel());
|
|
468
|
-
for (const connection of connections)
|
|
468
|
+
for (const connection of connections) {
|
|
469
|
+
await connection.beginTransaction();
|
|
470
|
+
connection.ignoreAfterCommitAtCurrentLevel?.();
|
|
471
|
+
}
|
|
469
472
|
test.beforeApplicationDestroyed(async () => {
|
|
470
473
|
for (const [index, connection] of [...connections.entries()].reverse()) await rollBackTo(connection, levels[index] ?? 0);
|
|
471
474
|
});
|
|
@@ -2749,6 +2752,16 @@ var QueueFake = class _QueueFake {
|
|
|
2749
2752
|
}
|
|
2750
2753
|
extend(_driver, _factory) {
|
|
2751
2754
|
}
|
|
2755
|
+
/** The real manager's, so a job pushed past the fake still reaches the callback. */
|
|
2756
|
+
before(callback) {
|
|
2757
|
+
this.manager?.before(callback);
|
|
2758
|
+
}
|
|
2759
|
+
after(callback) {
|
|
2760
|
+
this.manager?.after(callback);
|
|
2761
|
+
}
|
|
2762
|
+
failing(callback) {
|
|
2763
|
+
this.manager?.failing(callback);
|
|
2764
|
+
}
|
|
2752
2765
|
// Assertions ---------------------------------------------------------------------------------------------
|
|
2753
2766
|
/** Pushed at least once; a number asserts the count; a filter gets (job, queue, connection). */
|
|
2754
2767
|
assertPushed(job, callback) {
|