Skip to content

Commit

Permalink
combine callout and upsell codemods to single function
Browse files Browse the repository at this point in the history
  • Loading branch information
Erica Norris committed Dec 18, 2020
1 parent 4f36c11 commit 32f7e13
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 180 deletions.

This file was deleted.

This file was deleted.

@@ -0,0 +1,24 @@
// @flow strict
import React from 'react';
import { Box, Callout, Upsell } from 'gestalt';

export default function TestBox() {
return (
<Box>
<Callout
message="Insert a clever info callout message here"
iconAccessibilityLabel="info"
primaryLink={{ href: 'pinterest.com', label: 'Visit Pinterest' }}
secondaryLink={{ href: 'pinterest.com/help', label: 'Learn more' }}
type="info"
title="A Title"
/>
<Upsell
message="Insert a clever upsell message here"
primaryLink={{ href: 'pinterest.com', label: 'Visit Pinterest' }}
secondaryLink={{ href: 'pinterest.com/help', label: 'Learn more' }}
title="A Title"
/>
</Box>
);
}
@@ -0,0 +1,24 @@
// @flow strict
import React from 'react';
import { Box, Callout, Upsell } from 'gestalt';

export default function TestBox() {
return (
<Box>
<Callout
message="Insert a clever info callout message here"
iconAccessibilityLabel="info"
primaryAction={{ href: 'pinterest.com', label: 'Visit Pinterest' }}
secondaryAction={{ href: 'pinterest.com/help', label: 'Learn more' }}
type="info"
title="A Title"
/>
<Upsell
message="Insert a clever upsell message here"
primaryAction={{ href: 'pinterest.com', label: 'Visit Pinterest' }}
secondaryAction={{ href: 'pinterest.com/help', label: 'Learn more' }}
title="A Title"
/>
</Box>
);
}

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1,28 @@
import { defineTest } from 'jscodeshift/dist/testUtils.js';

jest.mock(
'../callout-upsell-primary-secondary-action-replace-primary-secondary-link',
() => {
return Object.assign(
jest.requireActual(
'../callout-upsell-primary-secondary-action-replace-primary-secondary-link'
),
{
parser: 'flow',
}
);
}
);

describe('callout-upsell-primary-secondary-action-replace-primary-secondary-link', () => {
[
'callout-upsell-primary-secondary-action-replace-primary-secondary-link',
].forEach((test) => {
defineTest(
__dirname,
'callout-upsell-primary-secondary-action-replace-primary-secondary-link',
{ quote: 'single' },
test
);
});
});

This file was deleted.

@@ -1,6 +1,7 @@
/*
* Converts
* <Callout primaryLink={...} secondaryLink={...} /> to <Callout primaryAction={...} secondaryAction={...} />
* <Upsell primaryLink={...} secondaryLink={...} /> to <Upsell primaryAction={...} secondaryAction={...} />
*/

export default function transformer(file, api) {
Expand All @@ -16,7 +17,7 @@ export default function transformer(file, api) {
}

localIdentifierName = decl.specifiers
.filter((node) => node.imported.name === 'Callout')
.filter((node) => ['Upsell', 'Callout'].includes(node.imported.name))
.map((node) => node.local.name);
return null;
});
Expand Down

This file was deleted.

0 comments on commit 32f7e13

Please sign in to comment.