@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@labdigital/commercetools-mock",
3
3
  "author": "Michael van Tellingen",
4
- "version": "2.14.1",
4
+ "version": "2.14.2",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
@@ -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 { Customer, Update } from '@commercetools/platform-sdk'
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: 'InvalidCredentials',
100
+ code: 'InvalidCurrentPassword',
97
101
  message: 'Account with the given credentials not found.',
98
- },
102
+ } as InvalidCurrentPasswordError,
99
103
  ],
100
104
  })
101
105
  }