@daffodil/customer 0.0.0-PLACEHOLDER
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/.eslintrc.js +52 -0
- package/README.md +9 -0
- package/driver/in-memory/ng-package.json +8 -0
- package/driver/in-memory/package.json +3 -0
- package/driver/in-memory/src/backend/address.service.spec.ts +199 -0
- package/driver/in-memory/src/backend/address.service.ts +123 -0
- package/driver/in-memory/src/backend/customer.service.spec.ts +119 -0
- package/driver/in-memory/src/backend/customer.service.ts +126 -0
- package/driver/in-memory/src/driver/address.service.spec.ts +153 -0
- package/driver/in-memory/src/driver/address.service.ts +49 -0
- package/driver/in-memory/src/driver/customer-driver.module.ts +38 -0
- package/driver/in-memory/src/driver/customer.service.spec.ts +131 -0
- package/driver/in-memory/src/driver/customer.service.ts +46 -0
- package/driver/in-memory/src/index.ts +1 -0
- package/driver/in-memory/src/public_api.ts +5 -0
- package/driver/magento/ng-package.json +8 -0
- package/driver/magento/package.json +3 -0
- package/driver/magento/src/address.service.spec.ts +398 -0
- package/driver/magento/src/address.service.ts +147 -0
- package/driver/magento/src/customer-driver.module.ts +41 -0
- package/driver/magento/src/customer.service.spec.ts +348 -0
- package/driver/magento/src/customer.service.ts +101 -0
- package/driver/magento/src/errors/map.ts +6 -0
- package/driver/magento/src/errors/public_api.ts +1 -0
- package/driver/magento/src/errors/transform.ts +40 -0
- package/driver/magento/src/index.ts +1 -0
- package/driver/magento/src/models/gender.enum.ts +4 -0
- package/driver/magento/src/models/public_api.ts +4 -0
- package/driver/magento/src/models/requests/address-attribute-input.type.ts +4 -0
- package/driver/magento/src/models/requests/address-input.type.ts +23 -0
- package/driver/magento/src/models/requests/address-region-input.type.ts +8 -0
- package/driver/magento/src/models/requests/customer-input.type.ts +15 -0
- package/driver/magento/src/models/requests/public_api.ts +4 -0
- package/driver/magento/src/models/responses/change-email.type.ts +7 -0
- package/driver/magento/src/models/responses/change-password.type.ts +5 -0
- package/driver/magento/src/models/responses/create-customer-address.type.ts +5 -0
- package/driver/magento/src/models/responses/customer-address.type.ts +18 -0
- package/driver/magento/src/models/responses/customer.type.ts +9 -0
- package/driver/magento/src/models/responses/delete-customer-address.type.ts +3 -0
- package/driver/magento/src/models/responses/get-customer-addresses.type.ts +5 -0
- package/driver/magento/src/models/responses/get-customer.type.ts +5 -0
- package/driver/magento/src/models/responses/public_api.ts +10 -0
- package/driver/magento/src/models/responses/update-customer-address.type.ts +5 -0
- package/driver/magento/src/models/responses/update-customer.type.ts +7 -0
- package/driver/magento/src/public_api.ts +9 -0
- package/driver/magento/src/queries/change-password.ts +14 -0
- package/driver/magento/src/queries/create-customer-address.ts +12 -0
- package/driver/magento/src/queries/delete-customer-address.ts +7 -0
- package/driver/magento/src/queries/fragments/customer-address.ts +21 -0
- package/driver/magento/src/queries/fragments/customer.ts +16 -0
- package/driver/magento/src/queries/fragments/public_api.ts +2 -0
- package/driver/magento/src/queries/get-customer-addresses.ts +16 -0
- package/driver/magento/src/queries/get-customer.ts +14 -0
- package/driver/magento/src/queries/public_api.ts +10 -0
- package/driver/magento/src/queries/update-customer-address.ts +12 -0
- package/driver/magento/src/queries/update-customer.ts +16 -0
- package/driver/magento/src/queries/update-email.ts +16 -0
- package/driver/magento/src/transforms/public_api.ts +2 -0
- package/driver/magento/src/transforms/requests/address-input.spec.ts +42 -0
- package/driver/magento/src/transforms/requests/address-input.ts +25 -0
- package/driver/magento/src/transforms/requests/customer-input.spec.ts +28 -0
- package/driver/magento/src/transforms/requests/customer-input.ts +9 -0
- package/driver/magento/src/transforms/requests/public_api.ts +2 -0
- package/driver/magento/src/transforms/responses/customer-address.spec.ts +39 -0
- package/driver/magento/src/transforms/responses/customer-address.ts +21 -0
- package/driver/magento/src/transforms/responses/customer.spec.ts +33 -0
- package/driver/magento/src/transforms/responses/customer.ts +13 -0
- package/driver/magento/src/transforms/responses/public_api.ts +2 -0
- package/driver/magento/src/validators/change-email.spec.ts +45 -0
- package/driver/magento/src/validators/change-email.ts +13 -0
- package/driver/magento/src/validators/change-password.spec.ts +45 -0
- package/driver/magento/src/validators/change-password.ts +13 -0
- package/driver/magento/src/validators/create-customer-address.spec.ts +43 -0
- package/driver/magento/src/validators/create-customer-address.ts +13 -0
- package/driver/magento/src/validators/delete-customer-address.spec.ts +38 -0
- package/driver/magento/src/validators/delete-customer-address.ts +13 -0
- package/driver/magento/src/validators/get-customer-addresses.spec.ts +43 -0
- package/driver/magento/src/validators/get-customer-addresses.ts +13 -0
- package/driver/magento/src/validators/get-customer.spec.ts +43 -0
- package/driver/magento/src/validators/get-customer.ts +13 -0
- package/driver/magento/src/validators/public_api.ts +8 -0
- package/driver/magento/src/validators/update-customer-address.spec.ts +43 -0
- package/driver/magento/src/validators/update-customer-address.ts +13 -0
- package/driver/magento/src/validators/update-customer.spec.ts +45 -0
- package/driver/magento/src/validators/update-customer.ts +13 -0
- package/driver/magento/testing/ng-package.json +8 -0
- package/driver/magento/testing/package.json +3 -0
- package/driver/magento/testing/src/factories/address.factory.spec.ts +45 -0
- package/driver/magento/testing/src/factories/address.factory.ts +35 -0
- package/driver/magento/testing/src/factories/customer.factory.spec.ts +36 -0
- package/driver/magento/testing/src/factories/customer.factory.ts +38 -0
- package/driver/magento/testing/src/factories/public_api.ts +2 -0
- package/driver/magento/testing/src/index.ts +1 -0
- package/driver/magento/testing/src/public_api.ts +1 -0
- package/driver/ng-package.json +8 -0
- package/driver/package.json +3 -0
- package/driver/src/errors/address-not-found.ts +17 -0
- package/driver/src/errors/codes.ts +11 -0
- package/driver/src/errors/default-billing-address-deletion.ts +17 -0
- package/driver/src/errors/default-shipping-address-deletion.ts +17 -0
- package/driver/src/errors/invalid-api-response.ts +17 -0
- package/driver/src/errors/map.ts +26 -0
- package/driver/src/errors/public_api.ts +18 -0
- package/driver/src/index.ts +1 -0
- package/driver/src/interfaces/address-service.interface.ts +42 -0
- package/driver/src/interfaces/customer-service.interface.ts +38 -0
- package/driver/src/public_api.ts +10 -0
- package/driver/testing/ng-package.json +8 -0
- package/driver/testing/package.json +3 -0
- package/driver/testing/src/drivers/address.service.spec.ts +61 -0
- package/driver/testing/src/drivers/address.service.ts +45 -0
- package/driver/testing/src/drivers/customer-driver.module.ts +39 -0
- package/driver/testing/src/drivers/customer.service.spec.ts +54 -0
- package/driver/testing/src/drivers/customer.service.ts +40 -0
- package/driver/testing/src/drivers/public_api.ts +3 -0
- package/driver/testing/src/index.ts +1 -0
- package/driver/testing/src/public_api.ts +1 -0
- package/karma.conf.js +11 -0
- package/ng-package.json +7 -0
- package/ng-package.prod.json +7 -0
- package/package.json +42 -0
- package/routing/ng-package.json +8 -0
- package/routing/package.json +3 -0
- package/routing/src/guards/clear-errors.guard.spec.ts +39 -0
- package/routing/src/guards/clear-errors.guard.ts +22 -0
- package/routing/src/guards/public_api.ts +1 -0
- package/routing/src/index.ts +1 -0
- package/routing/src/public_api.ts +2 -0
- package/routing/src/resolvers/customer.resolver.spec.ts +62 -0
- package/routing/src/resolvers/customer.resolver.ts +29 -0
- package/routing/src/resolvers/public_api.ts +1 -0
- package/src/index.ts +1 -0
- package/src/injection-tokens/error-matcher.token.ts +12 -0
- package/src/injection-tokens/public_api.ts +1 -0
- package/src/models/address.type.ts +16 -0
- package/src/models/customer.type.ts +29 -0
- package/src/models/public_api.ts +2 -0
- package/src/public_api.ts +2 -0
- package/state/ng-package.json +8 -0
- package/state/package.json +3 -0
- package/state/src/actions/address.actions.ts +200 -0
- package/state/src/actions/customer.actions.ts +163 -0
- package/state/src/actions/public_api.ts +2 -0
- package/state/src/customer.module.ts +22 -0
- package/state/src/effects/address.effects.spec.ts +267 -0
- package/state/src/effects/address.effects.ts +118 -0
- package/state/src/effects/customer.effects.spec.ts +210 -0
- package/state/src/effects/customer.effects.ts +105 -0
- package/state/src/facades/address/facade.spec.ts +81 -0
- package/state/src/facades/address/facade.ts +77 -0
- package/state/src/facades/address/interface.ts +17 -0
- package/state/src/facades/customer/facade.spec.ts +81 -0
- package/state/src/facades/customer/facade.ts +61 -0
- package/state/src/facades/customer/interface.ts +16 -0
- package/state/src/facades/public_api.ts +4 -0
- package/state/src/index.ts +1 -0
- package/state/src/models/address.type.ts +4 -0
- package/state/src/models/public_api.ts +1 -0
- package/state/src/public_api.ts +7 -0
- package/state/src/reducers/address/initial-state.ts +8 -0
- package/state/src/reducers/address/public_api.ts +3 -0
- package/state/src/reducers/address/reducer.spec.ts +422 -0
- package/state/src/reducers/address/reducer.ts +51 -0
- package/state/src/reducers/address/type.ts +6 -0
- package/state/src/reducers/address-entities/adapter.ts +17 -0
- package/state/src/reducers/address-entities/public_api.ts +2 -0
- package/state/src/reducers/address-entities/reducer.ts +95 -0
- package/state/src/reducers/customer/adapter.spec.ts +51 -0
- package/state/src/reducers/customer/adapter.ts +34 -0
- package/state/src/reducers/customer/initial-state.ts +11 -0
- package/state/src/reducers/customer/interface.ts +10 -0
- package/state/src/reducers/customer/public_api.ts +4 -0
- package/state/src/reducers/customer/reducer.spec.ts +396 -0
- package/state/src/reducers/customer/reducer.ts +65 -0
- package/state/src/reducers/public_api.ts +10 -0
- package/state/src/reducers/reducers.interface.ts +31 -0
- package/state/src/reducers/store-feature-key.ts +4 -0
- package/state/src/reducers/token/extra.token.spec.ts +35 -0
- package/state/src/reducers/token/extra.token.ts +42 -0
- package/state/src/reducers/token/public_api.ts +4 -0
- package/state/src/reducers/token/reducers.token.spec.ts +64 -0
- package/state/src/reducers/token/reducers.token.ts +39 -0
- package/state/src/selectors/address/selector.spec.ts +105 -0
- package/state/src/selectors/address/selector.ts +66 -0
- package/state/src/selectors/customer/selector.spec.ts +80 -0
- package/state/src/selectors/customer/selector.ts +55 -0
- package/state/src/selectors/feature.selector.ts +33 -0
- package/state/src/selectors/public_api.ts +3 -0
- package/state/testing/ng-package.json +8 -0
- package/state/testing/package.json +3 -0
- package/state/testing/src/customer-testing.module.ts +20 -0
- package/state/testing/src/factories/customer-address.factory.spec.ts +39 -0
- package/state/testing/src/factories/customer-address.factory.ts +28 -0
- package/state/testing/src/factories/public_api.ts +1 -0
- package/state/testing/src/index.ts +1 -0
- package/state/testing/src/mock-address-facade.ts +29 -0
- package/state/testing/src/mock-customer-facade.ts +22 -0
- package/state/testing/src/public_api.ts +5 -0
- package/test.ts +23 -0
- package/testing/ng-package.json +8 -0
- package/testing/package.json +3 -0
- package/testing/src/factories/customer-address.factory.spec.ts +39 -0
- package/testing/src/factories/customer-address.factory.ts +27 -0
- package/testing/src/factories/customer.factory.spec.ts +41 -0
- package/testing/src/factories/customer.factory.ts +44 -0
- package/testing/src/factories/public_api.ts +2 -0
- package/testing/src/index.ts +1 -0
- package/testing/src/public_api.ts +1 -0
- package/tsconfig.json +41 -0
- package/tsconfig.lib.json +28 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +17 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { Action } from '@ngrx/store';
|
|
2
|
+
|
|
3
|
+
import { DaffIdentifiable } from '@daffodil/core';
|
|
4
|
+
import { DaffStateError } from '@daffodil/core/state';
|
|
5
|
+
import {
|
|
6
|
+
DaffCustomer,
|
|
7
|
+
DaffCustomerAddress,
|
|
8
|
+
} from '@daffodil/customer';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The customer address action types enum.
|
|
12
|
+
*/
|
|
13
|
+
export enum DaffCustomerAddressActionTypes {
|
|
14
|
+
AddressListAction = '[@daffodil/customer] Address List Action',
|
|
15
|
+
AddressListSuccessAction = '[@daffodil/customer] Address List Success Action',
|
|
16
|
+
AddressListFailureAction = '[@daffodil/customer] Address List Failure Action',
|
|
17
|
+
AddressLoadAction = '[@daffodil/customer] Address Load Action',
|
|
18
|
+
AddressLoadSuccessAction = '[@daffodil/customer] Address Load Success Action',
|
|
19
|
+
AddressLoadFailureAction = '[@daffodil/customer] Address Load Failure Action',
|
|
20
|
+
AddressAddAction = '[@daffodil/customer] Address Add Action',
|
|
21
|
+
AddressAddSuccessAction = '[@daffodil/customer] Address Add Success Action',
|
|
22
|
+
AddressAddFailureAction = '[@daffodil/customer] Address Add Failure Action',
|
|
23
|
+
AddressUpdateAction = '[@daffodil/customer] Address Update Action',
|
|
24
|
+
AddressUpdateSuccessAction = '[@daffodil/customer] Address Update Success Action',
|
|
25
|
+
AddressUpdateFailureAction = '[@daffodil/customer] Address Update Failure Action',
|
|
26
|
+
AddressDeleteAction = '[@daffodil/customer] Address Delete Action',
|
|
27
|
+
AddressDeleteSuccessAction = '[@daffodil/customer] Address Delete Success Action',
|
|
28
|
+
AddressDeleteFailureAction = '[@daffodil/customer] Address Delete Failure Action',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Lists the addresses of the current customer.
|
|
33
|
+
*
|
|
34
|
+
* @param addressId The ID of the address.
|
|
35
|
+
*/
|
|
36
|
+
export class DaffCustomerAddressList implements Action {
|
|
37
|
+
readonly type = DaffCustomerAddressActionTypes.AddressListAction;
|
|
38
|
+
|
|
39
|
+
constructor() {}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Indicates a successful listing of customer addresses.
|
|
44
|
+
*/
|
|
45
|
+
export class DaffCustomerAddressListSuccess<T extends DaffCustomerAddress = DaffCustomerAddress> implements Action {
|
|
46
|
+
readonly type = DaffCustomerAddressActionTypes.AddressListSuccessAction;
|
|
47
|
+
|
|
48
|
+
constructor(public payload: T[]) {}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A failed customer address list with the error message.
|
|
53
|
+
*/
|
|
54
|
+
export class DaffCustomerAddressListFailure implements Action {
|
|
55
|
+
readonly type = DaffCustomerAddressActionTypes.AddressListFailureAction;
|
|
56
|
+
|
|
57
|
+
constructor(public payload: DaffStateError) {}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Loads an address of the current customer.
|
|
62
|
+
*
|
|
63
|
+
* @param addressId The ID of the address.
|
|
64
|
+
*/
|
|
65
|
+
export class DaffCustomerAddressLoad implements Action {
|
|
66
|
+
readonly type = DaffCustomerAddressActionTypes.AddressLoadAction;
|
|
67
|
+
|
|
68
|
+
constructor(public addressId: DaffCustomerAddress['id']) {}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Indicates a successful load of a customer address.
|
|
73
|
+
*/
|
|
74
|
+
export class DaffCustomerAddressLoadSuccess<T extends DaffCustomerAddress = DaffCustomerAddress> implements Action {
|
|
75
|
+
readonly type = DaffCustomerAddressActionTypes.AddressLoadSuccessAction;
|
|
76
|
+
|
|
77
|
+
constructor(public payload: T) {}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A failed customer address load with the error message.
|
|
82
|
+
*/
|
|
83
|
+
export class DaffCustomerAddressLoadFailure implements Action {
|
|
84
|
+
readonly type = DaffCustomerAddressActionTypes.AddressLoadFailureAction;
|
|
85
|
+
|
|
86
|
+
constructor(public payload: DaffStateError, public id: DaffCustomer['id']) {}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Updates one of the currently logged-in customer's addresses.
|
|
91
|
+
*
|
|
92
|
+
* @param query The customer query.
|
|
93
|
+
*/
|
|
94
|
+
export class DaffCustomerAddressUpdate<T extends DaffCustomerAddress = DaffCustomerAddress> implements Action {
|
|
95
|
+
readonly type = DaffCustomerAddressActionTypes.AddressUpdateAction;
|
|
96
|
+
|
|
97
|
+
constructor(public address: Partial<T> & DaffIdentifiable) {}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Indicates a successful update of one of the currently logged-in customer's addresses.
|
|
102
|
+
*/
|
|
103
|
+
export class DaffCustomerAddressUpdateSuccess<T extends DaffCustomerAddress = DaffCustomerAddress> implements Action {
|
|
104
|
+
readonly type = DaffCustomerAddressActionTypes.AddressUpdateSuccessAction;
|
|
105
|
+
|
|
106
|
+
constructor(public payload: T[]) {}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A failed address update with the error message.
|
|
111
|
+
*/
|
|
112
|
+
export class DaffCustomerAddressUpdateFailure implements Action {
|
|
113
|
+
readonly type = DaffCustomerAddressActionTypes.AddressUpdateFailureAction;
|
|
114
|
+
|
|
115
|
+
constructor(public payload: DaffStateError, public id: DaffCustomer['id']) {}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Adds one of the currently logged-in customer's addresses.
|
|
120
|
+
*
|
|
121
|
+
* @param query The customer query.
|
|
122
|
+
*/
|
|
123
|
+
export class DaffCustomerAddressAdd<T extends DaffCustomerAddress = DaffCustomerAddress> implements Action {
|
|
124
|
+
readonly type = DaffCustomerAddressActionTypes.AddressAddAction;
|
|
125
|
+
|
|
126
|
+
constructor(public address: T, public placeholderId?: string) {}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Indicates a successful addition of one of the currently logged-in customer's addresses.
|
|
131
|
+
*
|
|
132
|
+
* @param payload The updated list of customer addresses.
|
|
133
|
+
*/
|
|
134
|
+
export class DaffCustomerAddressAddSuccess<T extends DaffCustomerAddress = DaffCustomerAddress> implements Action {
|
|
135
|
+
readonly type = DaffCustomerAddressActionTypes.AddressAddSuccessAction;
|
|
136
|
+
|
|
137
|
+
constructor(public payload: T[]) {}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* A failed address addition with the error message.
|
|
142
|
+
*/
|
|
143
|
+
export class DaffCustomerAddressAddFailure implements Action {
|
|
144
|
+
readonly type = DaffCustomerAddressActionTypes.AddressAddFailureAction;
|
|
145
|
+
|
|
146
|
+
constructor(public payload: DaffStateError, public id: DaffCustomer['id']) {}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Deletes one of the currently logged-in customer's addresses.
|
|
151
|
+
*
|
|
152
|
+
* @param addressId The ID of the address.
|
|
153
|
+
*/
|
|
154
|
+
export class DaffCustomerAddressDelete implements Action {
|
|
155
|
+
readonly type = DaffCustomerAddressActionTypes.AddressDeleteAction;
|
|
156
|
+
|
|
157
|
+
constructor(public addressId: DaffCustomerAddress['id']) {}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Indicates a successful deletion of one of the currently logged-in customer's addresses.
|
|
162
|
+
*
|
|
163
|
+
* @param payload The updated list of customer addresses.
|
|
164
|
+
*/
|
|
165
|
+
export class DaffCustomerAddressDeleteSuccess<T extends DaffCustomerAddress = DaffCustomerAddress> implements Action {
|
|
166
|
+
readonly type = DaffCustomerAddressActionTypes.AddressDeleteSuccessAction;
|
|
167
|
+
|
|
168
|
+
constructor(public payload: T[]) {}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* A failed address deletion with the error message.
|
|
173
|
+
*/
|
|
174
|
+
export class DaffCustomerAddressDeleteFailure implements Action {
|
|
175
|
+
readonly type = DaffCustomerAddressActionTypes.AddressDeleteFailureAction;
|
|
176
|
+
|
|
177
|
+
constructor(public payload: DaffStateError, public id: DaffCustomer['id']) {}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* A union of the customer action types.
|
|
182
|
+
*/
|
|
183
|
+
export type DaffCustomerAddressActions<
|
|
184
|
+
T extends DaffCustomerAddress = DaffCustomerAddress,
|
|
185
|
+
> =
|
|
186
|
+
| DaffCustomerAddressList
|
|
187
|
+
| DaffCustomerAddressListSuccess<T>
|
|
188
|
+
| DaffCustomerAddressListFailure
|
|
189
|
+
| DaffCustomerAddressLoad
|
|
190
|
+
| DaffCustomerAddressLoadSuccess<T>
|
|
191
|
+
| DaffCustomerAddressLoadFailure
|
|
192
|
+
| DaffCustomerAddressUpdate<T>
|
|
193
|
+
| DaffCustomerAddressUpdateSuccess<T>
|
|
194
|
+
| DaffCustomerAddressUpdateFailure
|
|
195
|
+
| DaffCustomerAddressAdd<T>
|
|
196
|
+
| DaffCustomerAddressAddSuccess<T>
|
|
197
|
+
| DaffCustomerAddressAddFailure
|
|
198
|
+
| DaffCustomerAddressDelete
|
|
199
|
+
| DaffCustomerAddressDeleteSuccess
|
|
200
|
+
| DaffCustomerAddressDeleteFailure;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Action } from '@ngrx/store';
|
|
2
|
+
|
|
3
|
+
import { DaffStateError } from '@daffodil/core/state';
|
|
4
|
+
import { DaffCustomer } from '@daffodil/customer';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The customer action types enum.
|
|
8
|
+
*/
|
|
9
|
+
export enum DaffCustomerActionTypes {
|
|
10
|
+
CustomerLoadAction = '[@daffodil/customer] Customer Load Action',
|
|
11
|
+
CustomerLoadSuccessAction = '[@daffodil/customer] Customer Load Success Action',
|
|
12
|
+
CustomerLoadFailureAction = '[@daffodil/customer] Customer Load Failure Action',
|
|
13
|
+
CustomerUpdateAction = '[@daffodil/customer] Customer Update Action',
|
|
14
|
+
CustomerUpdateSuccessAction = '[@daffodil/customer] Customer Update Success Action',
|
|
15
|
+
CustomerUpdateFailureAction = '[@daffodil/customer] Customer Update Failure Action',
|
|
16
|
+
CustomerChangeEmailAction = '[@daffodil/customer] Customer Change Email Action',
|
|
17
|
+
CustomerChangeEmailSuccessAction = '[@daffodil/customer] Customer Change Email Success Action',
|
|
18
|
+
CustomerChangeEmailFailureAction = '[@daffodil/customer] Customer Change Email Failure Action',
|
|
19
|
+
CustomerChangePasswordAction = '[@daffodil/customer] Customer Change Password Action',
|
|
20
|
+
CustomerChangePasswordSuccessAction = '[@daffodil/customer] Customer Change Password Success Action',
|
|
21
|
+
CustomerChangePasswordFailureAction = '[@daffodil/customer] Customer Change Password Failure Action',
|
|
22
|
+
CustomerClearErrorsAction = '[@daffodil/customer] Customer Clear Errors Action',
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Loads the currently logged-in customer.
|
|
28
|
+
*
|
|
29
|
+
* @param query The customer query.
|
|
30
|
+
*/
|
|
31
|
+
export class DaffCustomerLoad implements Action {
|
|
32
|
+
readonly type = DaffCustomerActionTypes.CustomerLoadAction;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Indicates a successful load of the currently logged-in customer.
|
|
37
|
+
*/
|
|
38
|
+
export class DaffCustomerLoadSuccess<T extends DaffCustomer = DaffCustomer> implements Action {
|
|
39
|
+
readonly type = DaffCustomerActionTypes.CustomerLoadSuccessAction;
|
|
40
|
+
|
|
41
|
+
constructor(public payload: T) {}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A failed customer load with the error message.
|
|
46
|
+
*/
|
|
47
|
+
export class DaffCustomerLoadFailure implements Action {
|
|
48
|
+
readonly type = DaffCustomerActionTypes.CustomerLoadFailureAction;
|
|
49
|
+
|
|
50
|
+
constructor(public payload: DaffStateError) {}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Updates the currently logged-in customer.
|
|
55
|
+
*
|
|
56
|
+
* @param query The customer query.
|
|
57
|
+
*/
|
|
58
|
+
export class DaffCustomerUpdate<T extends DaffCustomer = DaffCustomer> implements Action {
|
|
59
|
+
readonly type = DaffCustomerActionTypes.CustomerUpdateAction;
|
|
60
|
+
|
|
61
|
+
constructor(public customer: Partial<T>) {}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Indicates a successful update of the currently logged-in customer.
|
|
66
|
+
*/
|
|
67
|
+
export class DaffCustomerUpdateSuccess<T extends DaffCustomer = DaffCustomer> implements Action {
|
|
68
|
+
readonly type = DaffCustomerActionTypes.CustomerUpdateSuccessAction;
|
|
69
|
+
|
|
70
|
+
constructor(public payload: T) {}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A failed customer update with the error message.
|
|
75
|
+
*/
|
|
76
|
+
export class DaffCustomerUpdateFailure implements Action {
|
|
77
|
+
readonly type = DaffCustomerActionTypes.CustomerUpdateFailureAction;
|
|
78
|
+
|
|
79
|
+
constructor(public payload: DaffStateError) {}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Changes the email of the currently logged-in customer.
|
|
84
|
+
*
|
|
85
|
+
* @param query The customer query.
|
|
86
|
+
*/
|
|
87
|
+
export class DaffCustomerChangeEmail implements Action {
|
|
88
|
+
readonly type = DaffCustomerActionTypes.CustomerChangeEmailAction;
|
|
89
|
+
|
|
90
|
+
constructor(public email: string, public password: string) {}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Indicates a successful email change of the currently logged-in customer.
|
|
95
|
+
*/
|
|
96
|
+
export class DaffCustomerChangeEmailSuccess<T extends DaffCustomer = DaffCustomer> implements Action {
|
|
97
|
+
readonly type = DaffCustomerActionTypes.CustomerChangeEmailSuccessAction;
|
|
98
|
+
|
|
99
|
+
constructor(public payload: T) {}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* A failed customer email change with the error message.
|
|
104
|
+
*/
|
|
105
|
+
export class DaffCustomerChangeEmailFailure implements Action {
|
|
106
|
+
readonly type = DaffCustomerActionTypes.CustomerChangeEmailFailureAction;
|
|
107
|
+
|
|
108
|
+
constructor(public payload: DaffStateError) {}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Changes the password of the currently logged-in customer.
|
|
113
|
+
*
|
|
114
|
+
* @param query The customer query.
|
|
115
|
+
*/
|
|
116
|
+
export class DaffCustomerChangePassword implements Action {
|
|
117
|
+
readonly type = DaffCustomerActionTypes.CustomerChangePasswordAction;
|
|
118
|
+
|
|
119
|
+
constructor(public newPassword: string, public oldPassword: string) {}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Indicates a successful password change of the currently logged-in customer.
|
|
124
|
+
*/
|
|
125
|
+
export class DaffCustomerChangePasswordSuccess implements Action {
|
|
126
|
+
readonly type = DaffCustomerActionTypes.CustomerChangePasswordSuccessAction;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* A failed customer password change with the error message.
|
|
131
|
+
*/
|
|
132
|
+
export class DaffCustomerChangePasswordFailure implements Action {
|
|
133
|
+
readonly type = DaffCustomerActionTypes.CustomerChangePasswordFailureAction;
|
|
134
|
+
|
|
135
|
+
constructor(public payload: DaffStateError) {}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* An action to clear all customer errors in state.
|
|
140
|
+
*/
|
|
141
|
+
export class DaffCustomerClearErrors implements Action {
|
|
142
|
+
readonly type = DaffCustomerActionTypes.CustomerClearErrorsAction;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* A union of the customer action types.
|
|
147
|
+
*/
|
|
148
|
+
export type DaffCustomerActions<
|
|
149
|
+
T extends DaffCustomer = DaffCustomer,
|
|
150
|
+
> =
|
|
151
|
+
| DaffCustomerLoad
|
|
152
|
+
| DaffCustomerLoadSuccess<T>
|
|
153
|
+
| DaffCustomerLoadFailure
|
|
154
|
+
| DaffCustomerUpdate
|
|
155
|
+
| DaffCustomerUpdateSuccess<T>
|
|
156
|
+
| DaffCustomerUpdateFailure
|
|
157
|
+
| DaffCustomerChangeEmail
|
|
158
|
+
| DaffCustomerChangeEmailSuccess<T>
|
|
159
|
+
| DaffCustomerChangeEmailFailure
|
|
160
|
+
| DaffCustomerChangePassword
|
|
161
|
+
| DaffCustomerChangePasswordSuccess
|
|
162
|
+
| DaffCustomerChangePasswordFailure
|
|
163
|
+
| DaffCustomerClearErrors;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { EffectsModule } from '@ngrx/effects';
|
|
3
|
+
import { StoreModule } from '@ngrx/store';
|
|
4
|
+
|
|
5
|
+
import { DaffCustomerAddressEffects } from './effects/address.effects';
|
|
6
|
+
import { DaffCustomerEffects } from './effects/customer.effects';
|
|
7
|
+
import { DAFF_CUSTOMER_STORE_FEATURE_KEY } from './reducers/public_api';
|
|
8
|
+
import { DAFF_CUSTOMER_REDUCERS } from './reducers/token/reducers.token';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Creates the customer feature store.
|
|
12
|
+
*/
|
|
13
|
+
@NgModule({
|
|
14
|
+
imports: [
|
|
15
|
+
StoreModule.forFeature(DAFF_CUSTOMER_STORE_FEATURE_KEY, DAFF_CUSTOMER_REDUCERS),
|
|
16
|
+
EffectsModule.forFeature([
|
|
17
|
+
DaffCustomerEffects,
|
|
18
|
+
DaffCustomerAddressEffects,
|
|
19
|
+
]),
|
|
20
|
+
],
|
|
21
|
+
})
|
|
22
|
+
export class DaffCustomerStateModule {}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
import { provideMockActions } from '@ngrx/effects/testing';
|
|
3
|
+
import {
|
|
4
|
+
hot,
|
|
5
|
+
cold,
|
|
6
|
+
} from 'jasmine-marbles';
|
|
7
|
+
import {
|
|
8
|
+
Observable,
|
|
9
|
+
of,
|
|
10
|
+
} from 'rxjs';
|
|
11
|
+
|
|
12
|
+
import { daffTransformErrorToStateError } from '@daffodil/core/state';
|
|
13
|
+
import {
|
|
14
|
+
DaffCustomer,
|
|
15
|
+
DaffCustomerAddress,
|
|
16
|
+
} from '@daffodil/customer';
|
|
17
|
+
import {
|
|
18
|
+
DaffCustomerAddressDriverInterface,
|
|
19
|
+
DaffCustomerAddressDriver,
|
|
20
|
+
DaffCustomerInvalidAPIResponseError,
|
|
21
|
+
} from '@daffodil/customer/driver';
|
|
22
|
+
import { DaffCustomerTestingDriverModule } from '@daffodil/customer/driver/testing';
|
|
23
|
+
import {
|
|
24
|
+
DaffCustomerAddressLoad,
|
|
25
|
+
DaffCustomerAddressLoadSuccess,
|
|
26
|
+
DaffCustomerAddressLoadFailure,
|
|
27
|
+
DaffCustomerAddressUpdate,
|
|
28
|
+
DaffCustomerAddressUpdateSuccess,
|
|
29
|
+
DaffCustomerAddressUpdateFailure,
|
|
30
|
+
DaffCustomerAddressDelete,
|
|
31
|
+
DaffCustomerAddressDeleteFailure,
|
|
32
|
+
DaffCustomerAddressDeleteSuccess,
|
|
33
|
+
DaffCustomerAddressAdd,
|
|
34
|
+
DaffCustomerAddressAddFailure,
|
|
35
|
+
DaffCustomerAddressAddSuccess,
|
|
36
|
+
DaffCustomerAddressList,
|
|
37
|
+
DaffCustomerAddressListFailure,
|
|
38
|
+
DaffCustomerAddressListSuccess,
|
|
39
|
+
} from '@daffodil/customer/state';
|
|
40
|
+
import { DaffCustomerAddressFactory } from '@daffodil/customer/testing';
|
|
41
|
+
|
|
42
|
+
import { DaffCustomerAddressEffects } from './address.effects';
|
|
43
|
+
|
|
44
|
+
describe('@daffodil/customer/state | DaffCustomerAddressEffects', () => {
|
|
45
|
+
let actions$: Observable<any>;
|
|
46
|
+
let effects: DaffCustomerAddressEffects;
|
|
47
|
+
|
|
48
|
+
let mockAddress: DaffCustomerAddress;
|
|
49
|
+
|
|
50
|
+
let addressFactory: DaffCustomerAddressFactory;
|
|
51
|
+
|
|
52
|
+
let daffDriver: DaffCustomerAddressDriverInterface;
|
|
53
|
+
let driverListSpy: jasmine.Spy<DaffCustomerAddressDriverInterface['list']>;
|
|
54
|
+
let driverGetSpy: jasmine.Spy<DaffCustomerAddressDriverInterface['get']>;
|
|
55
|
+
let driverUpdateSpy: jasmine.Spy<DaffCustomerAddressDriverInterface['update']>;
|
|
56
|
+
let driverDeleteSpy: jasmine.Spy<DaffCustomerAddressDriverInterface['delete']>;
|
|
57
|
+
let driverAddSpy: jasmine.Spy<DaffCustomerAddressDriverInterface['add']>;
|
|
58
|
+
|
|
59
|
+
beforeEach(() => {
|
|
60
|
+
TestBed.configureTestingModule({
|
|
61
|
+
imports: [
|
|
62
|
+
DaffCustomerTestingDriverModule.forRoot(),
|
|
63
|
+
],
|
|
64
|
+
providers: [
|
|
65
|
+
DaffCustomerAddressEffects,
|
|
66
|
+
provideMockActions(() => actions$),
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
effects = TestBed.inject(DaffCustomerAddressEffects);
|
|
71
|
+
daffDriver = TestBed.inject<DaffCustomerAddressDriverInterface>(DaffCustomerAddressDriver);
|
|
72
|
+
addressFactory = TestBed.inject(DaffCustomerAddressFactory);
|
|
73
|
+
|
|
74
|
+
mockAddress = addressFactory.create();
|
|
75
|
+
|
|
76
|
+
driverListSpy = spyOn(daffDriver, 'list');
|
|
77
|
+
driverGetSpy = spyOn(daffDriver, 'get');
|
|
78
|
+
driverUpdateSpy = spyOn(daffDriver, 'update');
|
|
79
|
+
driverDeleteSpy = spyOn(daffDriver, 'delete');
|
|
80
|
+
driverAddSpy = spyOn(daffDriver, 'add');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should be created', () => {
|
|
84
|
+
expect(effects).toBeTruthy();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('when DaffCustomerAddressListAction is triggered', () => {
|
|
88
|
+
let expected;
|
|
89
|
+
let listAction: DaffCustomerAddressList;
|
|
90
|
+
|
|
91
|
+
beforeEach(() => {
|
|
92
|
+
listAction = new DaffCustomerAddressList();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe('and the call to the driver is successful', () => {
|
|
96
|
+
beforeEach(() => {
|
|
97
|
+
driverListSpy.and.returnValue(of([mockAddress]));
|
|
98
|
+
const listSuccessAction = new DaffCustomerAddressListSuccess([mockAddress]);
|
|
99
|
+
actions$ = hot('--a', { a: listAction });
|
|
100
|
+
expected = cold('--b', { b: listSuccessAction });
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should dispatch a DaffCustomerAddressListSuccess action', () => {
|
|
104
|
+
expect(effects.list$).toBeObservable(expected);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe('and the call to the driver fails', () => {
|
|
109
|
+
beforeEach(() => {
|
|
110
|
+
const error = new DaffCustomerInvalidAPIResponseError('Failed to list customer address');
|
|
111
|
+
const response = cold('#', {}, error);
|
|
112
|
+
driverListSpy.and.returnValue(response);
|
|
113
|
+
const listFailureAction = new DaffCustomerAddressListFailure(daffTransformErrorToStateError(error));
|
|
114
|
+
actions$ = hot('--a', { a: listAction });
|
|
115
|
+
expected = cold('--b', { b: listFailureAction });
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should dispatch a DaffCustomerAddressListFailure action', () => {
|
|
119
|
+
expect(effects.list$).toBeObservable(expected);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('when DaffCustomerAddressLoadAction is triggered', () => {
|
|
125
|
+
let expected;
|
|
126
|
+
let loadAction: DaffCustomerAddressLoad;
|
|
127
|
+
|
|
128
|
+
beforeEach(() => {
|
|
129
|
+
loadAction = new DaffCustomerAddressLoad(mockAddress.id);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe('and the call to the driver is successful', () => {
|
|
133
|
+
beforeEach(() => {
|
|
134
|
+
driverGetSpy.and.returnValue(of(mockAddress));
|
|
135
|
+
const loadSuccessAction = new DaffCustomerAddressLoadSuccess(mockAddress);
|
|
136
|
+
actions$ = hot('--a', { a: loadAction });
|
|
137
|
+
expected = cold('--b', { b: loadSuccessAction });
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should dispatch a DaffCustomerAddressLoadSuccess action', () => {
|
|
141
|
+
expect(effects.get$).toBeObservable(expected);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
describe('and the call to the driver fails', () => {
|
|
146
|
+
beforeEach(() => {
|
|
147
|
+
const error = new DaffCustomerInvalidAPIResponseError('Failed to load customer address');
|
|
148
|
+
const response = cold('#', {}, error);
|
|
149
|
+
driverGetSpy.and.returnValue(response);
|
|
150
|
+
const loadFailureAction = new DaffCustomerAddressLoadFailure(daffTransformErrorToStateError(error), mockAddress.id);
|
|
151
|
+
actions$ = hot('--a', { a: loadAction });
|
|
152
|
+
expected = cold('--b', { b: loadFailureAction });
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should dispatch a DaffCustomerAddressLoadFailure action', () => {
|
|
156
|
+
expect(effects.get$).toBeObservable(expected);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
describe('when DaffCustomerAddressUpdateAction is triggered', () => {
|
|
162
|
+
let expected;
|
|
163
|
+
let updateAction: DaffCustomerAddressUpdate;
|
|
164
|
+
|
|
165
|
+
beforeEach(() => {
|
|
166
|
+
updateAction = new DaffCustomerAddressUpdate(mockAddress);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe('and the call to the driver is successful', () => {
|
|
170
|
+
beforeEach(() => {
|
|
171
|
+
driverUpdateSpy.and.returnValue(of([mockAddress]));
|
|
172
|
+
const updateSuccessAction = new DaffCustomerAddressUpdateSuccess([mockAddress]);
|
|
173
|
+
actions$ = hot('--a', { a: updateAction });
|
|
174
|
+
expected = cold('--b', { b: updateSuccessAction });
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('should dispatch a DaffCustomerAddressUpdateSuccess action', () => {
|
|
178
|
+
expect(effects.update$).toBeObservable(expected);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
describe('and the call to the driver fails', () => {
|
|
183
|
+
beforeEach(() => {
|
|
184
|
+
const error = new DaffCustomerInvalidAPIResponseError('Failed to load customer address');
|
|
185
|
+
const response = cold('#', {}, error);
|
|
186
|
+
driverUpdateSpy.and.returnValue(response);
|
|
187
|
+
const updateFailureAction = new DaffCustomerAddressUpdateFailure(daffTransformErrorToStateError(error), mockAddress.id);
|
|
188
|
+
actions$ = hot('--a', { a: updateAction });
|
|
189
|
+
expected = cold('--b', { b: updateFailureAction });
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('should dispatch a DaffCustomerAddressUpdateFailure action', () => {
|
|
193
|
+
expect(effects.update$).toBeObservable(expected);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
describe('when DaffCustomerAddressDeleteAction is triggered', () => {
|
|
199
|
+
let expected;
|
|
200
|
+
let deleteAction: DaffCustomerAddressDelete;
|
|
201
|
+
|
|
202
|
+
beforeEach(() => {
|
|
203
|
+
deleteAction = new DaffCustomerAddressDelete(mockAddress.id);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe('and the call to the driver is successful', () => {
|
|
207
|
+
beforeEach(() => {
|
|
208
|
+
driverDeleteSpy.and.returnValue(of([]));
|
|
209
|
+
const deleteSuccessAction = new DaffCustomerAddressDeleteSuccess([]);
|
|
210
|
+
actions$ = hot('--a', { a: deleteAction });
|
|
211
|
+
expected = cold('--b', { b: deleteSuccessAction });
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('should dispatch a DaffCustomerAddressDeleteSuccess action', () => {
|
|
215
|
+
expect(effects.delete$).toBeObservable(expected);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
describe('and the call to the driver fails', () => {
|
|
220
|
+
beforeEach(() => {
|
|
221
|
+
const error = new DaffCustomerInvalidAPIResponseError('Failed to load customer address');
|
|
222
|
+
const response = cold('#', {}, error);
|
|
223
|
+
driverDeleteSpy.and.returnValue(response);
|
|
224
|
+
const deleteFailureAction = new DaffCustomerAddressDeleteFailure(daffTransformErrorToStateError(error), mockAddress.id);
|
|
225
|
+
actions$ = hot('--a', { a: deleteAction });
|
|
226
|
+
expected = cold('--b', { b: deleteFailureAction });
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('should dispatch a DaffCustomerAddressDeleteFailure action', () => {
|
|
230
|
+
expect(effects.delete$).toBeObservable(expected);
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
describe('when DaffCustomerAddressAddAction is triggered', () => {
|
|
236
|
+
let expected;
|
|
237
|
+
const customerAddAction = new DaffCustomerAddressAdd(mockAddress, 'placeholder');
|
|
238
|
+
|
|
239
|
+
describe('and the call to the driver is successful', () => {
|
|
240
|
+
beforeEach(() => {
|
|
241
|
+
driverAddSpy.and.returnValue(of([mockAddress]));
|
|
242
|
+
const customerAddSuccessAction = new DaffCustomerAddressAddSuccess([mockAddress]);
|
|
243
|
+
actions$ = hot('--a', { a: customerAddAction });
|
|
244
|
+
expected = cold('--b', { b: customerAddSuccessAction });
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('should dispatch a DaffCustomerAddressAddSuccess action', () => {
|
|
248
|
+
expect(effects.add$).toBeObservable(expected);
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
describe('and the call to the driver fails', () => {
|
|
253
|
+
beforeEach(() => {
|
|
254
|
+
const error = new DaffCustomerInvalidAPIResponseError('Failed to load customer address');
|
|
255
|
+
const response = cold('#', {}, error);
|
|
256
|
+
driverAddSpy.and.returnValue(response);
|
|
257
|
+
const customerAddFailureAction = new DaffCustomerAddressAddFailure(daffTransformErrorToStateError(error), 'placeholder');
|
|
258
|
+
actions$ = hot('--a', { a: customerAddAction });
|
|
259
|
+
expected = cold('--b', { b: customerAddFailureAction });
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('should dispatch a DaffCustomerAddressAddFailure action', () => {
|
|
263
|
+
expect(effects.add$).toBeObservable(expected);
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
});
|