-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c42b48
commit 7a6bdf5
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
packages/codemods/src/transforms/v7/__testfixtures__/horizontal-cell/basic.input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { HorizontalCell, Image } from '@vkontakte/vkui'; | ||
import React from 'react'; | ||
|
||
const App = () => { | ||
return ( | ||
<React.Fragment> | ||
<HorizontalCell | ||
header="Title" | ||
subtitle="Subtitle" | ||
extraSubtitle="Extra Subtitle" | ||
size="m" | ||
> | ||
<Image size={88} borderRadius="l" /> | ||
</HorizontalCell> | ||
|
||
<HorizontalCell | ||
header={'Title'} | ||
subtitle="Subtitle" | ||
extraSubtitle="Extra Subtitle" | ||
size="m" | ||
> | ||
<Image size={88} borderRadius="l" /> | ||
</HorizontalCell> | ||
</React.Fragment> | ||
); | ||
}; |
29 changes: 29 additions & 0 deletions
29
packages/codemods/src/transforms/v7/__tests__/__snapshots__/horizontal-cell.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`horizontal-cell transforms correctly 1`] = ` | ||
"import { HorizontalCell, Image } from '@vkontakte/vkui'; | ||
import React from 'react'; | ||
const App = () => { | ||
return ( | ||
(<React.Fragment> | ||
<HorizontalCell | ||
title="Title" | ||
subtitle="Subtitle" | ||
extraSubtitle="Extra Subtitle" | ||
size="m" | ||
> | ||
<Image size={88} borderRadius="l" /> | ||
</HorizontalCell> | ||
<HorizontalCell | ||
title={'Title'} | ||
subtitle="Subtitle" | ||
extraSubtitle="Extra Subtitle" | ||
size="m" | ||
> | ||
<Image size={88} borderRadius="l" /> | ||
</HorizontalCell> | ||
</React.Fragment>) | ||
); | ||
};" | ||
`; |
12 changes: 12 additions & 0 deletions
12
packages/codemods/src/transforms/v7/__tests__/horizontal-cell.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
jest.autoMockOff(); | ||
|
||
import { defineSnapshotTestFromFixture } from '../../../testHelpers/testHelper'; | ||
|
||
const name = 'horizontal-cell'; | ||
const fixtures = ['basic'] as const; | ||
|
||
describe(name, () => { | ||
fixtures.forEach((test) => | ||
defineSnapshotTestFromFixture(__dirname, name, global.TRANSFORM_OPTIONS, `${name}/${test}`), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { API, FileInfo } from 'jscodeshift'; | ||
import { getImportInfo, renameProp } from '../../codemod-helpers'; | ||
import { JSCodeShiftOptions } from '../../types'; | ||
|
||
export const parser = 'tsx'; | ||
|
||
export default function transformer(file: FileInfo, api: API, options: JSCodeShiftOptions) { | ||
const { alias } = options; | ||
const j = api.jscodeshift; | ||
const source = j(file.source); | ||
const { localName } = getImportInfo(j, file, 'HorizontalCell', alias); | ||
|
||
if (localName) { | ||
renameProp(j, source, localName, { header: 'title' }); | ||
} | ||
|
||
return source.toSource(); | ||
} |