Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PANGOLIN-3515 - CH MoneyDraft & Payment presets #488

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/thin-rivers-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@commercetools-test-data/commons': patch
'@commercetools-test-data/payment': patch
---

Adjustments made to CH MoneyDraft & PaymentDraft presets.
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ it(`should set all fields to specified values`, () => {
}),
}),
]),
paymentStatus: expect.objectContaining({
state: undefined,
}),
})
);
});
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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<TTransactionDraft>();
withUsdCurrencyCodeCentMax().build<TTransactionDraft>();

expect(transactionWithUsdMoneyPreset).toEqual(
expect.objectContaining({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Loading