@cratis/arc 18.4.3 → 18.5.0
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/commands/for_Command/given/a_command.ts +4 -5
- package/commands/for_Command/when_executing/with_custom_http_headers.ts +4 -1
- package/commands/for_Command/when_executing/with_origin_and_api_base_path.ts +5 -2
- package/commands/for_Command/when_executing/with_route_parameters.ts +4 -2
- package/dist/cjs/helpers/fetchHelper.d.ts +7 -0
- package/dist/cjs/helpers/fetchHelper.d.ts.map +1 -0
- package/dist/cjs/identity/IIdentityProvider.d.ts +2 -1
- package/dist/cjs/identity/IIdentityProvider.d.ts.map +1 -1
- package/dist/cjs/identity/IIdentityProvider.js.map +1 -1
- package/dist/cjs/identity/IdentityProvider.d.ts +4 -3
- package/dist/cjs/identity/IdentityProvider.d.ts.map +1 -1
- package/dist/cjs/identity/IdentityProvider.js +12 -9
- package/dist/cjs/identity/IdentityProvider.js.map +1 -1
- package/dist/cjs/queries/IObservableQueryConnection.d.ts +2 -0
- package/dist/cjs/queries/IObservableQueryConnection.d.ts.map +1 -1
- package/dist/cjs/queries/NullObservableQueryConnection.d.ts +2 -0
- package/dist/cjs/queries/NullObservableQueryConnection.d.ts.map +1 -1
- package/dist/cjs/queries/NullObservableQueryConnection.js +6 -0
- package/dist/cjs/queries/NullObservableQueryConnection.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryConnection.d.ts +14 -1
- package/dist/cjs/queries/ObservableQueryConnection.d.ts.map +1 -1
- package/dist/cjs/queries/ObservableQueryConnection.js +73 -2
- package/dist/cjs/queries/ObservableQueryConnection.js.map +1 -1
- package/dist/cjs/queries/WebSocketMessage.d.ts +11 -0
- package/dist/cjs/queries/WebSocketMessage.d.ts.map +1 -0
- package/dist/cjs/queries/WebSocketMessage.js +9 -0
- package/dist/cjs/queries/WebSocketMessage.js.map +1 -0
- package/dist/cjs/queries/index.d.ts +1 -0
- package/dist/cjs/queries/index.d.ts.map +1 -1
- package/dist/cjs/queries/index.js +5 -0
- package/dist/cjs/queries/index.js.map +1 -1
- package/dist/esm/helpers/fetchHelper.d.ts +7 -0
- package/dist/esm/helpers/fetchHelper.d.ts.map +1 -0
- package/dist/esm/helpers/fetchHelper.js +22 -0
- package/dist/esm/helpers/fetchHelper.js.map +1 -0
- package/dist/esm/identity/IIdentityProvider.d.ts +2 -1
- package/dist/esm/identity/IIdentityProvider.d.ts.map +1 -1
- package/dist/esm/identity/IIdentityProvider.js.map +1 -1
- package/dist/esm/identity/IdentityProvider.d.ts +4 -3
- package/dist/esm/identity/IdentityProvider.d.ts.map +1 -1
- package/dist/esm/identity/IdentityProvider.js +12 -9
- package/dist/esm/identity/IdentityProvider.js.map +1 -1
- package/dist/esm/queries/IObservableQueryConnection.d.ts +2 -0
- package/dist/esm/queries/IObservableQueryConnection.d.ts.map +1 -1
- package/dist/esm/queries/NullObservableQueryConnection.d.ts +2 -0
- package/dist/esm/queries/NullObservableQueryConnection.d.ts.map +1 -1
- package/dist/esm/queries/NullObservableQueryConnection.js +6 -0
- package/dist/esm/queries/NullObservableQueryConnection.js.map +1 -1
- package/dist/esm/queries/ObservableQueryConnection.d.ts +14 -1
- package/dist/esm/queries/ObservableQueryConnection.d.ts.map +1 -1
- package/dist/esm/queries/ObservableQueryConnection.js +73 -2
- package/dist/esm/queries/ObservableQueryConnection.js.map +1 -1
- package/dist/esm/queries/WebSocketMessage.d.ts +11 -0
- package/dist/esm/queries/WebSocketMessage.d.ts.map +1 -0
- package/dist/esm/queries/WebSocketMessage.js +9 -0
- package/dist/esm/queries/WebSocketMessage.js.map +1 -0
- package/dist/esm/queries/index.d.ts +1 -0
- package/dist/esm/queries/index.d.ts.map +1 -1
- package/dist/esm/queries/index.js +1 -0
- package/dist/esm/queries/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/helpers/fetchHelper.ts +30 -0
- package/identity/IIdentityProvider.ts +4 -1
- package/identity/IdentityProvider.ts +14 -9
- package/identity/for_IdentityProvider/given/an_identity_provider.ts +4 -5
- package/identity/for_IdentityProvider/when_getting_current/with_type_safe_details.ts +43 -0
- package/identity/for_IdentityProvider/when_refreshing/with_type_safe_details.ts +42 -0
- package/package.json +1 -1
- package/queries/IObservableQueryConnection.ts +10 -0
- package/queries/NullObservableQueryConnection.ts +10 -0
- package/queries/ObservableQueryConnection.ts +93 -2
- package/queries/WebSocketMessage.ts +44 -0
- package/queries/for_ObservableQueryConnection/given/an_observable_query_connection.ts +27 -0
- package/queries/for_ObservableQueryConnection/when_constructing.ts +15 -0
- package/queries/for_ObservableQueryFor/when_performing/with_enumerable_query.ts +5 -2
- package/queries/for_ObservableQueryFor/when_performing/with_paging.ts +5 -2
- package/queries/for_ObservableQueryFor/when_performing/with_parameter_descriptor_values.ts +5 -2
- package/queries/for_ObservableQueryFor/when_performing/with_partial_parameter_descriptor_values.ts +5 -2
- package/queries/for_ObservableQueryFor/when_performing/with_route_parameters_and_unused_parameters.ts +5 -2
- package/queries/for_ObservableQueryFor/when_performing/with_sorting.ts +5 -2
- package/queries/for_ObservableQueryFor/when_performing/with_valid_arguments.ts +7 -2
- package/queries/for_QueryFor/when_performing/with_abort_controller.ts +5 -2
- package/queries/for_QueryFor/when_performing/with_enumerable_query.ts +5 -2
- package/queries/for_QueryFor/when_performing/with_fetch_error.ts +5 -2
- package/queries/for_QueryFor/when_performing/with_json_parse_error.ts +6 -3
- package/queries/for_QueryFor/when_performing/with_paging.ts +5 -2
- package/queries/for_QueryFor/when_performing/with_parameter_descriptor_values.ts +5 -2
- package/queries/for_QueryFor/when_performing/with_partial_parameter_descriptor_values.ts +5 -2
- package/queries/for_QueryFor/when_performing/with_query_without_required_parameters.ts +5 -2
- package/queries/for_QueryFor/when_performing/with_route_parameters_and_unused_parameters.ts +5 -2
- package/queries/for_QueryFor/when_performing/with_sorting.ts +7 -3
- package/queries/for_QueryFor/when_performing/with_valid_arguments.ts +6 -3
- package/queries/for_WebSocketMessage/when_creating_messages.ts +67 -0
- package/queries/index.ts +2 -1
|
@@ -5,15 +5,18 @@ import { a_query_for } from '../given/a_query_for';
|
|
|
5
5
|
import { given } from '../../../given';
|
|
6
6
|
|
|
7
7
|
import * as sinon from 'sinon';
|
|
8
|
+
import { createFetchHelper } from '../../../helpers/fetchHelper';
|
|
8
9
|
import { QueryResult } from '../../QueryResult';
|
|
9
10
|
|
|
10
11
|
describe('with fetch error', given(a_query_for, context => {
|
|
11
12
|
let result: QueryResult<string>;
|
|
12
13
|
let fetchStub: sinon.SinonStub;
|
|
14
|
+
let fetchHelper: { stubFetch: () => sinon.SinonStub; restore: () => void };
|
|
13
15
|
|
|
14
16
|
beforeEach(async () => {
|
|
15
17
|
// Setup fetch mock to reject
|
|
16
|
-
|
|
18
|
+
fetchHelper = createFetchHelper();
|
|
19
|
+
fetchStub = fetchHelper.stubFetch();
|
|
17
20
|
fetchStub.rejects(new Error('Network error'));
|
|
18
21
|
|
|
19
22
|
context.query.setOrigin('https://api.example.com');
|
|
@@ -29,7 +32,7 @@ describe('with fetch error', given(a_query_for, context => {
|
|
|
29
32
|
});
|
|
30
33
|
|
|
31
34
|
afterEach(() => {
|
|
32
|
-
|
|
35
|
+
fetchHelper.restore();
|
|
33
36
|
});
|
|
34
37
|
|
|
35
38
|
it('should return no success result', () => {
|
|
@@ -5,15 +5,18 @@ import { a_query_for } from '../given/a_query_for';
|
|
|
5
5
|
import { given } from '../../../given';
|
|
6
6
|
|
|
7
7
|
import * as sinon from 'sinon';
|
|
8
|
+
import { createFetchHelper } from '../../../helpers/fetchHelper';
|
|
8
9
|
import { QueryResult } from '../../QueryResult';
|
|
9
10
|
|
|
10
11
|
describe('with json parse error', given(a_query_for, context => {
|
|
11
12
|
let result: QueryResult<string>;
|
|
12
13
|
let fetchStub: sinon.SinonStub;
|
|
14
|
+
let fetchHelper: { stubFetch: () => sinon.SinonStub; restore: () => void };
|
|
13
15
|
|
|
14
16
|
beforeEach(async () => {
|
|
15
|
-
// Setup fetch mock with json parse error
|
|
16
|
-
|
|
17
|
+
// Setup fetch mock with json parse error using helper
|
|
18
|
+
fetchHelper = createFetchHelper();
|
|
19
|
+
fetchStub = fetchHelper.stubFetch();
|
|
17
20
|
fetchStub.resolves({
|
|
18
21
|
json: sinon.stub().rejects(new Error('Invalid JSON')),
|
|
19
22
|
ok: true,
|
|
@@ -27,7 +30,7 @@ describe('with json parse error', given(a_query_for, context => {
|
|
|
27
30
|
});
|
|
28
31
|
|
|
29
32
|
afterEach(() => {
|
|
30
|
-
|
|
33
|
+
fetchHelper.restore();
|
|
31
34
|
});
|
|
32
35
|
|
|
33
36
|
it('should return no success result', () => {
|
|
@@ -5,12 +5,14 @@ import { a_query_for } from '../given/a_query_for';
|
|
|
5
5
|
import { given } from '../../../given';
|
|
6
6
|
|
|
7
7
|
import * as sinon from 'sinon';
|
|
8
|
+
import { createFetchHelper } from '../../../helpers/fetchHelper';
|
|
8
9
|
import { QueryResult } from '../../QueryResult';
|
|
9
10
|
import { Paging } from '../../Paging';
|
|
10
11
|
|
|
11
12
|
describe('with paging', given(a_query_for, context => {
|
|
12
13
|
let result: QueryResult<string>;
|
|
13
14
|
let fetchStub: sinon.SinonStub;
|
|
15
|
+
let fetchHelper: { stubFetch: () => sinon.SinonStub; restore: () => void };
|
|
14
16
|
const mockResponse = {
|
|
15
17
|
data: 'test-result',
|
|
16
18
|
isSuccess: true,
|
|
@@ -30,7 +32,8 @@ describe('with paging', given(a_query_for, context => {
|
|
|
30
32
|
|
|
31
33
|
beforeEach(async () => {
|
|
32
34
|
// Setup fetch mock
|
|
33
|
-
|
|
35
|
+
fetchHelper = createFetchHelper();
|
|
36
|
+
fetchStub = fetchHelper.stubFetch();
|
|
34
37
|
fetchStub.resolves({
|
|
35
38
|
json: sinon.stub().resolves(mockResponse),
|
|
36
39
|
ok: true,
|
|
@@ -45,7 +48,7 @@ describe('with paging', given(a_query_for, context => {
|
|
|
45
48
|
});
|
|
46
49
|
|
|
47
50
|
afterEach(() => {
|
|
48
|
-
|
|
51
|
+
fetchHelper.restore();
|
|
49
52
|
});
|
|
50
53
|
|
|
51
54
|
it('should call fetch with URL including paging parameters', () => {
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
import { a_query_for } from '../given/a_query_for';
|
|
5
5
|
import { given } from '../../../given';
|
|
6
6
|
import * as sinon from 'sinon';
|
|
7
|
+
import { createFetchHelper } from '../../../helpers/fetchHelper';
|
|
7
8
|
import { QueryResult } from '../../QueryResult';
|
|
8
9
|
|
|
9
10
|
describe('with parameter descriptor values', given(a_query_for, context => {
|
|
10
11
|
let result: QueryResult<string>;
|
|
11
12
|
let fetchStub: sinon.SinonStub;
|
|
13
|
+
let fetchHelper: { stubFetch: () => sinon.SinonStub; restore: () => void };
|
|
12
14
|
const mockResponse = {
|
|
13
15
|
data: 'test-result',
|
|
14
16
|
isSuccess: true,
|
|
@@ -27,7 +29,8 @@ describe('with parameter descriptor values', given(a_query_for, context => {
|
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
beforeEach(async () => {
|
|
30
|
-
|
|
32
|
+
fetchHelper = createFetchHelper();
|
|
33
|
+
fetchStub = fetchHelper.stubFetch();
|
|
31
34
|
fetchStub.resolves({
|
|
32
35
|
json: sinon.stub().resolves(mockResponse),
|
|
33
36
|
ok: true,
|
|
@@ -45,7 +48,7 @@ describe('with parameter descriptor values', given(a_query_for, context => {
|
|
|
45
48
|
});
|
|
46
49
|
|
|
47
50
|
afterEach(() => {
|
|
48
|
-
|
|
51
|
+
fetchHelper.restore();
|
|
49
52
|
});
|
|
50
53
|
|
|
51
54
|
it('should return successful result', () => {
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
import { a_query_for } from '../given/a_query_for';
|
|
5
5
|
import { given } from '../../../given';
|
|
6
6
|
import * as sinon from 'sinon';
|
|
7
|
+
import { createFetchHelper } from '../../../helpers/fetchHelper';
|
|
7
8
|
import { QueryResult } from '../../QueryResult';
|
|
8
9
|
|
|
9
10
|
describe('with partial parameter descriptor values', given(a_query_for, context => {
|
|
10
11
|
let result: QueryResult<string>;
|
|
11
12
|
let fetchStub: sinon.SinonStub;
|
|
13
|
+
let fetchHelper: { stubFetch: () => sinon.SinonStub; restore: () => void };
|
|
12
14
|
const mockResponse = {
|
|
13
15
|
data: 'test-result',
|
|
14
16
|
isSuccess: true,
|
|
@@ -27,7 +29,8 @@ describe('with partial parameter descriptor values', given(a_query_for, context
|
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
beforeEach(async () => {
|
|
30
|
-
|
|
32
|
+
fetchHelper = createFetchHelper();
|
|
33
|
+
fetchStub = fetchHelper.stubFetch();
|
|
31
34
|
fetchStub.resolves({
|
|
32
35
|
json: sinon.stub().resolves(mockResponse),
|
|
33
36
|
ok: true,
|
|
@@ -45,7 +48,7 @@ describe('with partial parameter descriptor values', given(a_query_for, context
|
|
|
45
48
|
});
|
|
46
49
|
|
|
47
50
|
afterEach(() => {
|
|
48
|
-
|
|
51
|
+
fetchHelper.restore();
|
|
49
52
|
});
|
|
50
53
|
|
|
51
54
|
it('should return successful result', () => {
|
|
@@ -5,11 +5,13 @@ import { a_query_for } from '../given/a_query_for';
|
|
|
5
5
|
import { given } from '../../../given';
|
|
6
6
|
|
|
7
7
|
import * as sinon from 'sinon';
|
|
8
|
+
import { createFetchHelper } from '../../../helpers/fetchHelper';
|
|
8
9
|
import { QueryResult } from '../../QueryResult';
|
|
9
10
|
|
|
10
11
|
describe('with query without required parameters', given(a_query_for, context => {
|
|
11
12
|
let result: QueryResult<string>;
|
|
12
13
|
let fetchStub: sinon.SinonStub;
|
|
14
|
+
let fetchHelper: { stubFetch: () => sinon.SinonStub; restore: () => void };
|
|
13
15
|
const mockResponse = {
|
|
14
16
|
data: 'test-result',
|
|
15
17
|
isSuccess: true,
|
|
@@ -32,7 +34,8 @@ describe('with query without required parameters', given(a_query_for, context =>
|
|
|
32
34
|
if ((global.fetch as sinon.SinonStub)?.restore) {
|
|
33
35
|
(global.fetch as sinon.SinonStub).restore();
|
|
34
36
|
}
|
|
35
|
-
|
|
37
|
+
fetchHelper = createFetchHelper();
|
|
38
|
+
fetchStub = fetchHelper.stubFetch();
|
|
36
39
|
fetchStub.resolves({
|
|
37
40
|
json: sinon.stub().resolves(mockResponse),
|
|
38
41
|
ok: true,
|
|
@@ -46,7 +49,7 @@ describe('with query without required parameters', given(a_query_for, context =>
|
|
|
46
49
|
});
|
|
47
50
|
|
|
48
51
|
afterEach(() => {
|
|
49
|
-
|
|
52
|
+
fetchHelper.restore();
|
|
50
53
|
});
|
|
51
54
|
|
|
52
55
|
it('should return successful result', () => {
|
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
import { a_query_for } from '../given/a_query_for';
|
|
5
5
|
import { given } from '../../../given';
|
|
6
6
|
import * as sinon from 'sinon';
|
|
7
|
+
import { createFetchHelper } from '../../../helpers/fetchHelper';
|
|
7
8
|
import { QueryResult } from '../../QueryResult';
|
|
8
9
|
import { expect } from 'chai';
|
|
9
10
|
|
|
10
11
|
describe('with route parameters and unused parameters', given(a_query_for, context => {
|
|
11
12
|
let result: QueryResult<string>;
|
|
12
13
|
let fetchStub: sinon.SinonStub;
|
|
14
|
+
let fetchHelper: { stubFetch: () => sinon.SinonStub; restore: () => void };
|
|
13
15
|
const mockResponse = {
|
|
14
16
|
data: 'test-result',
|
|
15
17
|
isSuccess: true,
|
|
@@ -28,7 +30,8 @@ describe('with route parameters and unused parameters', given(a_query_for, conte
|
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
beforeEach(async () => {
|
|
31
|
-
|
|
33
|
+
fetchHelper = createFetchHelper();
|
|
34
|
+
fetchStub = fetchHelper.stubFetch();
|
|
32
35
|
fetchStub.resolves({
|
|
33
36
|
json: sinon.stub().resolves(mockResponse),
|
|
34
37
|
ok: true,
|
|
@@ -43,7 +46,7 @@ describe('with route parameters and unused parameters', given(a_query_for, conte
|
|
|
43
46
|
});
|
|
44
47
|
|
|
45
48
|
afterEach(() => {
|
|
46
|
-
|
|
49
|
+
fetchHelper.restore();
|
|
47
50
|
});
|
|
48
51
|
|
|
49
52
|
it('should return successful result', () => {
|
|
@@ -5,6 +5,7 @@ import { a_query_for } from '../given/a_query_for';
|
|
|
5
5
|
import { given } from '../../../given';
|
|
6
6
|
|
|
7
7
|
import * as sinon from 'sinon';
|
|
8
|
+
import { createFetchHelper } from '../../../helpers/fetchHelper';
|
|
8
9
|
import { QueryResult } from '../../QueryResult';
|
|
9
10
|
import { Sorting } from '../../Sorting';
|
|
10
11
|
import { SortDirection } from '../../SortDirection';
|
|
@@ -12,6 +13,7 @@ import { SortDirection } from '../../SortDirection';
|
|
|
12
13
|
describe('with sorting', given(a_query_for, context => {
|
|
13
14
|
let result: QueryResult<string>;
|
|
14
15
|
let fetchStub: sinon.SinonStub;
|
|
16
|
+
let fetchHelper: { stubFetch: () => sinon.SinonStub; restore: () => void };
|
|
15
17
|
const mockResponse = {
|
|
16
18
|
data: 'test-result',
|
|
17
19
|
isSuccess: true,
|
|
@@ -32,7 +34,8 @@ describe('with sorting', given(a_query_for, context => {
|
|
|
32
34
|
describe('and ascending direction', () => {
|
|
33
35
|
beforeEach(async () => {
|
|
34
36
|
// Setup fetch mock
|
|
35
|
-
|
|
37
|
+
fetchHelper = createFetchHelper();
|
|
38
|
+
fetchStub = fetchHelper.stubFetch();
|
|
36
39
|
fetchStub.resolves({
|
|
37
40
|
json: sinon.stub().resolves(mockResponse),
|
|
38
41
|
ok: true,
|
|
@@ -66,7 +69,8 @@ describe('with sorting', given(a_query_for, context => {
|
|
|
66
69
|
describe('and descending direction', () => {
|
|
67
70
|
beforeEach(async () => {
|
|
68
71
|
// Setup fetch mock
|
|
69
|
-
|
|
72
|
+
fetchHelper = createFetchHelper();
|
|
73
|
+
fetchStub = fetchHelper.stubFetch();
|
|
70
74
|
fetchStub.resolves({
|
|
71
75
|
json: sinon.stub().resolves(mockResponse),
|
|
72
76
|
ok: true,
|
|
@@ -81,7 +85,7 @@ describe('with sorting', given(a_query_for, context => {
|
|
|
81
85
|
});
|
|
82
86
|
|
|
83
87
|
afterEach(() => {
|
|
84
|
-
|
|
88
|
+
fetchHelper.restore();
|
|
85
89
|
});
|
|
86
90
|
|
|
87
91
|
it('should call fetch with URL including sorting parameters', () => {
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
import { a_query_for } from '../given/a_query_for';
|
|
5
5
|
import { given } from '../../../given';
|
|
6
6
|
import * as sinon from 'sinon';
|
|
7
|
+
import { createFetchHelper } from '../../../helpers/fetchHelper';
|
|
7
8
|
import { QueryResult } from '../../QueryResult';
|
|
8
9
|
|
|
9
10
|
describe('with valid arguments', given(a_query_for, context => {
|
|
10
11
|
let result: QueryResult<string>;
|
|
11
12
|
let fetchStub: sinon.SinonStub;
|
|
13
|
+
let fetchHelper: { stubFetch: () => sinon.SinonStub; restore: () => void };
|
|
12
14
|
const mockResponse = {
|
|
13
15
|
data: 'test-result',
|
|
14
16
|
isSuccess: true,
|
|
@@ -27,8 +29,9 @@ describe('with valid arguments', given(a_query_for, context => {
|
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
beforeEach(async () => {
|
|
30
|
-
// Setup fetch mock
|
|
31
|
-
|
|
32
|
+
// Setup fetch mock using helper
|
|
33
|
+
fetchHelper = createFetchHelper();
|
|
34
|
+
fetchStub = fetchHelper.stubFetch();
|
|
32
35
|
fetchStub.resolves({
|
|
33
36
|
json: sinon.stub().resolves(mockResponse),
|
|
34
37
|
ok: true,
|
|
@@ -44,7 +47,7 @@ describe('with valid arguments', given(a_query_for, context => {
|
|
|
44
47
|
});
|
|
45
48
|
|
|
46
49
|
afterEach(() => {
|
|
47
|
-
|
|
50
|
+
fetchHelper.restore();
|
|
48
51
|
});
|
|
49
52
|
|
|
50
53
|
it('should return successful result', () => {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { WebSocketMessage, WebSocketMessageType } from '../WebSocketMessage';
|
|
5
|
+
|
|
6
|
+
describe('when creating a ping message', () => {
|
|
7
|
+
let timestamp: number;
|
|
8
|
+
let message: WebSocketMessage;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
timestamp = Date.now();
|
|
12
|
+
message = {
|
|
13
|
+
type: WebSocketMessageType.Ping,
|
|
14
|
+
timestamp: timestamp
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should have ping type', () => {
|
|
19
|
+
message.type.should.equal(WebSocketMessageType.Ping);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should have timestamp', () => {
|
|
23
|
+
message.timestamp!.should.equal(timestamp);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('when creating a pong message', () => {
|
|
28
|
+
let timestamp: number;
|
|
29
|
+
let message: WebSocketMessage;
|
|
30
|
+
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
timestamp = Date.now();
|
|
33
|
+
message = {
|
|
34
|
+
type: WebSocketMessageType.Pong,
|
|
35
|
+
timestamp: timestamp
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should have pong type', () => {
|
|
40
|
+
message.type.should.equal(WebSocketMessageType.Pong);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should have timestamp', () => {
|
|
44
|
+
message.timestamp!.should.equal(timestamp);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('when creating a data message', () => {
|
|
49
|
+
let data: object;
|
|
50
|
+
let message: WebSocketMessage;
|
|
51
|
+
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
data = { test: 'value' };
|
|
54
|
+
message = {
|
|
55
|
+
type: WebSocketMessageType.Data,
|
|
56
|
+
data: data
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should have data type', () => {
|
|
61
|
+
message.type.should.equal(WebSocketMessageType.Data);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should have data', () => {
|
|
65
|
+
message.data.should.equal(data);
|
|
66
|
+
});
|
|
67
|
+
});
|
package/queries/index.ts
CHANGED
|
@@ -17,5 +17,6 @@ export * from './ObservableQueryFor';
|
|
|
17
17
|
export * from './IObservableQueryConnection';
|
|
18
18
|
export * from './ObservableQueryConnection';
|
|
19
19
|
export * from './ObservableQuerySubscription';
|
|
20
|
+
export * from './WebSocketMessage';
|
|
20
21
|
export * from './IQueryProvider';
|
|
21
|
-
export * from './QueryProvider';
|
|
22
|
+
export * from './QueryProvider';
|