@nest-yalc-2/api-strategy 2.2.2 → 2.2.4
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/package.json +5 -3
- package/src/__tests__/call-strategy-wrappers.spec.ts +217 -217
- package/src/__tests__/context-call.service.spec.ts +52 -52
- package/src/__tests__/context-event.service.spec.ts +52 -52
- package/src/__tests__/event-strategy-composition.spec.ts +185 -185
- package/src/__tests__/header-whitelist.helper.spec.ts +41 -30
- package/src/__tests__/http-abstract-call.strategy.spec.ts +17 -17
- package/src/__tests__/nest-http-call.strategy.spec.ts +164 -164
- package/src/__tests__/nest-local-call.strategy.spec.ts +263 -263
- package/src/__tests__/nest-local-event.strategy.spec.ts +55 -55
- package/src/__tests__/rabbitmq-event.strategy.spec.ts +220 -220
- package/src/__tests__/strategy-selector.provider.spec.ts +182 -182
- package/src/context-call.interface.ts +49 -49
- package/src/context-call.service.ts +31 -31
- package/src/context-event.interface.ts +4 -4
- package/src/context-event.service.ts +31 -31
- package/src/header-whitelist.helper.ts +12 -12
- package/src/index.ts +17 -17
- package/src/strategies/composite-event.strategy.ts +76 -76
- package/src/strategies/conditional-call.strategy.ts +70 -70
- package/src/strategies/conditional-event.strategy.ts +54 -54
- package/src/strategies/fallback-call.strategy.ts +67 -67
- package/src/strategies/http-abstract-call.strategy.ts +238 -238
- package/src/strategies/nest-http-call.strategy.ts +121 -121
- package/src/strategies/nest-local-call.strategy.ts +153 -153
- package/src/strategies/nest-local-event.strategy.d.ts +1 -1
- package/src/strategies/nest-local-event.strategy.ts +42 -42
- package/src/strategies/rabbitmq-event.strategy.ts +154 -154
- package/src/strategies/shadow-call.strategy.ts +87 -87
- package/src/strategy-selector.provider.ts +103 -103
|
@@ -1,220 +1,220 @@
|
|
|
1
|
-
import { jest, beforeEach, describe, expect, it } from "@jest/globals";
|
|
2
|
-
import { createMock } from "@golevelup/ts-jest";
|
|
3
|
-
import { EventEmitter2 } from "@nestjs/event-emitter";
|
|
4
|
-
import amqp from "amqplib";
|
|
5
|
-
import { RabbitMqEventStrategy, RabbitMqEventStrategyProvider } from "../strategies/rabbitmq-event.strategy.js";
|
|
6
|
-
|
|
7
|
-
const publish = jest.fn(() => true);
|
|
8
|
-
const assertExchange = jest.fn();
|
|
9
|
-
const channelClose = jest.fn();
|
|
10
|
-
const connectionClose = jest.fn();
|
|
11
|
-
const createChannel = jest.fn();
|
|
12
|
-
const connect = jest.spyOn(amqp, 'connect' as never) as unknown as jest.Mock;
|
|
13
|
-
|
|
14
|
-
describe("RabbitMqEventStrategy", () => {
|
|
15
|
-
let eventEmitter: EventEmitter2;
|
|
16
|
-
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
jest.clearAllMocks();
|
|
19
|
-
|
|
20
|
-
eventEmitter = createMock<EventEmitter2>({
|
|
21
|
-
emit: jest.fn(() => true),
|
|
22
|
-
emitAsync: jest.fn(() => Promise.resolve([])),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
publish.mockReturnValue(true);
|
|
26
|
-
assertExchange.mockResolvedValue(undefined as never);
|
|
27
|
-
channelClose.mockResolvedValue(undefined as never);
|
|
28
|
-
connectionClose.mockResolvedValue(undefined as never);
|
|
29
|
-
createChannel.mockResolvedValue({
|
|
30
|
-
assertExchange,
|
|
31
|
-
publish,
|
|
32
|
-
close: channelClose,
|
|
33
|
-
} as never);
|
|
34
|
-
connect.mockResolvedValue({
|
|
35
|
-
createChannel,
|
|
36
|
-
close: connectionClose,
|
|
37
|
-
} as never);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("publishes to RabbitMQ asynchronously", async () => {
|
|
41
|
-
const strategy = new RabbitMqEventStrategy({
|
|
42
|
-
url: "amqp://localhost",
|
|
43
|
-
exchange: "test.events",
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const result = await strategy.emitAsync("task.created", { id: "task-1" });
|
|
47
|
-
|
|
48
|
-
expect(result).toBe(true);
|
|
49
|
-
expect(eventEmitter.emitAsync).not.toHaveBeenCalled();
|
|
50
|
-
expect(connect).toHaveBeenCalledWith("amqp://localhost");
|
|
51
|
-
expect(assertExchange).toHaveBeenCalledWith("test.events", "topic", {
|
|
52
|
-
durable: true,
|
|
53
|
-
});
|
|
54
|
-
expect(publish).toHaveBeenCalledWith(
|
|
55
|
-
"test.events",
|
|
56
|
-
"task.created",
|
|
57
|
-
Buffer.from(JSON.stringify({ id: "task-1" })),
|
|
58
|
-
{
|
|
59
|
-
contentType: "application/json",
|
|
60
|
-
persistent: true,
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("uses custom broker options and buffer serialization", async () => {
|
|
66
|
-
const body = Buffer.from("encoded");
|
|
67
|
-
const strategy = new RabbitMqEventStrategy({
|
|
68
|
-
url: "amqp://localhost",
|
|
69
|
-
exchange: "test.events",
|
|
70
|
-
exchangeType: "fanout",
|
|
71
|
-
durable: false,
|
|
72
|
-
persistent: false,
|
|
73
|
-
contentType: "application/custom",
|
|
74
|
-
publishOptions: {
|
|
75
|
-
expiration: "1000",
|
|
76
|
-
},
|
|
77
|
-
serialize: () => body,
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
await strategy.emitAsync("task.created", { id: "task-1" });
|
|
81
|
-
|
|
82
|
-
expect(assertExchange).toHaveBeenCalledWith("test.events", "fanout", {
|
|
83
|
-
durable: false,
|
|
84
|
-
});
|
|
85
|
-
expect(publish).toHaveBeenCalledWith("test.events", "task.created", body, {
|
|
86
|
-
contentType: "application/custom",
|
|
87
|
-
persistent: false,
|
|
88
|
-
expiration: "1000",
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("reuses the open RabbitMQ channel", async () => {
|
|
93
|
-
const strategy = new RabbitMqEventStrategy({
|
|
94
|
-
url: "amqp://localhost",
|
|
95
|
-
exchange: "test.events",
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
await strategy.emitAsync("task.created", { id: "task-1" });
|
|
99
|
-
await strategy.emitAsync("task.updated", { id: "task-1" });
|
|
100
|
-
|
|
101
|
-
expect(connect).toHaveBeenCalledTimes(1);
|
|
102
|
-
expect(createChannel).toHaveBeenCalledTimes(1);
|
|
103
|
-
expect(publish).toHaveBeenCalledTimes(2);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("publishes in the background for sync emit", async () => {
|
|
107
|
-
const strategy = new RabbitMqEventStrategy({
|
|
108
|
-
url: "amqp://localhost",
|
|
109
|
-
exchange: "test.events",
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const result = strategy.emit("task.created", { id: "task-1" });
|
|
113
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
114
|
-
|
|
115
|
-
expect(result).toBe(true);
|
|
116
|
-
expect(eventEmitter.emit).not.toHaveBeenCalled();
|
|
117
|
-
expect(publish).toHaveBeenCalled();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("does not fail sync emit when background publishing fails", async () => {
|
|
121
|
-
const strategy = new RabbitMqEventStrategy({
|
|
122
|
-
url: "amqp://localhost",
|
|
123
|
-
exchange: "test.events",
|
|
124
|
-
});
|
|
125
|
-
connect.mockRejectedValueOnce(new Error("publish failed") as never);
|
|
126
|
-
|
|
127
|
-
const result = strategy.emit("task.created", { id: "task-1" });
|
|
128
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
129
|
-
|
|
130
|
-
expect(result).toBe(true);
|
|
131
|
-
expect(connect).toHaveBeenCalled();
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("closes RabbitMQ resources on module destroy", async () => {
|
|
135
|
-
const strategy = new RabbitMqEventStrategy({
|
|
136
|
-
url: "amqp://localhost",
|
|
137
|
-
exchange: "test.events",
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
await strategy.emitAsync("task.created", { id: "task-1" });
|
|
141
|
-
await strategy.onModuleDestroy();
|
|
142
|
-
|
|
143
|
-
expect(channelClose).toHaveBeenCalled();
|
|
144
|
-
expect(connectionClose).toHaveBeenCalled();
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("ignores closing errors on module destroy", async () => {
|
|
148
|
-
const strategy = new RabbitMqEventStrategy({
|
|
149
|
-
url: "amqp://localhost",
|
|
150
|
-
exchange: "test.events",
|
|
151
|
-
});
|
|
152
|
-
channelClose.mockRejectedValue(new Error("already closing") as never);
|
|
153
|
-
connectionClose.mockRejectedValue(new Error("connection closing") as never);
|
|
154
|
-
|
|
155
|
-
await strategy.emitAsync("task.created", { id: "task-1" });
|
|
156
|
-
|
|
157
|
-
await expect(strategy.onModuleDestroy()).resolves.toBeUndefined();
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it("ignores synchronous closing errors on module destroy", async () => {
|
|
161
|
-
const strategy = new RabbitMqEventStrategy({
|
|
162
|
-
url: "amqp://localhost",
|
|
163
|
-
exchange: "test.events",
|
|
164
|
-
});
|
|
165
|
-
channelClose.mockImplementationOnce(() => {
|
|
166
|
-
throw new Error("already closing");
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
await strategy.emitAsync("task.created", { id: "task-1" });
|
|
170
|
-
|
|
171
|
-
await expect(strategy.onModuleDestroy()).resolves.toBeUndefined();
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it("throws unexpected close errors on module destroy", async () => {
|
|
175
|
-
const strategy = new RabbitMqEventStrategy({
|
|
176
|
-
url: "amqp://localhost",
|
|
177
|
-
exchange: "test.events",
|
|
178
|
-
});
|
|
179
|
-
channelClose.mockRejectedValue(new Error("boom") as never);
|
|
180
|
-
|
|
181
|
-
await strategy.emitAsync("task.created", { id: "task-1" });
|
|
182
|
-
|
|
183
|
-
await expect(strategy.onModuleDestroy()).rejects.toThrow("boom");
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it("does not close RabbitMQ resources before a connection is opened", async () => {
|
|
187
|
-
const strategy = new RabbitMqEventStrategy({
|
|
188
|
-
url: "amqp://localhost",
|
|
189
|
-
exchange: "test.events",
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
await strategy.onModuleDestroy();
|
|
193
|
-
|
|
194
|
-
expect(channelClose).not.toHaveBeenCalled();
|
|
195
|
-
expect(connectionClose).not.toHaveBeenCalled();
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it("creates a provider", () => {
|
|
199
|
-
const provider = RabbitMqEventStrategyProvider("test", {
|
|
200
|
-
options: {
|
|
201
|
-
url: "amqp://localhost",
|
|
202
|
-
exchange: "test.events",
|
|
203
|
-
},
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
expect(provider).toBeDefined();
|
|
207
|
-
expect(provider.useFactory()).toBeDefined();
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it("creates a provider with an options factory", () => {
|
|
211
|
-
const provider = RabbitMqEventStrategyProvider("test", {
|
|
212
|
-
options: () => ({
|
|
213
|
-
url: "amqp://localhost",
|
|
214
|
-
exchange: "test.events",
|
|
215
|
-
}),
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
expect(provider.useFactory()).toBeDefined();
|
|
219
|
-
});
|
|
220
|
-
});
|
|
1
|
+
import { jest, beforeEach, describe, expect, it } from "@jest/globals";
|
|
2
|
+
import { createMock } from "@golevelup/ts-jest";
|
|
3
|
+
import { EventEmitter2 } from "@nestjs/event-emitter";
|
|
4
|
+
import amqp from "amqplib";
|
|
5
|
+
import { RabbitMqEventStrategy, RabbitMqEventStrategyProvider } from "../strategies/rabbitmq-event.strategy.js";
|
|
6
|
+
|
|
7
|
+
const publish = jest.fn(() => true);
|
|
8
|
+
const assertExchange = jest.fn();
|
|
9
|
+
const channelClose = jest.fn();
|
|
10
|
+
const connectionClose = jest.fn();
|
|
11
|
+
const createChannel = jest.fn();
|
|
12
|
+
const connect = jest.spyOn(amqp, 'connect' as never) as unknown as jest.Mock;
|
|
13
|
+
|
|
14
|
+
describe("RabbitMqEventStrategy", () => {
|
|
15
|
+
let eventEmitter: EventEmitter2;
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
jest.clearAllMocks();
|
|
19
|
+
|
|
20
|
+
eventEmitter = createMock<EventEmitter2>({
|
|
21
|
+
emit: jest.fn(() => true),
|
|
22
|
+
emitAsync: jest.fn(() => Promise.resolve([])),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
publish.mockReturnValue(true);
|
|
26
|
+
assertExchange.mockResolvedValue(undefined as never);
|
|
27
|
+
channelClose.mockResolvedValue(undefined as never);
|
|
28
|
+
connectionClose.mockResolvedValue(undefined as never);
|
|
29
|
+
createChannel.mockResolvedValue({
|
|
30
|
+
assertExchange,
|
|
31
|
+
publish,
|
|
32
|
+
close: channelClose,
|
|
33
|
+
} as never);
|
|
34
|
+
connect.mockResolvedValue({
|
|
35
|
+
createChannel,
|
|
36
|
+
close: connectionClose,
|
|
37
|
+
} as never);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("publishes to RabbitMQ asynchronously", async () => {
|
|
41
|
+
const strategy = new RabbitMqEventStrategy({
|
|
42
|
+
url: "amqp://localhost",
|
|
43
|
+
exchange: "test.events",
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const result = await strategy.emitAsync("task.created", { id: "task-1" });
|
|
47
|
+
|
|
48
|
+
expect(result).toBe(true);
|
|
49
|
+
expect(eventEmitter.emitAsync).not.toHaveBeenCalled();
|
|
50
|
+
expect(connect).toHaveBeenCalledWith("amqp://localhost");
|
|
51
|
+
expect(assertExchange).toHaveBeenCalledWith("test.events", "topic", {
|
|
52
|
+
durable: true,
|
|
53
|
+
});
|
|
54
|
+
expect(publish).toHaveBeenCalledWith(
|
|
55
|
+
"test.events",
|
|
56
|
+
"task.created",
|
|
57
|
+
Buffer.from(JSON.stringify({ id: "task-1" })),
|
|
58
|
+
{
|
|
59
|
+
contentType: "application/json",
|
|
60
|
+
persistent: true,
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("uses custom broker options and buffer serialization", async () => {
|
|
66
|
+
const body = Buffer.from("encoded");
|
|
67
|
+
const strategy = new RabbitMqEventStrategy({
|
|
68
|
+
url: "amqp://localhost",
|
|
69
|
+
exchange: "test.events",
|
|
70
|
+
exchangeType: "fanout",
|
|
71
|
+
durable: false,
|
|
72
|
+
persistent: false,
|
|
73
|
+
contentType: "application/custom",
|
|
74
|
+
publishOptions: {
|
|
75
|
+
expiration: "1000",
|
|
76
|
+
},
|
|
77
|
+
serialize: () => body,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
await strategy.emitAsync("task.created", { id: "task-1" });
|
|
81
|
+
|
|
82
|
+
expect(assertExchange).toHaveBeenCalledWith("test.events", "fanout", {
|
|
83
|
+
durable: false,
|
|
84
|
+
});
|
|
85
|
+
expect(publish).toHaveBeenCalledWith("test.events", "task.created", body, {
|
|
86
|
+
contentType: "application/custom",
|
|
87
|
+
persistent: false,
|
|
88
|
+
expiration: "1000",
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("reuses the open RabbitMQ channel", async () => {
|
|
93
|
+
const strategy = new RabbitMqEventStrategy({
|
|
94
|
+
url: "amqp://localhost",
|
|
95
|
+
exchange: "test.events",
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
await strategy.emitAsync("task.created", { id: "task-1" });
|
|
99
|
+
await strategy.emitAsync("task.updated", { id: "task-1" });
|
|
100
|
+
|
|
101
|
+
expect(connect).toHaveBeenCalledTimes(1);
|
|
102
|
+
expect(createChannel).toHaveBeenCalledTimes(1);
|
|
103
|
+
expect(publish).toHaveBeenCalledTimes(2);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("publishes in the background for sync emit", async () => {
|
|
107
|
+
const strategy = new RabbitMqEventStrategy({
|
|
108
|
+
url: "amqp://localhost",
|
|
109
|
+
exchange: "test.events",
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const result = strategy.emit("task.created", { id: "task-1" });
|
|
113
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
114
|
+
|
|
115
|
+
expect(result).toBe(true);
|
|
116
|
+
expect(eventEmitter.emit).not.toHaveBeenCalled();
|
|
117
|
+
expect(publish).toHaveBeenCalled();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("does not fail sync emit when background publishing fails", async () => {
|
|
121
|
+
const strategy = new RabbitMqEventStrategy({
|
|
122
|
+
url: "amqp://localhost",
|
|
123
|
+
exchange: "test.events",
|
|
124
|
+
});
|
|
125
|
+
connect.mockRejectedValueOnce(new Error("publish failed") as never);
|
|
126
|
+
|
|
127
|
+
const result = strategy.emit("task.created", { id: "task-1" });
|
|
128
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
129
|
+
|
|
130
|
+
expect(result).toBe(true);
|
|
131
|
+
expect(connect).toHaveBeenCalled();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("closes RabbitMQ resources on module destroy", async () => {
|
|
135
|
+
const strategy = new RabbitMqEventStrategy({
|
|
136
|
+
url: "amqp://localhost",
|
|
137
|
+
exchange: "test.events",
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
await strategy.emitAsync("task.created", { id: "task-1" });
|
|
141
|
+
await strategy.onModuleDestroy();
|
|
142
|
+
|
|
143
|
+
expect(channelClose).toHaveBeenCalled();
|
|
144
|
+
expect(connectionClose).toHaveBeenCalled();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("ignores closing errors on module destroy", async () => {
|
|
148
|
+
const strategy = new RabbitMqEventStrategy({
|
|
149
|
+
url: "amqp://localhost",
|
|
150
|
+
exchange: "test.events",
|
|
151
|
+
});
|
|
152
|
+
channelClose.mockRejectedValue(new Error("already closing") as never);
|
|
153
|
+
connectionClose.mockRejectedValue(new Error("connection closing") as never);
|
|
154
|
+
|
|
155
|
+
await strategy.emitAsync("task.created", { id: "task-1" });
|
|
156
|
+
|
|
157
|
+
await expect(strategy.onModuleDestroy()).resolves.toBeUndefined();
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("ignores synchronous closing errors on module destroy", async () => {
|
|
161
|
+
const strategy = new RabbitMqEventStrategy({
|
|
162
|
+
url: "amqp://localhost",
|
|
163
|
+
exchange: "test.events",
|
|
164
|
+
});
|
|
165
|
+
channelClose.mockImplementationOnce(() => {
|
|
166
|
+
throw new Error("already closing");
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
await strategy.emitAsync("task.created", { id: "task-1" });
|
|
170
|
+
|
|
171
|
+
await expect(strategy.onModuleDestroy()).resolves.toBeUndefined();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("throws unexpected close errors on module destroy", async () => {
|
|
175
|
+
const strategy = new RabbitMqEventStrategy({
|
|
176
|
+
url: "amqp://localhost",
|
|
177
|
+
exchange: "test.events",
|
|
178
|
+
});
|
|
179
|
+
channelClose.mockRejectedValue(new Error("boom") as never);
|
|
180
|
+
|
|
181
|
+
await strategy.emitAsync("task.created", { id: "task-1" });
|
|
182
|
+
|
|
183
|
+
await expect(strategy.onModuleDestroy()).rejects.toThrow("boom");
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("does not close RabbitMQ resources before a connection is opened", async () => {
|
|
187
|
+
const strategy = new RabbitMqEventStrategy({
|
|
188
|
+
url: "amqp://localhost",
|
|
189
|
+
exchange: "test.events",
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
await strategy.onModuleDestroy();
|
|
193
|
+
|
|
194
|
+
expect(channelClose).not.toHaveBeenCalled();
|
|
195
|
+
expect(connectionClose).not.toHaveBeenCalled();
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it("creates a provider", () => {
|
|
199
|
+
const provider = RabbitMqEventStrategyProvider("test", {
|
|
200
|
+
options: {
|
|
201
|
+
url: "amqp://localhost",
|
|
202
|
+
exchange: "test.events",
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
expect(provider).toBeDefined();
|
|
207
|
+
expect(provider.useFactory()).toBeDefined();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it("creates a provider with an options factory", () => {
|
|
211
|
+
const provider = RabbitMqEventStrategyProvider("test", {
|
|
212
|
+
options: () => ({
|
|
213
|
+
url: "amqp://localhost",
|
|
214
|
+
exchange: "test.events",
|
|
215
|
+
}),
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
expect(provider.useFactory()).toBeDefined();
|
|
219
|
+
});
|
|
220
|
+
});
|