Skip to content

Commit a0062be

Browse files
committed
Add wrapper around jest.it
Signed-off-by: Shubham Sharma <[email protected]>
1 parent d90140c commit a0062be

File tree

4 files changed

+62
-42
lines changed

4 files changed

+62
-42
lines changed

test/e2e/actors.http.test.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import DemoActorTimerImpl from '../actor/DemoActorTimerImpl';
99
import ActorId from '../../src/actors/ActorId';
1010
import ActorProxyBuilder from '../../src/actors/client/ActorProxyBuilder';
1111
import * as NodeJSUtil from '../../src/utils/NodeJS.util';
12+
import { testIt } from './utils';
1213

1314
const serverHost = "127.0.0.1";
1415
const serverPort = "50001";
@@ -54,7 +55,7 @@ describe('http/actors', () => {
5455
});
5556

5657
describe('actorProxy', () => {
57-
it('should be able to create an actor object through the proxy', async () => {
58+
testIt('should be able to create an actor object through the proxy', async () => {
5859
const builder = new ActorProxyBuilder<DemoActorCounterImpl>(DemoActorCounterImpl, client);
5960
const actor = builder.build(ActorId.createRandomId());
6061

@@ -72,7 +73,7 @@ describe('http/actors', () => {
7273
});
7374

7475
describe('invoke', () => {
75-
it('should register actors correctly', async () => {
76+
testIt('should register actors correctly', async () => {
7677
const actors = await server.actor.getRegisteredActors();
7778

7879
expect(actors.length).toEqual(6);
@@ -84,36 +85,36 @@ describe('http/actors', () => {
8485
expect(actors).toContain(DemoActorActivateImpl.name);
8586
});
8687

87-
it('should be able to invoke an actor through a text message', async () => {
88+
testIt('should be able to invoke an actor through a text message', async () => {
8889
const builder = new ActorProxyBuilder<DemoActorSayImpl>(DemoActorSayImpl, client);
8990
const actor = builder.build(ActorId.createRandomId());
9091
const res = await actor.sayString("Hello World");
9192
expect(res).toEqual(`Actor said: "Hello World"`)
9293
});
9394

94-
it('should be able to invoke an actor through an object message', async () => {
95+
testIt('should be able to invoke an actor through an object message', async () => {
9596
const builder = new ActorProxyBuilder<DemoActorSayImpl>(DemoActorSayImpl, client);
9697
const actor = builder.build(ActorId.createRandomId());
9798
const res = await actor.sayObject({ hello: "world" });
9899
expect(JSON.stringify(res)).toEqual(`{"said":{"hello":"world"}}`)
99100
});
100101

101-
it('should be able to invoke an actor through multiple parameters', async () => {
102+
testIt('should be able to invoke an actor through multiple parameters', async () => {
102103
const builder = new ActorProxyBuilder<DemoActorSayImpl>(DemoActorSayImpl, client);
103104
const actor = builder.build(ActorId.createRandomId());
104105
const res = await actor.sayMulti(123, "123", { hello: "world 123" }, [1, 2, 3]);
105106
expect(JSON.stringify(res)).toEqual(`{"a":{"value":123,"type":"number"},"b":{"value":"123","type":"string"},"c":{"value":{"hello":"world 123"},"type":"object"},"d":{"value":[1,2,3],"type":"object"}}`)
106107
});
107108

108-
it('should be able to invoke an actor through the client which abstracts the actor proxy builder for people unaware of patterns', async () => {
109+
testIt('should be able to invoke an actor through the client which abstracts the actor proxy builder for people unaware of patterns', async () => {
109110
const actor = client.actor.create<DemoActorSayImpl>(DemoActorSayImpl);
110111
const res = await actor.sayMulti(123, "123", { hello: "world 123" }, [1, 2, 3]);
111112
expect(JSON.stringify(res)).toEqual(`{"a":{"value":123,"type":"number"},"b":{"value":"123","type":"string"},"c":{"value":{"hello":"world 123"},"type":"object"},"d":{"value":[1,2,3],"type":"object"}}`)
112113
});
113114
});
114115

115116
describe('timers', () => {
116-
it('should fire a timer correctly (expected execution time > 5s)', async () => {
117+
testIt('should fire a timer correctly (expected execution time > 5s)', async () => {
117118
const builder = new ActorProxyBuilder<DemoActorTimerImpl>(DemoActorTimerImpl, client);
118119
const actor = builder.build(ActorId.createRandomId());
119120

@@ -152,7 +153,7 @@ describe('http/actors', () => {
152153
});
153154

154155
describe('reminders', () => {
155-
it('should be able to unregister a reminder', async () => {
156+
testIt('should be able to unregister a reminder', async () => {
156157
const builder = new ActorProxyBuilder<DemoActorReminderImpl>(DemoActorReminderImpl, client);
157158
const actor = builder.build(ActorId.createRandomId());
158159

@@ -181,7 +182,7 @@ describe('http/actors', () => {
181182
expect(res2).toEqual(123);
182183
});
183184

184-
it('should fire a reminder but with a warning if it\'s not implemented correctly', async () => {
185+
testIt('should fire a reminder but with a warning if it\'s not implemented correctly', async () => {
185186
const builder = new ActorProxyBuilder<DemoActorReminder2Impl>(DemoActorReminder2Impl, client);
186187
const actorId = ActorId.createRandomId();
187188
const actor = builder.build(actorId);

test/e2e/main.grpc.test.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { CommunicationProtocolEnum, DaprClient, DaprServer, HttpMethod } from '../../src';
2+
import { testIt } from './utils';
23

34
const serverHost = '127.0.0.1';
45
const serverPort = '50001';
@@ -33,15 +34,15 @@ describe('grpc/main', () => {
3334
});
3435

3536
describe('metadata', () => {
36-
it('should be able to get the metadata of the Dapr sidecar', async () => {
37+
testIt('should be able to get the metadata of the Dapr sidecar', async () => {
3738
await client.metadata.get();
3839

3940
// app id is not set in grpc?
4041
// expect(res.id.length).toBeGreaterThan(0);
4142
// expect(res.components.length).toBeGreaterThan(0);
4243
});
4344

44-
it('should be able to set a custom metadata value of the Dapr sidecar', async () => {
45+
testIt('should be able to set a custom metadata value of the Dapr sidecar', async () => {
4546
await client.metadata.set("testKey", "Hello World");
4647

4748
const res = await client.metadata.get();
@@ -55,14 +56,14 @@ describe('grpc/main', () => {
5556
});
5657

5758
describe('health', () => {
58-
it('should return true if Dapr is ready', async () => {
59+
testIt('should return true if Dapr is ready', async () => {
5960
const res = await client.health.isHealthy();
6061
expect(res).toEqual(true);
6162
});
6263
});
6364

6465
describe('binding', () => {
65-
it('should be able to receive events', async () => {
66+
testIt('should be able to receive events', async () => {
6667
await client.binding.send('binding-mqtt', 'create', { hello: 'world' });
6768

6869
// Delay a bit for event to arrive
@@ -76,7 +77,7 @@ describe('grpc/main', () => {
7677
});
7778

7879
describe('pubsub', () => {
79-
it('should be able to send and receive events', async () => {
80+
testIt('should be able to send and receive events', async () => {
8081
await client.pubsub.publish('pubsub-redis', 'test-topic', { hello: 'world' });
8182

8283
// Delay a bit for event to arrive
@@ -89,14 +90,14 @@ describe('grpc/main', () => {
8990
expect(mockPubSubSubscribe.mock.calls[0][0]['hello']).toEqual('world');
9091
});
9192

92-
it('should receive if it was successful or not', async () => {
93+
testIt('should receive if it was successful or not', async () => {
9394
const res = await client.pubsub.publish('pubsub-redis', 'test-topic', { hello: 'world' });
9495
expect(res).toEqual(true);
9596
});
9697
});
9798

9899
describe('invoker', () => {
99-
it('should be able to listen and invoke a service with GET', async () => {
100+
testIt('should be able to listen and invoke a service with GET', async () => {
100101
const mock = jest.fn(async (_data: object) => ({ hello: 'world' }));
101102

102103
await server.invoker.listen('hello-world', mock, { method: HttpMethod.GET });
@@ -109,7 +110,7 @@ describe('grpc/main', () => {
109110
expect(JSON.stringify(res)).toEqual(`{"hello":"world"}`);
110111
});
111112

112-
it('should be able to listen and invoke a service with POST data', async () => {
113+
testIt('should be able to listen and invoke a service with POST data', async () => {
113114
const mock = jest.fn(async (_data: object) => ({ hello: 'world' }));
114115

115116
await server.invoker.listen('hello-world', mock, { method: HttpMethod.POST });
@@ -126,19 +127,19 @@ describe('grpc/main', () => {
126127
});
127128

128129
describe('secrets', () => {
129-
it('should be able to correctly fetch the secrets by a single key', async () => {
130+
testIt('should be able to correctly fetch the secrets by a single key', async () => {
130131
const res = await client.secret.get('secret-envvars', 'TEST_SECRET_1');
131132
expect(JSON.stringify(res)).toEqual(`{"TEST_SECRET_1":"secret_val_1"}`);
132133
});
133134

134-
it('should be able to correctly fetch the secrets in bulk', async () => {
135+
testIt('should be able to correctly fetch the secrets in bulk', async () => {
135136
const res = await client.secret.getBulk('secret-envvars');
136137
expect(Object.keys(res).length).toBeGreaterThan(1);
137138
});
138139
});
139140

140141
describe('state', () => {
141-
it('should be able to save the state', async () => {
142+
testIt('should be able to save the state', async () => {
142143
await client.state.save('state-redis', [
143144
{
144145
key: 'key-1',
@@ -158,7 +159,7 @@ describe('grpc/main', () => {
158159
expect(res).toEqual('value-1');
159160
});
160161

161-
it('should be able to get the state in bulk', async () => {
162+
testIt('should be able to get the state in bulk', async () => {
162163
await client.state.save('state-redis', [
163164
{
164165
key: 'key-1',
@@ -184,7 +185,7 @@ describe('grpc/main', () => {
184185
);
185186
});
186187

187-
it('should be able to delete a key from the state store', async () => {
188+
testIt('should be able to delete a key from the state store', async () => {
188189
await client.state.save('state-redis', [
189190
{
190191
key: 'key-1',
@@ -205,7 +206,7 @@ describe('grpc/main', () => {
205206
expect(res).toEqual('');
206207
});
207208

208-
it('should be able to perform a transaction that replaces a key and deletes another', async () => {
209+
testIt('should be able to perform a transaction that replaces a key and deletes another', async () => {
209210
await client.state.transaction('state-redis', [
210211
{
211212
operation: 'upsert',
@@ -228,7 +229,7 @@ describe('grpc/main', () => {
228229
expect(resTransactionUpsert).toEqual('my-new-data-1');
229230
});
230231

231-
it('should be able to perform a transaction with metadata', async () => {
232+
testIt('should be able to perform a transaction with metadata', async () => {
232233
await client.state.transaction('state-redis', [
233234
{
234235
operation: 'upsert',
@@ -256,7 +257,7 @@ describe('grpc/main', () => {
256257

257258
// Note: actors require an external dependency and are disabled by default for now until we can have actors in Javascript
258259
// describe('actors', () => {
259-
// it('should be able to invoke a method on an actor', async () => {
260+
// testIt('should be able to invoke a method on an actor', async () => {
260261
// const clientActor = new DaprClient(daprHost, daprPortActor);
261262

262263
// await clientActor.actor.invoke("POST", "DemoActor", "MyActorId1", "SetDataAsync", { PropertyA: "hello", PropertyB: "world", ToNotExistKey: "this should not exist since we only have PropertyA and PropertyB" });
@@ -265,7 +266,7 @@ describe('grpc/main', () => {
265266
// expect(JSON.stringify(res)).toEqual(`{\"propertyA\":\"hello\",\"propertyB\":\"world\"}`);
266267
// });
267268

268-
// it('should be able to manipulate the state through a transaction of an actor', async () => {
269+
// testIt('should be able to manipulate the state through a transaction of an actor', async () => {
269270
// const clientActor = new DaprClient(daprHost, daprPortActor);
270271
// await clientActor.actor.stateTransaction("DemoActor", "MyActorId1", [
271272
// {
@@ -297,7 +298,7 @@ describe('grpc/main', () => {
297298
// expect(JSON.stringify(resActorStateGet2)).toEqual(`\"my-new-data-1\"`);
298299
// });
299300

300-
// it('should be able to get all the actors', async () => {
301+
// testIt('should be able to get all the actors', async () => {
301302
// const clientActor = new DaprClient(daprHost, daprPortActor);
302303

303304
// const res = await clientActor.actor.getActors();

test/e2e/main.http.test.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { CommunicationProtocolEnum, DaprClient, DaprServer, HttpMethod } from '../../src';
2+
import { testIt } from './utils';
23

34
const serverHost = '127.0.0.1';
45
const serverPort = '50001';
@@ -38,14 +39,19 @@ describe('http/main', () => {
3839
});
3940

4041
describe('metadata', () => {
41-
it('should be able to get the metadata of the Dapr sidecar', async () => {
42+
// TODO: remove
43+
testIt('this will fail', () => {
44+
expect(false).toBe(true);
45+
});
46+
47+
testIt('should be able to get the metadata of the Dapr sidecar', async () => {
4248
const res = await client.metadata.get();
4349

4450
expect(res.id.length).toBeGreaterThan(0);
4551
expect(res.components.length).toBeGreaterThan(0);
4652
});
4753

48-
it('should be able to set a custom metadata value of the Dapr sidecar', async () => {
54+
testIt('should be able to set a custom metadata value of the Dapr sidecar', async () => {
4955
await client.metadata.set("testKey", "Hello World");
5056

5157
const res = await client.metadata.get();
@@ -57,14 +63,14 @@ describe('http/main', () => {
5763
});
5864

5965
describe('health', () => {
60-
it('should return true if Dapr is ready', async () => {
66+
testIt('should return true if Dapr is ready', async () => {
6167
const res = await client.health.isHealthy();
6268
expect(res).toEqual(true);
6369
});
6470
});
6571

6672
describe('binding', () => {
67-
it('should be able to receive events', async () => {
73+
testIt('should be able to receive events', async () => {
6874
await client.binding.send('binding-mqtt', 'create', { hello: 'world' });
6975

7076
// Delay a bit for event to arrive
@@ -78,7 +84,7 @@ describe('http/main', () => {
7884
});
7985

8086
describe('pubsub', () => {
81-
it('should be able to send and receive events', async () => {
87+
testIt('should be able to send and receive events', async () => {
8288
await client.pubsub.publish('pubsub-redis', 'test-topic', { hello: 'world' });
8389

8490
// Delay a bit for event to arrive
@@ -91,14 +97,14 @@ describe('http/main', () => {
9197
expect(mockPubSubSubscribe.mock.calls[0][0]['hello']).toEqual('world');
9298
});
9399

94-
it('should receive if it was successful or not', async () => {
100+
testIt('should receive if it was successful or not', async () => {
95101
const res = await client.pubsub.publish('pubsub-redis', 'test-topic', { hello: 'world' });
96102
expect(res).toEqual(true);
97103
});
98104
});
99105

100106
describe('invoker', () => {
101-
it('should be able to listen and invoke a service with GET', async () => {
107+
testIt('should be able to listen and invoke a service with GET', async () => {
102108
const mock = jest.fn(async (_data: object) => ({ hello: 'world' }));
103109

104110
await server.invoker.listen('hello-world', mock, { method: HttpMethod.GET });
@@ -111,7 +117,7 @@ describe('http/main', () => {
111117
expect(JSON.stringify(res)).toEqual(`{"hello":"world"}`);
112118
});
113119

114-
it('should be able to listen and invoke a service with POST data', async () => {
120+
testIt('should be able to listen and invoke a service with POST data', async () => {
115121
const mock = jest.fn(async (_data: object) => ({ hello: 'world' }));
116122

117123
await server.invoker.listen('hello-world', mock, { method: HttpMethod.POST });
@@ -128,19 +134,19 @@ describe('http/main', () => {
128134
});
129135

130136
describe('secrets', () => {
131-
it('should be able to correctly fetch the secrets by a single key', async () => {
137+
testIt('should be able to correctly fetch the secrets by a single key', async () => {
132138
const res = await client.secret.get('secret-envvars', 'TEST_SECRET_1');
133139
expect(JSON.stringify(res)).toEqual(`{"TEST_SECRET_1":"secret_val_1"}`);
134140
});
135141

136-
it('should be able to correctly fetch the secrets in bulk', async () => {
142+
testIt('should be able to correctly fetch the secrets in bulk', async () => {
137143
const res = await client.secret.getBulk('secret-envvars');
138144
expect(Object.keys(res).length).toBeGreaterThan(1);
139145
});
140146
});
141147

142148
describe('state', () => {
143-
it('should be able to save the state', async () => {
149+
testIt('should be able to save the state', async () => {
144150
await client.state.save('state-redis', [
145151
{
146152
key: 'key-1',
@@ -160,7 +166,7 @@ describe('http/main', () => {
160166
expect(res).toEqual('value-1');
161167
});
162168

163-
it('should be able to get the state in bulk', async () => {
169+
testIt('should be able to get the state in bulk', async () => {
164170
await client.state.save('state-redis', [
165171
{
166172
key: 'key-1',
@@ -186,7 +192,7 @@ describe('http/main', () => {
186192
);
187193
});
188194

189-
it('should be able to delete a key from the state store', async () => {
195+
testIt('should be able to delete a key from the state store', async () => {
190196
await client.state.save('state-redis', [
191197
{
192198
key: 'key-1',
@@ -207,7 +213,7 @@ describe('http/main', () => {
207213
expect(res).toEqual('');
208214
});
209215

210-
it('should be able to perform a transaction that replaces a key and deletes another', async () => {
216+
testIt('should be able to perform a transaction that replaces a key and deletes another', async () => {
211217
await client.state.transaction('state-redis', [
212218
{
213219
operation: 'upsert',
@@ -230,7 +236,7 @@ describe('http/main', () => {
230236
expect(resTransactionUpsert).toEqual('my-new-data-1');
231237
});
232238

233-
it('should be able to query state', async () => {
239+
testIt('should be able to query state', async () => {
234240
// First save our data
235241
await client.state.save("state-mongodb", [
236242
{

0 commit comments

Comments
 (0)