@cratis/arc 19.0.0 → 19.0.2
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/Command.ts +9 -1
- package/commands/for_Command/when_executing/and_command_route_not_found.ts +2 -2
- package/commands/for_Command/when_executing/and_fetch_throws_exception.ts +3 -3
- package/commands/for_Command/when_executing/with_client_validation_failing.ts +5 -5
- package/commands/for_Command/when_executing/with_client_validation_failure_and_custom_message.ts +5 -5
- package/commands/for_Command/when_executing/with_client_validation_passing.ts +1 -1
- package/commands/for_Command/when_executing/with_command_properties.ts +1 -1
- package/commands/for_Command/when_executing/with_custom_http_headers.ts +2 -2
- package/commands/for_Command/when_executing/with_microservice_header.ts +1 -1
- package/commands/for_Command/when_executing/with_missing_required_property.ts +7 -7
- package/commands/for_Command/when_executing/with_origin_and_api_base_path.ts +1 -1
- package/commands/for_Command/when_executing/with_route_parameters.ts +2 -2
- package/commands/for_Command/when_executing/with_successful_response.ts +5 -5
- package/commands/for_Command/when_validating/and_fetch_throws_exception.ts +3 -3
- package/commands/for_Command/when_validating/and_validation_endpoint_not_found.ts +2 -2
- package/commands/for_Command/when_validating/does_not_update_initial_values.ts +1 -1
- package/commands/for_Command/when_validating/with_client_validation_failure.ts +4 -4
- package/commands/for_Command/when_validating/with_client_validation_passing.ts +3 -3
- package/commands/for_Command/when_validating/with_required_property_missing.ts +4 -4
- package/commands/for_Command/when_validating/with_route_parameters.ts +61 -0
- package/commands/for_Command/when_validating/with_successful_response.ts +3 -3
- package/commands/for_Command/when_validating/with_validation_errors.ts +3 -3
- package/dist/cjs/commands/Command.d.ts.map +1 -1
- package/dist/cjs/commands/Command.js +7 -1
- package/dist/cjs/commands/Command.js.map +1 -1
- package/dist/cjs/commands/for_Command/when_validating/with_route_parameters.d.ts +2 -0
- package/dist/cjs/commands/for_Command/when_validating/with_route_parameters.d.ts.map +1 -0
- package/dist/esm/commands/Command.d.ts.map +1 -1
- package/dist/esm/commands/Command.js +7 -1
- package/dist/esm/commands/Command.js.map +1 -1
- package/dist/esm/commands/for_Command/when_executing/and_command_route_not_found.js +2 -2
- package/dist/esm/commands/for_Command/when_executing/and_fetch_throws_exception.js +3 -3
- package/dist/esm/commands/for_Command/when_executing/with_client_validation_failing.js +5 -5
- package/dist/esm/commands/for_Command/when_executing/with_client_validation_failure_and_custom_message.js +5 -5
- package/dist/esm/commands/for_Command/when_executing/with_client_validation_passing.js +1 -1
- package/dist/esm/commands/for_Command/when_executing/with_command_properties.js +1 -1
- package/dist/esm/commands/for_Command/when_executing/with_custom_http_headers.js +2 -2
- package/dist/esm/commands/for_Command/when_executing/with_microservice_header.js +1 -1
- package/dist/esm/commands/for_Command/when_executing/with_missing_required_property.js +7 -7
- package/dist/esm/commands/for_Command/when_executing/with_origin_and_api_base_path.js +1 -1
- package/dist/esm/commands/for_Command/when_executing/with_route_parameters.js +2 -2
- package/dist/esm/commands/for_Command/when_executing/with_successful_response.js +5 -5
- package/dist/esm/commands/for_Command/when_validating/and_fetch_throws_exception.js +3 -3
- package/dist/esm/commands/for_Command/when_validating/and_validation_endpoint_not_found.js +2 -2
- package/dist/esm/commands/for_Command/when_validating/does_not_update_initial_values.js +1 -1
- package/dist/esm/commands/for_Command/when_validating/with_client_validation_failure.js +4 -4
- package/dist/esm/commands/for_Command/when_validating/with_client_validation_passing.js +3 -3
- package/dist/esm/commands/for_Command/when_validating/with_required_property_missing.js +4 -4
- package/dist/esm/commands/for_Command/when_validating/with_route_parameters.d.ts +2 -0
- package/dist/esm/commands/for_Command/when_validating/with_route_parameters.d.ts.map +1 -0
- package/dist/esm/commands/for_Command/when_validating/with_route_parameters.js +51 -0
- package/dist/esm/commands/for_Command/when_validating/with_route_parameters.js.map +1 -0
- package/dist/esm/commands/for_Command/when_validating/with_successful_response.js +3 -3
- package/dist/esm/commands/for_Command/when_validating/with_validation_errors.js +3 -3
- package/dist/esm/for_UrlHelpers/when_creating_url_from/with_base_path_ending_with_slash.js +3 -3
- package/dist/esm/for_UrlHelpers/when_creating_url_from/with_empty_origin.js +2 -2
- package/dist/esm/for_UrlHelpers/when_creating_url_from/with_null_or_undefined_origin.js +4 -4
- package/dist/esm/for_UrlHelpers/when_creating_url_from/with_relative_route.js +3 -3
- package/dist/esm/for_UrlHelpers/when_creating_url_from/with_valid_parameters.js +3 -3
- package/dist/esm/for_UrlHelpers/when_creating_url_from/without_document_object.js +1 -1
- package/dist/esm/identity/for_IdentityProvider/when_refreshing/with_api_base_path_set.js +1 -1
- package/dist/esm/identity/for_IdentityProvider/when_refreshing/with_globals_api_base_path.js +1 -1
- package/dist/esm/identity/for_IdentityProvider/when_refreshing/with_origin_set.js +3 -3
- package/dist/esm/identity/for_IdentityProvider/when_refreshing/without_api_base_path.js +1 -1
- package/dist/esm/queries/for_QueryFor/when_performing/with_client_validation_failing.js +4 -4
- package/dist/esm/queries/for_QueryFor/when_performing/with_client_validation_failure_and_custom_message.js +5 -5
- package/dist/esm/queries/for_QueryFor/when_performing/with_client_validation_passing.js +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/validation/for_Validator/when_defining_multiple_rules_for_same_property.js +2 -2
- package/dist/esm/validation/for_Validator/when_using_custom_error_message.js +1 -1
- package/dist/esm/validation/for_Validator/when_validating/with_all_rules_passing.js +2 -2
- package/dist/esm/validation/for_Validator/when_validating/with_multiple_rules_failing.js +3 -3
- package/dist/esm/validation/for_Validator/when_validating/with_one_rule_failing.js +3 -3
- package/dist/esm/validation/rules/for_EmailRule/when_validating/with_empty_string.js +1 -1
- package/dist/esm/validation/rules/for_EmailRule/when_validating/with_invalid_email.js +1 -1
- package/dist/esm/validation/rules/for_EmailRule/when_validating/with_valid_email.js +1 -1
- package/dist/esm/validation/rules/for_GreaterThanOrEqualRule/when_validating/with_value_equal_to_threshold.js +1 -1
- package/dist/esm/validation/rules/for_GreaterThanRule/when_validating/with_value_equal_to_threshold.js +1 -1
- package/dist/esm/validation/rules/for_GreaterThanRule/when_validating/with_value_greater_than_threshold.js +1 -1
- package/dist/esm/validation/rules/for_GreaterThanRule/when_validating/with_value_less_than_threshold.js +2 -2
- package/dist/esm/validation/rules/for_LengthRule/when_validating/with_string_longer_than_maximum.js +1 -1
- package/dist/esm/validation/rules/for_LengthRule/when_validating/with_string_shorter_than_minimum.js +1 -1
- package/dist/esm/validation/rules/for_LengthRule/when_validating/with_string_within_range.js +1 -1
- package/dist/esm/validation/rules/for_LessThanRule/when_validating/with_value_less_than_threshold.js +1 -1
- package/dist/esm/validation/rules/for_MaxLengthRule/when_validating/with_string_equal_to_maximum.js +1 -1
- package/dist/esm/validation/rules/for_MaxLengthRule/when_validating/with_string_longer_than_maximum.js +2 -2
- package/dist/esm/validation/rules/for_MinLengthRule/when_validating/with_string_equal_to_minimum.js +1 -1
- package/dist/esm/validation/rules/for_MinLengthRule/when_validating/with_string_longer_than_minimum.js +1 -1
- package/dist/esm/validation/rules/for_MinLengthRule/when_validating/with_string_shorter_than_minimum.js +2 -2
- package/dist/esm/validation/rules/for_NotEmptyRule/when_setting_custom_message.js +1 -1
- package/dist/esm/validation/rules/for_NotEmptyRule/when_validating/with_empty_array.js +1 -1
- package/dist/esm/validation/rules/for_NotEmptyRule/when_validating/with_empty_string.js +1 -1
- package/dist/esm/validation/rules/for_NotEmptyRule/when_validating/with_non_empty_array.js +1 -1
- package/dist/esm/validation/rules/for_NotEmptyRule/when_validating/with_null_value.js +4 -4
- package/dist/esm/validation/rules/for_NotEmptyRule/when_validating/with_undefined_value.js +2 -2
- package/dist/esm/validation/rules/for_NotEmptyRule/when_validating/with_valid_string.js +1 -1
- package/dist/esm/validation/rules/for_NotEmptyRule/when_validating/with_whitespace_string.js +1 -1
- package/for_UrlHelpers/when_creating_url_from/with_base_path_ending_with_slash.ts +3 -3
- package/for_UrlHelpers/when_creating_url_from/with_empty_origin.ts +2 -2
- package/for_UrlHelpers/when_creating_url_from/with_null_or_undefined_origin.ts +4 -4
- package/for_UrlHelpers/when_creating_url_from/with_relative_route.ts +3 -3
- package/for_UrlHelpers/when_creating_url_from/with_valid_parameters.ts +3 -3
- package/for_UrlHelpers/when_creating_url_from/without_document_object.ts +1 -1
- package/identity/for_IdentityProvider/when_refreshing/with_api_base_path_set.ts +1 -1
- package/identity/for_IdentityProvider/when_refreshing/with_globals_api_base_path.ts +1 -1
- package/identity/for_IdentityProvider/when_refreshing/with_origin_set.ts +3 -3
- package/identity/for_IdentityProvider/when_refreshing/without_api_base_path.ts +1 -1
- package/package.json +2 -2
- package/queries/for_QueryFor/when_performing/with_client_validation_failing.ts +4 -4
- package/queries/for_QueryFor/when_performing/with_client_validation_failure_and_custom_message.ts +5 -5
- package/queries/for_QueryFor/when_performing/with_client_validation_passing.ts +1 -1
- package/validation/for_Validator/when_defining_multiple_rules_for_same_property.ts +2 -2
- package/validation/for_Validator/when_using_custom_error_message.ts +1 -1
- package/validation/for_Validator/when_validating/with_all_rules_passing.ts +2 -2
- package/validation/for_Validator/when_validating/with_multiple_rules_failing.ts +3 -3
- package/validation/for_Validator/when_validating/with_one_rule_failing.ts +3 -3
- package/validation/rules/for_EmailRule/when_validating/with_empty_string.ts +1 -1
- package/validation/rules/for_EmailRule/when_validating/with_invalid_email.ts +1 -1
- package/validation/rules/for_EmailRule/when_validating/with_valid_email.ts +1 -1
- package/validation/rules/for_GreaterThanOrEqualRule/when_validating/with_value_equal_to_threshold.ts +1 -1
- package/validation/rules/for_GreaterThanRule/when_validating/with_value_equal_to_threshold.ts +1 -1
- package/validation/rules/for_GreaterThanRule/when_validating/with_value_greater_than_threshold.ts +1 -1
- package/validation/rules/for_GreaterThanRule/when_validating/with_value_less_than_threshold.ts +2 -2
- package/validation/rules/for_LengthRule/when_validating/with_string_longer_than_maximum.ts +1 -1
- package/validation/rules/for_LengthRule/when_validating/with_string_shorter_than_minimum.ts +1 -1
- package/validation/rules/for_LengthRule/when_validating/with_string_within_range.ts +1 -1
- package/validation/rules/for_LessThanRule/when_validating/with_value_less_than_threshold.ts +1 -1
- package/validation/rules/for_MaxLengthRule/when_validating/with_string_equal_to_maximum.ts +1 -1
- package/validation/rules/for_MaxLengthRule/when_validating/with_string_longer_than_maximum.ts +2 -2
- package/validation/rules/for_MinLengthRule/when_validating/with_string_equal_to_minimum.ts +1 -1
- package/validation/rules/for_MinLengthRule/when_validating/with_string_longer_than_minimum.ts +1 -1
- package/validation/rules/for_MinLengthRule/when_validating/with_string_shorter_than_minimum.ts +2 -2
- package/validation/rules/for_NotEmptyRule/when_setting_custom_message.ts +1 -1
- package/validation/rules/for_NotEmptyRule/when_validating/with_empty_array.ts +1 -1
- package/validation/rules/for_NotEmptyRule/when_validating/with_empty_string.ts +1 -1
- package/validation/rules/for_NotEmptyRule/when_validating/with_non_empty_array.ts +1 -1
- package/validation/rules/for_NotEmptyRule/when_validating/with_null_value.ts +4 -4
- package/validation/rules/for_NotEmptyRule/when_validating/with_undefined_value.ts +2 -2
- package/validation/rules/for_NotEmptyRule/when_validating/with_valid_string.ts +1 -1
- package/validation/rules/for_NotEmptyRule/when_validating/with_whitespace_string.ts +1 -1
|
@@ -12,7 +12,7 @@ describe("when executing and command route not found", given(a_command, context
|
|
|
12
12
|
afterEach(() => {
|
|
13
13
|
context.fetchStub.restore();
|
|
14
14
|
});
|
|
15
|
-
it("
|
|
16
|
-
it("
|
|
15
|
+
it("should return failed result", () => result.isSuccess.should.be.false);
|
|
16
|
+
it("should have exception messages", () => (result.exceptionMessages.length > 0).should.be.true);
|
|
17
17
|
}));
|
|
18
18
|
//# sourceMappingURL=and_command_route_not_found.js.map
|
|
@@ -9,8 +9,8 @@ describe("when executing and fetch throws exception", given(a_command, context =
|
|
|
9
9
|
afterEach(() => {
|
|
10
10
|
context.fetchStub.restore();
|
|
11
11
|
});
|
|
12
|
-
it("
|
|
13
|
-
it("
|
|
14
|
-
it("
|
|
12
|
+
it("should return failed result", () => result.isSuccess.should.be.false);
|
|
13
|
+
it("should include error message", () => result.exceptionMessages[0].should.contain('Error during server call'));
|
|
14
|
+
it("should have exception messages", () => (result.exceptionMessages.length > 0).should.be.true);
|
|
15
15
|
}));
|
|
16
16
|
//# sourceMappingURL=and_fetch_throws_exception.js.map
|
|
@@ -33,19 +33,19 @@ describe("when executing with client validation failing", () => {
|
|
|
33
33
|
command.age = 15;
|
|
34
34
|
result = await command.execute();
|
|
35
35
|
});
|
|
36
|
-
it("
|
|
36
|
+
it("should not be success", () => {
|
|
37
37
|
result.isSuccess.should.be.false;
|
|
38
38
|
});
|
|
39
|
-
it("
|
|
39
|
+
it("should not be valid", () => {
|
|
40
40
|
result.isValid.should.be.false;
|
|
41
41
|
});
|
|
42
|
-
it("
|
|
42
|
+
it("should have validation results", () => {
|
|
43
43
|
result.validationResults.should.not.be.empty;
|
|
44
44
|
});
|
|
45
|
-
it("
|
|
45
|
+
it("should have error for name", () => {
|
|
46
46
|
result.validationResults.some(r => r.members.includes('name')).should.be.true;
|
|
47
47
|
});
|
|
48
|
-
it("
|
|
48
|
+
it("should have error for age", () => {
|
|
49
49
|
result.validationResults.some(r => r.members.includes('age')).should.be.true;
|
|
50
50
|
});
|
|
51
51
|
});
|
|
@@ -10,10 +10,10 @@ describe("when executing with client validation failure and custom message", giv
|
|
|
10
10
|
afterEach(() => {
|
|
11
11
|
context.fetchStub.restore();
|
|
12
12
|
});
|
|
13
|
-
it("
|
|
14
|
-
it("
|
|
15
|
-
it("
|
|
16
|
-
it("
|
|
17
|
-
it("
|
|
13
|
+
it("should not call server", () => context.fetchStub.called.should.be.false);
|
|
14
|
+
it("should return invalid result", () => result.isValid.should.be.false);
|
|
15
|
+
it("should have validation error", () => result.validationResults.length.should.equal(1));
|
|
16
|
+
it("should have custom error message", () => result.validationResults[0].message.should.equal('Email is required'));
|
|
17
|
+
it("should have error for email property", () => result.validationResults[0].members[0].should.equal('email'));
|
|
18
18
|
}));
|
|
19
19
|
//# sourceMappingURL=with_client_validation_failure_and_custom_message.js.map
|
|
@@ -41,7 +41,7 @@ describe("when executing with client validation passing", () => {
|
|
|
41
41
|
afterEach(() => {
|
|
42
42
|
fetchHelper.restore();
|
|
43
43
|
});
|
|
44
|
-
it("
|
|
44
|
+
it("should call server", async () => {
|
|
45
45
|
await command.execute();
|
|
46
46
|
fetchStub.should.have.been.called;
|
|
47
47
|
});
|
|
@@ -23,7 +23,7 @@ describe("when executing with command properties", given(a_command, context => {
|
|
|
23
23
|
afterEach(() => {
|
|
24
24
|
context.fetchStub.restore();
|
|
25
25
|
});
|
|
26
|
-
it("
|
|
26
|
+
it("should include command properties in body", () => {
|
|
27
27
|
const call = context.fetchStub.getCall(0);
|
|
28
28
|
const body = JSON.parse(call.args[1].body);
|
|
29
29
|
body.someProperty.should.equal('test value');
|
|
@@ -40,12 +40,12 @@ describe("when executing with custom http headers", given(class {
|
|
|
40
40
|
afterEach(() => {
|
|
41
41
|
context.fetchStub.restore();
|
|
42
42
|
});
|
|
43
|
-
it("
|
|
43
|
+
it("should include custom headers", () => {
|
|
44
44
|
const call = context.fetchStub.getCall(0);
|
|
45
45
|
call.args[1].headers['X-Custom-Header'].should.equal('custom-value');
|
|
46
46
|
call.args[1].headers['Authorization'].should.equal('Bearer token123');
|
|
47
47
|
});
|
|
48
|
-
it("
|
|
48
|
+
it("should include default headers", () => {
|
|
49
49
|
const call = context.fetchStub.getCall(0);
|
|
50
50
|
call.args[1].headers['Content-Type'].should.equal('application/json');
|
|
51
51
|
call.args[1].headers['Accept'].should.equal('application/json');
|
|
@@ -32,7 +32,7 @@ describe("when executing with microservice header", given(class extends a_comman
|
|
|
32
32
|
context.fetchStub.restore();
|
|
33
33
|
Globals.microserviceHttpHeader = context.originalMicroserviceHeader;
|
|
34
34
|
});
|
|
35
|
-
it("
|
|
35
|
+
it("should include microservice header", () => {
|
|
36
36
|
const call = context.fetchStub.getCall(0);
|
|
37
37
|
call.args[1].headers['X-Microservice-Id'].should.equal('my-microservice');
|
|
38
38
|
});
|
|
@@ -13,12 +13,12 @@ describe("when executing with missing required property", given(class extends a_
|
|
|
13
13
|
afterEach(() => {
|
|
14
14
|
context.fetchStub.restore();
|
|
15
15
|
});
|
|
16
|
-
it("
|
|
17
|
-
it("
|
|
18
|
-
it("
|
|
19
|
-
it("
|
|
20
|
-
it("
|
|
21
|
-
it("
|
|
22
|
-
it("
|
|
16
|
+
it("should not call fetch", () => context.fetchStub.called.should.be.false);
|
|
17
|
+
it("should return failed result", () => result.isSuccess.should.be.false);
|
|
18
|
+
it("should return invalid result", () => result.isValid.should.be.false);
|
|
19
|
+
it("should return authorized result", () => result.isAuthorized.should.be.true);
|
|
20
|
+
it("should have validation results", () => result.validationResults.length.should.equal(1));
|
|
21
|
+
it("should have validation message for property", () => result.validationResults[0].message.should.equal('someProperty is required'));
|
|
22
|
+
it("should have validation member for property", () => result.validationResults[0].members[0].should.equal('someProperty'));
|
|
23
23
|
}));
|
|
24
24
|
//# sourceMappingURL=with_missing_required_property.js.map
|
|
@@ -36,7 +36,7 @@ describe("when executing with origin and api base path", given(class {
|
|
|
36
36
|
afterEach(() => {
|
|
37
37
|
context.fetchHelper.restore();
|
|
38
38
|
});
|
|
39
|
-
it("
|
|
39
|
+
it("should construct url with origin and base path", () => {
|
|
40
40
|
const call = context.fetchStub.getCall(0);
|
|
41
41
|
const url = call.args[0];
|
|
42
42
|
url.toString().should.contain('https://api.example.com');
|
|
@@ -36,12 +36,12 @@ describe("when executing with route parameters", given(class {
|
|
|
36
36
|
afterEach(() => {
|
|
37
37
|
context.fetchHelper.restore();
|
|
38
38
|
});
|
|
39
|
-
it("
|
|
39
|
+
it("should replace route parameters in url", () => {
|
|
40
40
|
const call = context.fetchStub.getCall(0);
|
|
41
41
|
const url = call.args[0];
|
|
42
42
|
url.toString().should.contain('/api/items/123');
|
|
43
43
|
});
|
|
44
|
-
it("
|
|
44
|
+
it("should include all properties in body", () => {
|
|
45
45
|
const call = context.fetchStub.getCall(0);
|
|
46
46
|
const body = JSON.parse(call.args[1].body);
|
|
47
47
|
body.id.should.equal('123');
|
|
@@ -23,17 +23,17 @@ describe("when executing with successful response", given(a_command, context =>
|
|
|
23
23
|
afterEach(() => {
|
|
24
24
|
context.fetchStub.restore();
|
|
25
25
|
});
|
|
26
|
-
it("
|
|
27
|
-
it("
|
|
26
|
+
it("should call fetch with correct url", () => context.fetchStub.calledOnce.should.be.true);
|
|
27
|
+
it("should call fetch with post method", () => {
|
|
28
28
|
const call = context.fetchStub.getCall(0);
|
|
29
29
|
call.args[1].method.should.equal('POST');
|
|
30
30
|
});
|
|
31
|
-
it("
|
|
31
|
+
it("should call fetch with json headers", () => {
|
|
32
32
|
const call = context.fetchStub.getCall(0);
|
|
33
33
|
call.args[1].headers['Content-Type'].should.equal('application/json');
|
|
34
34
|
call.args[1].headers['Accept'].should.equal('application/json');
|
|
35
35
|
});
|
|
36
|
-
it("
|
|
37
|
-
it("
|
|
36
|
+
it("should return command result", () => (result !== null && result !== undefined).should.be.true);
|
|
37
|
+
it("should set initial values from current values", () => context.command.hasChanges.should.be.false);
|
|
38
38
|
}));
|
|
39
39
|
//# sourceMappingURL=with_successful_response.js.map
|
|
@@ -9,8 +9,8 @@ describe("when validating and fetch throws exception", given(a_command, context
|
|
|
9
9
|
afterEach(() => {
|
|
10
10
|
context.fetchStub.restore();
|
|
11
11
|
});
|
|
12
|
-
it("
|
|
13
|
-
it("
|
|
14
|
-
it("
|
|
12
|
+
it("should return failed result", () => result.isSuccess.should.be.false);
|
|
13
|
+
it("should include error message", () => result.exceptionMessages[0].should.contain('Error during validation call'));
|
|
14
|
+
it("should have exception messages", () => (result.exceptionMessages.length > 0).should.be.true);
|
|
15
15
|
}));
|
|
16
16
|
//# sourceMappingURL=and_fetch_throws_exception.js.map
|
|
@@ -12,7 +12,7 @@ describe("when validating and validation endpoint not found", given(a_command, c
|
|
|
12
12
|
afterEach(() => {
|
|
13
13
|
context.fetchStub.restore();
|
|
14
14
|
});
|
|
15
|
-
it("
|
|
16
|
-
it("
|
|
15
|
+
it("should return failed result", () => result.isSuccess.should.be.false);
|
|
16
|
+
it("should have exception messages", () => (result.exceptionMessages.length > 0).should.be.true);
|
|
17
17
|
}));
|
|
18
18
|
//# sourceMappingURL=and_validation_endpoint_not_found.js.map
|
|
@@ -26,6 +26,6 @@ describe("when validating does not update initial values", given(a_command, cont
|
|
|
26
26
|
afterEach(() => {
|
|
27
27
|
context.fetchStub.restore();
|
|
28
28
|
});
|
|
29
|
-
it("
|
|
29
|
+
it("should still have changes after validation", () => context.command.hasChanges.should.be.true);
|
|
30
30
|
}));
|
|
31
31
|
//# sourceMappingURL=does_not_update_initial_values.js.map
|
|
@@ -10,9 +10,9 @@ describe("when validating with client validation failure", given(a_command_with_
|
|
|
10
10
|
afterEach(() => {
|
|
11
11
|
context.fetchStub.restore();
|
|
12
12
|
});
|
|
13
|
-
it("
|
|
14
|
-
it("
|
|
15
|
-
it("
|
|
16
|
-
it("
|
|
13
|
+
it("should not call server", () => context.fetchStub.called.should.be.false);
|
|
14
|
+
it("should return invalid result", () => result.isValid.should.be.false);
|
|
15
|
+
it("should have validation error", () => result.validationResults.length.should.equal(1));
|
|
16
|
+
it("should have error for email property", () => result.validationResults[0].members[0].should.equal('email'));
|
|
17
17
|
}));
|
|
18
18
|
//# sourceMappingURL=with_client_validation_failure.js.map
|
|
@@ -46,11 +46,11 @@ describe("when validating with client validation passing", () => {
|
|
|
46
46
|
afterEach(() => {
|
|
47
47
|
fetchHelper.restore();
|
|
48
48
|
});
|
|
49
|
-
it("
|
|
50
|
-
it("
|
|
49
|
+
it("should call server", () => fetchStub.calledOnce.should.be.true);
|
|
50
|
+
it("should call validation endpoint", () => {
|
|
51
51
|
const url = fetchStub.getCall(0).args[0];
|
|
52
52
|
url.toString().should.contain('/api/test/validate');
|
|
53
53
|
});
|
|
54
|
-
it("
|
|
54
|
+
it("should return valid result", () => result.isValid.should.be.true);
|
|
55
55
|
});
|
|
56
56
|
//# sourceMappingURL=with_client_validation_passing.js.map
|
|
@@ -13,9 +13,9 @@ describe("when validating with required property missing", given(class extends a
|
|
|
13
13
|
afterEach(() => {
|
|
14
14
|
context.fetchStub.restore();
|
|
15
15
|
});
|
|
16
|
-
it("
|
|
17
|
-
it("
|
|
18
|
-
it("
|
|
19
|
-
it("
|
|
16
|
+
it("should not call server", () => context.fetchStub.called.should.be.false);
|
|
17
|
+
it("should return invalid result", () => result.isValid.should.be.false);
|
|
18
|
+
it("should have validation error", () => result.validationResults.length.should.equal(1));
|
|
19
|
+
it("should have error for missing property", () => result.validationResults[0].members[0].should.equal('someProperty'));
|
|
20
20
|
}));
|
|
21
21
|
//# sourceMappingURL=with_required_property_missing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with_route_parameters.d.ts","sourceRoot":"","sources":["../../../../../commands/for_Command/when_validating/with_route_parameters.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createFetchHelper } from '../../../helpers/fetchHelper';
|
|
2
|
+
import { CommandWithRouteParams } from '../CommandWithRouteParams';
|
|
3
|
+
import { given } from '../../../given';
|
|
4
|
+
describe("when validating with route parameters", given(class {
|
|
5
|
+
command;
|
|
6
|
+
fetchStub;
|
|
7
|
+
fetchHelper;
|
|
8
|
+
constructor() {
|
|
9
|
+
this.command = new CommandWithRouteParams();
|
|
10
|
+
this.command.setOrigin('http://localhost');
|
|
11
|
+
this.command.setApiBasePath('/api');
|
|
12
|
+
this.command.id = '123';
|
|
13
|
+
this.command.name = 'Test Item';
|
|
14
|
+
this.fetchHelper = createFetchHelper();
|
|
15
|
+
this.fetchStub = this.fetchHelper.stubFetch();
|
|
16
|
+
}
|
|
17
|
+
}, context => {
|
|
18
|
+
const responseData = {
|
|
19
|
+
correlationId: '12345678-1234-1234-1234-123456789012',
|
|
20
|
+
isSuccess: true,
|
|
21
|
+
isAuthorized: true,
|
|
22
|
+
isValid: true,
|
|
23
|
+
hasExceptions: false,
|
|
24
|
+
validationResults: [],
|
|
25
|
+
exceptionMessages: [],
|
|
26
|
+
exceptionStackTrace: '',
|
|
27
|
+
response: {}
|
|
28
|
+
};
|
|
29
|
+
beforeEach(async () => {
|
|
30
|
+
context.fetchStub.resolves({
|
|
31
|
+
status: 200,
|
|
32
|
+
json: async () => responseData
|
|
33
|
+
});
|
|
34
|
+
await context.command.validate();
|
|
35
|
+
});
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
context.fetchHelper.restore();
|
|
38
|
+
});
|
|
39
|
+
it("should replace route parameters in url and append validate", () => {
|
|
40
|
+
const call = context.fetchStub.getCall(0);
|
|
41
|
+
const url = call.args[0];
|
|
42
|
+
url.toString().should.contain('/api/items/123/validate');
|
|
43
|
+
});
|
|
44
|
+
it("should include all properties in body", () => {
|
|
45
|
+
const call = context.fetchStub.getCall(0);
|
|
46
|
+
const body = JSON.parse(call.args[1].body);
|
|
47
|
+
body.id.should.equal('123');
|
|
48
|
+
body.name.should.equal('Test Item');
|
|
49
|
+
});
|
|
50
|
+
}));
|
|
51
|
+
//# sourceMappingURL=with_route_parameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with_route_parameters.js","sourceRoot":"","sources":["../../../../../commands/for_Command/when_validating/with_route_parameters.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,QAAQ,CAAC,uCAAuC,EAAE,KAAK,CAAC;IACpD,OAAO,CAAyB;IAChC,SAAS,CAAkB;IAC3B,WAAW,CAA4D;IAEvE;QACI,IAAI,CAAC,OAAO,GAAG,IAAI,sBAAsB,EAAE,CAAC;QAC5C,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,iBAAiB,EAAE,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;IAClD,CAAC;CACJ,EAAE,OAAO,CAAC,EAAE;IACT,MAAM,YAAY,GAAG;QACjB,aAAa,EAAE,sCAAsC;QACrD,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,IAAI;QAClB,OAAO,EAAE,IAAI;QACb,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE,EAAE;QACrB,iBAAiB,EAAE,EAAE;QACrB,mBAAmB,EAAE,EAAE;QACvB,QAAQ,EAAE,EAAE;KACf,CAAC;IAEF,UAAU,CAAC,KAAK,IAAI,EAAE;QAClB,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC;YACvB,MAAM,EAAE,GAAG;YACX,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,YAAY;SACjC,CAAC,CAAC;QAEH,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QAClE,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,GAAG,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC7C,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -23,15 +23,15 @@ describe("when validating with successful response", given(a_command, context =>
|
|
|
23
23
|
afterEach(() => {
|
|
24
24
|
context.fetchStub.restore();
|
|
25
25
|
});
|
|
26
|
-
it("
|
|
26
|
+
it("should call fetch with validate route", () => {
|
|
27
27
|
const call = context.fetchStub.getCall(0);
|
|
28
28
|
const url = call.args[0];
|
|
29
29
|
url.toString().should.contain('/validate');
|
|
30
30
|
});
|
|
31
|
-
it("
|
|
31
|
+
it("should call fetch with post method", () => {
|
|
32
32
|
const call = context.fetchStub.getCall(0);
|
|
33
33
|
call.args[1].method.should.equal('POST');
|
|
34
34
|
});
|
|
35
|
-
it("
|
|
35
|
+
it("should return command result", () => (result !== null && result !== undefined).should.be.true);
|
|
36
36
|
}));
|
|
37
37
|
//# sourceMappingURL=with_successful_response.js.map
|
|
@@ -30,8 +30,8 @@ describe("when validating with validation errors", given(a_command, context => {
|
|
|
30
30
|
afterEach(() => {
|
|
31
31
|
context.fetchStub.restore();
|
|
32
32
|
});
|
|
33
|
-
it("
|
|
34
|
-
it("
|
|
35
|
-
it("
|
|
33
|
+
it("should return invalid result", () => result.isValid.should.be.false);
|
|
34
|
+
it("should not be successful", () => result.isSuccess.should.be.false);
|
|
35
|
+
it("should not update initial values", () => context.command.hasChanges.should.be.false);
|
|
36
36
|
}));
|
|
37
37
|
//# sourceMappingURL=with_validation_errors.js.map
|
|
@@ -10,13 +10,13 @@ describe("with_base_path_ending_with_slash", () => {
|
|
|
10
10
|
route = 'users/123';
|
|
11
11
|
result = UrlHelpers.createUrlFrom(origin, apiBasePath, route);
|
|
12
12
|
});
|
|
13
|
-
it("
|
|
13
|
+
it("should create correct url", () => {
|
|
14
14
|
result.href.should.equal('https://example.com/api/v1/users/123');
|
|
15
15
|
});
|
|
16
|
-
it("
|
|
16
|
+
it("should have correct origin", () => {
|
|
17
17
|
result.origin.should.equal('https://example.com');
|
|
18
18
|
});
|
|
19
|
-
it("
|
|
19
|
+
it("should have correct pathname", () => {
|
|
20
20
|
result.pathname.should.equal('/api/v1/users/123');
|
|
21
21
|
});
|
|
22
22
|
});
|
|
@@ -25,10 +25,10 @@ describe("with_empty_origin", () => {
|
|
|
25
25
|
delete global.document;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
it("
|
|
28
|
+
it("should use document location origin", () => {
|
|
29
29
|
result.origin.should.equal('https://mocked-origin.com');
|
|
30
30
|
});
|
|
31
|
-
it("
|
|
31
|
+
it("should create correct url with document origin", () => {
|
|
32
32
|
result.href.should.equal('https://mocked-origin.com/users/123');
|
|
33
33
|
});
|
|
34
34
|
});
|
|
@@ -22,19 +22,19 @@ describe("with_null_or_undefined_origin", () => {
|
|
|
22
22
|
delete global.document;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
it("
|
|
25
|
+
it("should use document location origin when null", () => {
|
|
26
26
|
result = UrlHelpers.createUrlFrom(null, apiBasePath, route);
|
|
27
27
|
result.origin.should.equal('https://fallback-origin.com');
|
|
28
28
|
});
|
|
29
|
-
it("
|
|
29
|
+
it("should use document location origin when undefined", () => {
|
|
30
30
|
result = UrlHelpers.createUrlFrom(undefined, apiBasePath, route);
|
|
31
31
|
result.origin.should.equal('https://fallback-origin.com');
|
|
32
32
|
});
|
|
33
|
-
it("
|
|
33
|
+
it("should create correct url with document origin when null", () => {
|
|
34
34
|
result = UrlHelpers.createUrlFrom(null, apiBasePath, route);
|
|
35
35
|
result.href.should.equal('https://fallback-origin.com/users/123');
|
|
36
36
|
});
|
|
37
|
-
it("
|
|
37
|
+
it("should create correct url with document origin when undefined", () => {
|
|
38
38
|
result = UrlHelpers.createUrlFrom(undefined, apiBasePath, route);
|
|
39
39
|
result.href.should.equal('https://fallback-origin.com/users/123');
|
|
40
40
|
});
|
|
@@ -10,13 +10,13 @@ describe("with_relative_route", () => {
|
|
|
10
10
|
route = 'users/123';
|
|
11
11
|
result = UrlHelpers.createUrlFrom(origin, apiBasePath, route);
|
|
12
12
|
});
|
|
13
|
-
it("
|
|
13
|
+
it("should create correct url with relative route", () => {
|
|
14
14
|
result.href.should.equal('https://example.com/api/users/123');
|
|
15
15
|
});
|
|
16
|
-
it("
|
|
16
|
+
it("should have correct origin", () => {
|
|
17
17
|
result.origin.should.equal('https://example.com');
|
|
18
18
|
});
|
|
19
|
-
it("
|
|
19
|
+
it("should have correct pathname", () => {
|
|
20
20
|
result.pathname.should.equal('/api/users/123');
|
|
21
21
|
});
|
|
22
22
|
});
|
|
@@ -10,13 +10,13 @@ describe("with_valid_parameters", () => {
|
|
|
10
10
|
route = '/users/123';
|
|
11
11
|
result = UrlHelpers.createUrlFrom(origin, apiBasePath, route);
|
|
12
12
|
});
|
|
13
|
-
it("
|
|
13
|
+
it("should create correct url", () => {
|
|
14
14
|
result.href.should.equal('https://example.com/users/123');
|
|
15
15
|
});
|
|
16
|
-
it("
|
|
16
|
+
it("should have correct origin", () => {
|
|
17
17
|
result.origin.should.equal('https://example.com');
|
|
18
18
|
});
|
|
19
|
-
it("
|
|
19
|
+
it("should have correct pathname", () => {
|
|
20
20
|
result.pathname.should.equal('/users/123');
|
|
21
21
|
});
|
|
22
22
|
});
|
|
@@ -19,7 +19,7 @@ describe("without_document_object", () => {
|
|
|
19
19
|
delete global.document;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
it("
|
|
22
|
+
it("should throw invalid url error", () => {
|
|
23
23
|
(() => UrlHelpers.createUrlFrom(origin, apiBasePath, route)).should.throw('Invalid URL');
|
|
24
24
|
});
|
|
25
25
|
});
|
|
@@ -19,7 +19,7 @@ describe('when refreshing with api base path set', given(an_identity_provider, c
|
|
|
19
19
|
afterEach(() => {
|
|
20
20
|
IdentityProvider.setApiBasePath('');
|
|
21
21
|
});
|
|
22
|
-
it('
|
|
22
|
+
it('should call fetch with api base path prefixed', () => {
|
|
23
23
|
actualUrl.pathname.should.equal('/custom/api/.cratis/me');
|
|
24
24
|
});
|
|
25
25
|
}));
|
package/dist/esm/identity/for_IdentityProvider/when_refreshing/with_globals_api_base_path.js
CHANGED
|
@@ -24,7 +24,7 @@ describe('when refreshing with globals api base path', given(an_identity_provide
|
|
|
24
24
|
Globals.apiBasePath = originalGlobalsApiBasePath;
|
|
25
25
|
IdentityProvider.setApiBasePath('');
|
|
26
26
|
});
|
|
27
|
-
it('
|
|
27
|
+
it('should call fetch with globals api base path prefixed', () => {
|
|
28
28
|
actualUrl.pathname.should.equal('/global/api/.cratis/me');
|
|
29
29
|
});
|
|
30
30
|
}));
|
|
@@ -21,13 +21,13 @@ describe('when refreshing with origin set', given(an_identity_provider, context
|
|
|
21
21
|
IdentityProvider.setOrigin('');
|
|
22
22
|
IdentityProvider.setApiBasePath('');
|
|
23
23
|
});
|
|
24
|
-
it('
|
|
24
|
+
it('should call fetch with full url including origin', () => {
|
|
25
25
|
actualUrl.href.should.equal('https://example.com/api/v1/.cratis/me');
|
|
26
26
|
});
|
|
27
|
-
it('
|
|
27
|
+
it('should have correct origin', () => {
|
|
28
28
|
actualUrl.origin.should.equal('https://example.com');
|
|
29
29
|
});
|
|
30
|
-
it('
|
|
30
|
+
it('should have correct pathname', () => {
|
|
31
31
|
actualUrl.pathname.should.equal('/api/v1/.cratis/me');
|
|
32
32
|
});
|
|
33
33
|
}));
|
|
@@ -23,7 +23,7 @@ describe('when refreshing without api base path', given(an_identity_provider, co
|
|
|
23
23
|
afterEach(() => {
|
|
24
24
|
Globals.apiBasePath = originalGlobalsApiBasePath;
|
|
25
25
|
});
|
|
26
|
-
it('
|
|
26
|
+
it('should call fetch with default path', () => {
|
|
27
27
|
actualUrl.pathname.should.equal('/.cratis/me');
|
|
28
28
|
});
|
|
29
29
|
}));
|
|
@@ -28,16 +28,16 @@ describe("when performing with client validation failing", () => {
|
|
|
28
28
|
query.parameters = { minAge: -5 };
|
|
29
29
|
result = await query.perform(query.parameters);
|
|
30
30
|
});
|
|
31
|
-
it("
|
|
31
|
+
it("should not be success", () => {
|
|
32
32
|
result.isSuccess.should.be.false;
|
|
33
33
|
});
|
|
34
|
-
it("
|
|
34
|
+
it("should not be valid", () => {
|
|
35
35
|
result.isValid.should.be.false;
|
|
36
36
|
});
|
|
37
|
-
it("
|
|
37
|
+
it("should have validation results", () => {
|
|
38
38
|
result.validationResults.should.not.be.empty;
|
|
39
39
|
});
|
|
40
|
-
it("
|
|
40
|
+
it("should have error for minAge", () => {
|
|
41
41
|
result.validationResults.some(r => r.members.includes('minAge')).should.be.true;
|
|
42
42
|
});
|
|
43
43
|
});
|
|
@@ -9,10 +9,10 @@ describe("when performing with client validation failure and custom message", gi
|
|
|
9
9
|
afterEach(() => {
|
|
10
10
|
context.fetchStub.restore();
|
|
11
11
|
});
|
|
12
|
-
it("
|
|
13
|
-
it("
|
|
14
|
-
it("
|
|
15
|
-
it("
|
|
16
|
-
it("
|
|
12
|
+
it("should not call server", () => context.fetchStub.called.should.be.false);
|
|
13
|
+
it("should return invalid result", () => result.isValid.should.be.false);
|
|
14
|
+
it("should have validation error", () => result.validationResults.length.should.equal(1));
|
|
15
|
+
it("should have custom error message", () => result.validationResults[0].message.should.equal('Search term must be at least 3 characters'));
|
|
16
|
+
it("should have error for searchTerm property", () => result.validationResults[0].members[0].should.equal('searchTerm'));
|
|
17
17
|
}));
|
|
18
18
|
//# sourceMappingURL=with_client_validation_failure_and_custom_message.js.map
|
|
@@ -39,7 +39,7 @@ describe("when performing with client validation passing", () => {
|
|
|
39
39
|
afterEach(() => {
|
|
40
40
|
fetchHelper.restore();
|
|
41
41
|
});
|
|
42
|
-
it("
|
|
42
|
+
it("should call server", async () => {
|
|
43
43
|
await query.perform(query.parameters);
|
|
44
44
|
fetchStub.should.have.been.called;
|
|
45
45
|
});
|