Skip to content

Commit

Permalink
chore: rename to DiscountApplicationStrategyCard
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiusj committed Sep 21, 2023
1 parent efb7fc1 commit ee26d4a
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 26 deletions.
2 changes: 1 addition & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@
"oncePerOrderHelpText": "If not selected, the amount will be taken off each eligible item in an order.",
"oncePerOrderHelpTextWithAmount": "If not selected, {fixedAmountValue} will be taken off each eligible item in an order."
},
"DiscountAppStrategyCard": {
"DiscountApplicationStrategyCard": {
"title": "Discount Application Strategy",
"first": {
"label": "First",
Expand Down
1 change: 0 additions & 1 deletion src/components/DiscountAppStrategyCard/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ export interface DiscountAppStrategyProps {
}

const I18N_SCOPE = {
scope: 'DiscountAppComponents.DiscountAppStrategyCard',
scope: 'DiscountAppComponents.DiscountApplicationStrategyCard',
};

export function DiscountAppStrategyCard({strategy}: DiscountAppStrategyProps) {
export function DiscountApplicationStrategyCard({
strategy,
}: DiscountAppStrategyProps) {
const [i18n] = useI18n();

const handleChange = (strategies: DiscountApplicationStrategy[]) =>
Expand Down
1 change: 1 addition & 0 deletions src/components/DiscountApplicationStrategyCard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './DiscountApplicationStrategyCard';
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react';
import {ChoiceList, TextField} from '@shopify/polaris';
import {mockField, mountWithApp} from 'tests/utilities';

import {DiscountAppStrategyCard} from '../DiscountAppStrategyCard';
import {DiscountApplicationStrategyCard} from '../DiscountApplicationStrategyCard';
import {DiscountApplicationStrategy} from '../../../types';

describe('<DiscountAppStrategyCard />', () => {
describe('<DiscountApplicationStrategyCard />', () => {
const mockProps = {
strategy: mockField(DiscountApplicationStrategy.First),
};
Expand All @@ -14,16 +14,20 @@ describe('<DiscountAppStrategyCard />', () => {
jest.resetAllMocks();
});

it('renders a DiscountAppStrategyCard', () => {
const methodCard = mountWithApp(<DiscountAppStrategyCard {...mockProps} />);
it('renders a DiscountApplicationStrategyCard', () => {
const methodCard = mountWithApp(
<DiscountApplicationStrategyCard {...mockProps} />,
);

expect(methodCard).not.toContainReactComponent(TextField, {
label: 'Title',
});
});

it('calls onChange when the strategy is changed', () => {
const methodCard = mountWithApp(<DiscountAppStrategyCard {...mockProps} />);
const methodCard = mountWithApp(
<DiscountApplicationStrategyCard {...mockProps} />,
);

methodCard
.find(ChoiceList)
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ export {onBreadcrumbAction, handleRedirect} from './utilities/navigation';

export {generateRandomDiscountCode} from './components/DiscountCodeGenerator/utilities';
export {ValueCard} from './components/ValueCard';
export {DiscountAppStrategyCard} from './components/DiscountAppStrategyCard';
export {DiscountApplicationStrategyCard} from './components/DiscountApplicationStrategyCard';

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React from 'react';
import {Provider} from '../../foundation/Provider';
import DiscountAppStrategyCard from './DiscountAppStrategyCardPattern';
import DiscountApplicationStrategyCard from './DiscountApplicationStrategyCardPattern';

// eslint-disable-next-line import/no-default-export, import/no-anonymous-default-export
export default {
title: 'DiscountAppStrategyCard pattern',
title: 'DiscountApplicationStrategyCard pattern',
parameters: {
layout: 'fullscreen',
},
};

const ApplicationStrategyCardPattern = () => (
<Provider>
<DiscountAppStrategyCard />
<DiscountApplicationStrategyCard />
</Provider>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, {useState} from 'react';

import {Page} from '@shopify/polaris';
import {DiscountApplicationStrategyCard} from '../../../components/DiscountApplicationStrategyCard';
import {DiscountApplicationStrategy} from '../../../types';

export default function MethodCardPattern() {
const [strategy, setStrategy] = useState<DiscountApplicationStrategy>(
DiscountApplicationStrategy.First,
);
return (
<Page>
<DiscountApplicationStrategyCard
strategy={{
value: strategy,
onChange: setStrategy,
}}
/>
</Page>
);
}

0 comments on commit ee26d4a

Please sign in to comment.