@labdigital/commercetools-mock 2.14.1 → 2.14.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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/services/my-customer.test.ts +23 -0
- package/src/services/my-customer.ts +7 -3
package/package.json
CHANGED
|
@@ -150,6 +150,29 @@ describe('/me', () => {
|
|
|
150
150
|
expect(response.status).toBe(200)
|
|
151
151
|
})
|
|
152
152
|
|
|
153
|
+
test('Fail to change password', async () => {
|
|
154
|
+
const draft: CustomerChangePassword = {
|
|
155
|
+
id: 'foo',
|
|
156
|
+
version: 1,
|
|
157
|
+
newPassword: 'newP4ssw0rd',
|
|
158
|
+
currentPassword: 'p4ssw0rd',
|
|
159
|
+
}
|
|
160
|
+
const response = await supertest(ctMock.app)
|
|
161
|
+
.post('/dummy/me/password')
|
|
162
|
+
.send(draft)
|
|
163
|
+
|
|
164
|
+
expect(response.status).toBe(404)
|
|
165
|
+
expect(response.body).toEqual({
|
|
166
|
+
errors: [
|
|
167
|
+
{
|
|
168
|
+
code: 'InvalidCurrentPassword',
|
|
169
|
+
message: 'Account with the given credentials not found.',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
message: 'Account with the given credentials not found.',
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
|
|
153
176
|
test('setCustomField', async () => {
|
|
154
177
|
const response = await supertest(ctMock.app)
|
|
155
178
|
.post(`/dummy/me`)
|
|
@@ -3,7 +3,11 @@ import { CustomerRepository } from '../repositories/customer.js'
|
|
|
3
3
|
import { getRepositoryContext } from '../repositories/helpers.js'
|
|
4
4
|
import AbstractService from './abstract.js'
|
|
5
5
|
import { hashPassword } from '../lib/password.js'
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
Customer,
|
|
8
|
+
Update,
|
|
9
|
+
InvalidCurrentPasswordError,
|
|
10
|
+
} from '@commercetools/platform-sdk'
|
|
7
11
|
|
|
8
12
|
export class MyCustomerService extends AbstractService {
|
|
9
13
|
public repository: CustomerRepository
|
|
@@ -93,9 +97,9 @@ export class MyCustomerService extends AbstractService {
|
|
|
93
97
|
message: 'Account with the given credentials not found.',
|
|
94
98
|
errors: [
|
|
95
99
|
{
|
|
96
|
-
code: '
|
|
100
|
+
code: 'InvalidCurrentPassword',
|
|
97
101
|
message: 'Account with the given credentials not found.',
|
|
98
|
-
},
|
|
102
|
+
} as InvalidCurrentPasswordError,
|
|
99
103
|
],
|
|
100
104
|
})
|
|
101
105
|
}
|