@labdigital/commercetools-mock 0.13.0 → 0.14.1

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": "0.13.0",
4
+ "version": "0.14.1",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/commercetools--mock.esm.js",
@@ -87,6 +87,7 @@
87
87
  "start": "nodemon --watch src --exec 'node -r esbuild-register' src/server.ts",
88
88
  "build": "tsup",
89
89
  "build:server": "esbuild src/server.ts --bundle --outfile=dist/server.js --platform=node",
90
+ "publish:ci": "pnpm build && pnpm changeset publish",
90
91
  "check": "eslint src && tsc",
91
92
  "test": "jest test --coverage",
92
93
  "lint": "eslint src"
@@ -20,6 +20,7 @@ import { ProductProjectionService } from './product-projection'
20
20
  import { ProductTypeService } from './product-type'
21
21
  import { ShippingMethodService } from './shipping-method'
22
22
  import { ShoppingListService } from './shopping-list'
23
+ import { StandAlonePriceService } from './standalone-price'
23
24
  import { StateService } from './state'
24
25
  import { StoreService } from './store'
25
26
  import { SubscriptionService } from './subscription'
@@ -46,6 +47,7 @@ export const createServices = (router: any, repos: any) => ({
46
47
  ),
47
48
  order: new OrderService(router, repos['order']),
48
49
  payment: new PaymentService(router, repos['payment']),
50
+ 'standalone-price': new StandAlonePriceService(router, repos['standalone-price']),
49
51
  'my-cart': new MyCartService(router, repos['my-cart']),
50
52
  'my-order': new MyOrderService(router, repos['my-order']),
51
53
  'my-customer': new MyCustomerService(router, repos['my-customer']),
@@ -0,0 +1,37 @@
1
+ import { StandalonePriceDraft } from '@commercetools/platform-sdk'
2
+ import supertest from 'supertest'
3
+ import { CommercetoolsMock } from '../index'
4
+
5
+ const ctMock = new CommercetoolsMock()
6
+
7
+ describe('StandalonePrice', () => {
8
+ test('Create standalone price', async () => {
9
+ const draft: StandalonePriceDraft = {
10
+ sku: 'test-sku',
11
+ value: {
12
+ currencyCode: 'EUR',
13
+ centAmount: 1000,
14
+ },
15
+ active: true,
16
+ }
17
+
18
+ const response = await supertest(ctMock.app).post('/dummy/standalone-prices').send(draft)
19
+ expect(response.status).toBe(201)
20
+ })
21
+
22
+ test('Get standalone price', async () => {
23
+ const draft: StandalonePriceDraft = {
24
+ sku: 'test-sku',
25
+ value: {
26
+ currencyCode: 'EUR',
27
+ centAmount: 1000,
28
+ },
29
+ active: true,
30
+ }
31
+
32
+ const createResponse = await supertest(ctMock.app).post('/dummy/standalone-prices').send(draft)
33
+
34
+ const response = await supertest(ctMock.app).get(`/dummy/standalone-prices/${createResponse.body.id}`)
35
+ expect(response.status).toBe(200)
36
+ })
37
+ })
@@ -0,0 +1,16 @@
1
+ import { Router } from 'express'
2
+ import { StandAlonePriceRepository } from '../repositories/standalone-price'
3
+ import AbstractService from './abstract'
4
+
5
+ export class StandAlonePriceService extends AbstractService {
6
+ public repository: StandAlonePriceRepository
7
+
8
+ constructor(parent: Router, repository: StandAlonePriceRepository) {
9
+ super(parent)
10
+ this.repository = repository
11
+ }
12
+
13
+ getBasePath() {
14
+ return 'standalone-prices'
15
+ }
16
+ }