Skip to content

Commit 2dd88b8

Browse files
committed
tests(angular): awaiting promises
Signed-off-by: Vojtech Mašek <[email protected]>
1 parent 26473d8 commit 2dd88b8

File tree

3 files changed

+26
-137
lines changed

3 files changed

+26
-137
lines changed

tests/test-angular-project/src/api-tests/api-client.module.spec.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,28 @@ describe('APIClientModule', () => {
1919
});
2020
});
2121

22-
it('should provide APIClient', inject([APIClient], (apiClient: APIClient) => {
23-
expect(apiClient).toBeTruthy();
24-
}));
22+
it('should provide APIClient',
23+
inject([APIClient], async (apiClient: APIClient) => {
24+
await expect(apiClient).toBeTruthy();
25+
})
26+
);
2527

26-
it('should have domain set to current hostname and port', inject([APIClient], (apiClient: APIClient) => {
27-
expect(apiClient.domain).toBe(`//${window.location.hostname}${window.location.port ? ':'+window.location.port : ''}`);
28-
}));
28+
it('should have domain set to current hostname and port',
29+
inject([APIClient], (apiClient: APIClient) => {
30+
expect(apiClient.domain).toBe(`//${window.location.hostname}${window.location.port ? ':' + window.location.port : ''}`);
31+
})
32+
);
2933

30-
it('should have header set', inject([APIClient], (apiClient: APIClient) => {
31-
expect(apiClient.options.headers.getAll('testHeader')).toEqual(['42']);
32-
}));
34+
it('should have header set',
35+
inject([APIClient], (apiClient: APIClient) => {
36+
expect(apiClient.options.headers.getAll('testHeader')).toEqual(['42']);
37+
})
38+
);
3339

34-
it('should not have params set', inject([APIClient], (apiClient: APIClient) => {
35-
// if params are not set they equal to new empty http params
36-
expect(apiClient.options.params).toEqual(new HttpParams());
37-
}));
40+
it('should not have params set',
41+
inject([APIClient], async (apiClient: APIClient) => {
42+
// if params are not set they equal to new empty http params
43+
await expect(apiClient.options.params).toEqual(new HttpParams());
44+
})
45+
);
3846
});

tests/test-angular-project/src/api-tests/user.service.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ describe('UserService', () => {
1515
});
1616
});
1717

18-
it('should be initialized', inject([UserAPIClient], (userApi: UserAPIClient) => {
19-
expect(userApi).toBeTruthy();
20-
expect(userApi.domain).toBe(DUMMY_DOMAIN);
18+
it('should be initialized', inject([UserAPIClient], async (userApi: UserAPIClient) => {
19+
await expect(userApi).toBeTruthy();
20+
await expect(userApi.domain).toBe(DUMMY_DOMAIN);
2121
}));
2222

2323
it('should register user', inject(
@@ -34,9 +34,9 @@ describe('UserService', () => {
3434
userStatus: 1,
3535
};
3636

37-
userApi.createUser({body: user}).subscribe(data => {
37+
userApi.createUser({body: user}).subscribe(async data => {
3838
console.info('data', data);
39-
expect(data).toBe('register was successful');
39+
await expect(data).toBe('register was successful');
4040
});
4141

4242
backend

tests/test-angular-project/swagger.yaml

Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -213,98 +213,6 @@ paths:
213213
- petstore_auth:
214214
- "write:pets"
215215
- "read:pets"
216-
/store/inventory:
217-
get:
218-
tags:
219-
- "store"
220-
summary: "Returns pet inventories by status"
221-
description: "Returns a map of status codes to quantities"
222-
operationId: "getInventory"
223-
produces:
224-
- "application/json"
225-
parameters: []
226-
responses:
227-
200:
228-
description: "successful operation"
229-
schema:
230-
type: "object"
231-
additionalProperties:
232-
type: "integer"
233-
format: "int32"
234-
security:
235-
- api_key: []
236-
/store/order:
237-
post:
238-
tags:
239-
- "store"
240-
summary: "Place an order for a pet"
241-
operationId: "placeOrder"
242-
produces:
243-
- "application/json"
244-
parameters:
245-
- in: "body"
246-
name: "body"
247-
description: "order placed for purchasing the pet"
248-
required: true
249-
schema:
250-
$ref: "#/definitions/Order"
251-
responses:
252-
200:
253-
description: "successful operation"
254-
schema:
255-
$ref: "#/definitions/Order"
256-
400:
257-
description: "Invalid Order"
258-
/store/order/{orderId}:
259-
get:
260-
tags:
261-
- "store"
262-
summary: "Find purchase order by ID"
263-
description: "For valid response try integer IDs with value >= 1 and <= 10.\
264-
\ Other values will generated exceptions"
265-
operationId: "getOrderById"
266-
produces:
267-
- "application/json"
268-
parameters:
269-
- name: "orderId"
270-
in: "path"
271-
description: "ID of pet that needs to be fetched"
272-
required: true
273-
type: "integer"
274-
maximum: 10.0
275-
minimum: 1.0
276-
format: "int64"
277-
responses:
278-
200:
279-
description: "successful operation"
280-
schema:
281-
$ref: "#/definitions/Order"
282-
400:
283-
description: "Invalid ID supplied"
284-
404:
285-
description: "Order not found"
286-
delete:
287-
tags:
288-
- "store"
289-
summary: "Delete purchase order by ID"
290-
description: "For valid response try integer IDs with positive integer value.\
291-
\ Negative or non-integer values will generate API errors"
292-
operationId: "deleteOrder"
293-
produces:
294-
- "application/json"
295-
parameters:
296-
- name: "orderId"
297-
in: "path"
298-
description: "ID of the order that needs to be deleted"
299-
required: true
300-
type: "integer"
301-
minimum: 1.0
302-
format: "int64"
303-
responses:
304-
400:
305-
description: "Invalid ID supplied"
306-
404:
307-
description: "Order not found"
308216
/user:
309217
post:
310218
tags:
@@ -459,33 +367,6 @@ securityDefinitions:
459367
name: "api_key"
460368
in: "header"
461369
definitions:
462-
Order:
463-
type: "object"
464-
properties:
465-
id:
466-
type: "integer"
467-
format: "int64"
468-
petId:
469-
type: "integer"
470-
format: "int64"
471-
quantity:
472-
type: "integer"
473-
format: "int32"
474-
shipDate:
475-
type: "string"
476-
format: "date-time"
477-
status:
478-
type: "string"
479-
description: "Order Status"
480-
enum:
481-
- "placed"
482-
- "approved"
483-
- "delivered"
484-
complete:
485-
type: "boolean"
486-
default: false
487-
xml:
488-
name: "Order"
489370
User:
490371
type: "object"
491372
properties:

0 commit comments

Comments
 (0)