diff --git a/.changeset/thin-rivers-film.md b/.changeset/thin-rivers-film.md new file mode 100644 index 000000000..a9338cfea --- /dev/null +++ b/.changeset/thin-rivers-film.md @@ -0,0 +1,6 @@ +--- +'@commercetools-test-data/commons': patch +'@commercetools-test-data/payment': patch +--- + +Adjustments made to CH MoneyDraft & PaymentDraft presets. diff --git a/models/commons/src/money/money-draft/presets/change-history-data/with-usd-currency-code-max-cent.ts b/models/commons/src/money/money-draft/presets/change-history-data/with-usd-currency-code-max-cent.ts index 4e340778a..0b6164952 100644 --- a/models/commons/src/money/money-draft/presets/change-history-data/with-usd-currency-code-max-cent.ts +++ b/models/commons/src/money/money-draft/presets/change-history-data/with-usd-currency-code-max-cent.ts @@ -1,11 +1,11 @@ import { TMoneyDraftBuilder } from '../../../types'; import MoneyDraft from '../../builder'; -const random10DigitNumber = (): number => { - return Math.floor(1000000000 + Math.random() * 9000000000); +const range32Bit = (): number => { + return Math.floor(Math.random() * 2147483648); }; const withUsdCurrencyCodeCentMax = (): TMoneyDraftBuilder => - MoneyDraft().currencyCode('USD').centAmount(random10DigitNumber()); + MoneyDraft().currencyCode('USD').centAmount(range32Bit()); export default withUsdCurrencyCodeCentMax; diff --git a/models/payment/src/payment/payment-draft/presets/change-history-data/with-usd-currency-code.spec.ts b/models/payment/src/payment/payment-draft/presets/change-history-data/with-usd-currency-code.spec.ts index 91d44ebce..8ce630e4f 100644 --- a/models/payment/src/payment/payment-draft/presets/change-history-data/with-usd-currency-code.spec.ts +++ b/models/payment/src/payment/payment-draft/presets/change-history-data/with-usd-currency-code.spec.ts @@ -22,6 +22,9 @@ it(`should set all fields to specified values`, () => { }), }), ]), + paymentStatus: expect.objectContaining({ + state: undefined, + }), }) ); }); diff --git a/models/payment/src/payment/payment-draft/presets/change-history-data/with-usd-currency-code.ts b/models/payment/src/payment/payment-draft/presets/change-history-data/with-usd-currency-code.ts index 078cccaa6..6f6ec8fb6 100644 --- a/models/payment/src/payment/payment-draft/presets/change-history-data/with-usd-currency-code.ts +++ b/models/payment/src/payment/payment-draft/presets/change-history-data/with-usd-currency-code.ts @@ -1,14 +1,18 @@ import { MoneyDraft } from '@commercetools-test-data/commons'; import * as PaymentDraft from '../..'; +import { PaymentStatusDraft } from '../../../../payment-status'; import { TransactionDraft } from '../../../../transaction'; import type { TPaymentDraftBuilder } from '../../../types'; const withUsdCurrencyCode = (): TPaymentDraftBuilder => PaymentDraft.random() .anonymousId(undefined) - .amountPlanned(MoneyDraft.presets.changeHistoryData.withUsdCurrencyCode()) + .amountPlanned( + MoneyDraft.presets.changeHistoryData.withUsdCurrencyCodeCentMax() + ) + .paymentStatus(PaymentStatusDraft.random().state(undefined)) .transactions([ - TransactionDraft.presets.changeHistoryData.withTransactionUsdCurrencyCodeMaxCent(), + TransactionDraft.presets.changeHistoryData.withUsdCurrencyCodeCentMax(), ]); export default withUsdCurrencyCode; diff --git a/models/payment/src/transaction/transaction-draft/presets/change-history-data/index.ts b/models/payment/src/transaction/transaction-draft/presets/change-history-data/index.ts index 4e45e44e7..c0a44ab92 100644 --- a/models/payment/src/transaction/transaction-draft/presets/change-history-data/index.ts +++ b/models/payment/src/transaction/transaction-draft/presets/change-history-data/index.ts @@ -1,7 +1,7 @@ -import withTransactionUsdCurrencyCodeMaxCent from './with-usd-currency-code-max-cent'; +import withUsdCurrencyCodeCentMax from './with-usd-currency-code-max-cent'; const presets = { - withTransactionUsdCurrencyCodeMaxCent, + withUsdCurrencyCodeCentMax, }; export default presets; diff --git a/models/payment/src/transaction/transaction-draft/presets/change-history-data/with-usd-currency-code-max-cent.spec.ts b/models/payment/src/transaction/transaction-draft/presets/change-history-data/with-usd-currency-code-max-cent.spec.ts index f96aa84aa..bc854f4d8 100644 --- a/models/payment/src/transaction/transaction-draft/presets/change-history-data/with-usd-currency-code-max-cent.spec.ts +++ b/models/payment/src/transaction/transaction-draft/presets/change-history-data/with-usd-currency-code-max-cent.spec.ts @@ -1,10 +1,10 @@ import { TTransactionDraft } from '../../../types'; -import withTransactionUsdCurrencyCodeMaxCent from './with-usd-currency-code-max-cent'; +import withUsdCurrencyCodeCentMax from './with-usd-currency-code-max-cent'; describe('Transaction with with the amount money of `USD` currencyCode and max cent amount preset', () => { it('should return the currencyCode of `USD` with a max cent amount', () => { const transactionWithUsdMoneyPreset = - withTransactionUsdCurrencyCodeMaxCent().build(); + withUsdCurrencyCodeCentMax().build(); expect(transactionWithUsdMoneyPreset).toEqual( expect.objectContaining({ diff --git a/models/payment/src/transaction/transaction-draft/presets/change-history-data/with-usd-currency-code-max-cent.ts b/models/payment/src/transaction/transaction-draft/presets/change-history-data/with-usd-currency-code-max-cent.ts index 11d45b3c1..cb916d704 100644 --- a/models/payment/src/transaction/transaction-draft/presets/change-history-data/with-usd-currency-code-max-cent.ts +++ b/models/payment/src/transaction/transaction-draft/presets/change-history-data/with-usd-currency-code-max-cent.ts @@ -2,9 +2,9 @@ import { MoneyDraft } from '@commercetools-test-data/commons'; import type { TTransactionDraftBuilder } from '../../../types'; import * as TransactionDraft from '../../index'; -const withTransactionUsdCurrencyCodeMaxCent = (): TTransactionDraftBuilder => +const withUsdCurrencyCodeCentMax = (): TTransactionDraftBuilder => TransactionDraft.random().amount( MoneyDraft.presets.changeHistoryData.withUsdCurrencyCodeCentMax() ); -export default withTransactionUsdCurrencyCodeMaxCent; +export default withUsdCurrencyCodeCentMax;