From 2d920530ce4f6d9578b8b789c949be4765875353 Mon Sep 17 00:00:00 2001 From: Carlos Cortizas Date: Mon, 9 Dec 2024 16:13:57 +0100 Subject: [PATCH] fix(common): fix discounted-line-item-portion model --- models/commons/package.json | 1 - .../src/discounted-line-item-portion/builders.spec.ts | 4 +--- .../src/discounted-line-item-portion/fields-config.ts | 8 ++++---- .../src/discounted-line-item-price/builders.spec.ts | 9 ++------- pnpm-lock.yaml | 3 --- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/models/commons/package.json b/models/commons/package.json index db3997edb..420039f16 100644 --- a/models/commons/package.json +++ b/models/commons/package.json @@ -19,7 +19,6 @@ "dependencies": { "@babel/runtime": "^7.17.9", "@babel/runtime-corejs3": "^7.17.9", - "@commercetools-test-data/cart-discount": "10.10.1", "@commercetools-test-data/core": "10.10.1", "@commercetools-test-data/graphql-types": "10.10.1", "@commercetools-test-data/product-discount": "10.10.1", diff --git a/models/commons/src/discounted-line-item-portion/builders.spec.ts b/models/commons/src/discounted-line-item-portion/builders.spec.ts index 08576bdc9..ce2ef0917 100644 --- a/models/commons/src/discounted-line-item-portion/builders.spec.ts +++ b/models/commons/src/discounted-line-item-portion/builders.spec.ts @@ -25,9 +25,7 @@ describe('DiscountedLineItemPortion Builder', () => { expect(graphqlModel).toEqual( expect.objectContaining({ - discount: expect.objectContaining({ - __typename: 'CartDiscount', - }), + discount: null, discountRef: expect.objectContaining({ id: expect.any(String), typeId: 'cart-discount', diff --git a/models/commons/src/discounted-line-item-portion/fields-config.ts b/models/commons/src/discounted-line-item-portion/fields-config.ts index 212a7ea32..368ef59a0 100644 --- a/models/commons/src/discounted-line-item-portion/fields-config.ts +++ b/models/commons/src/discounted-line-item-portion/fields-config.ts @@ -1,4 +1,4 @@ -import { CartDiscount } from '@commercetools-test-data/cart-discount'; +// import { CartDiscount } from '@commercetools-test-data/cart-discount'; import { fake, type TModelFieldsConfig } from '@commercetools-test-data/core'; import { Money, Reference, TReferenceGraphql } from '../index'; import type { @@ -22,8 +22,8 @@ export const graphqlFieldsConfig: TModelFieldsConfig CartDiscount.random()), - discountRef: null, + discount: null, + discountRef: fake(() => Reference.presets.cartDiscountReference()), __typename: 'DiscountedLineItemPortion', }, postBuild: (model) => { @@ -33,7 +33,7 @@ export const graphqlFieldsConfig: TModelFieldsConfig>() - : undefined, + : model.discountRef, }; }, }; diff --git a/models/commons/src/discounted-line-item-price/builders.spec.ts b/models/commons/src/discounted-line-item-price/builders.spec.ts index 4d9dc5ecb..75eb5551a 100644 --- a/models/commons/src/discounted-line-item-price/builders.spec.ts +++ b/models/commons/src/discounted-line-item-price/builders.spec.ts @@ -30,19 +30,14 @@ describe('DiscountedLineItemPrice Builder', () => { expect(graphqlModel).toEqual( expect.objectContaining({ value: expect.objectContaining({ - centAmount: expect.any(Number), - currencyCode: expect.any(String), + __typename: 'Money', }), includedDiscounts: expect.arrayContaining([ expect.objectContaining({ discountedAmount: expect.objectContaining({ - centAmount: expect.any(Number), - currencyCode: expect.any(String), __typename: 'Money', }), - discount: expect.objectContaining({ - __typename: 'CartDiscount', - }), + discount: null, discountRef: expect.objectContaining({ typeId: 'cart-discount', __typename: 'Reference', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 33cf525e5..be951cc84 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -402,9 +402,6 @@ importers: '@babel/runtime-corejs3': specifier: ^7.17.9 version: 7.24.6 - '@commercetools-test-data/cart-discount': - specifier: 10.10.1 - version: link:../cart-discount '@commercetools-test-data/core': specifier: 10.10.1 version: link:../../core