Skip to content

Commit 69d0bde

Browse files
committed
test(cli): add code migration example
1 parent 28050ae commit 69d0bde

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import assert from 'node:assert';
2+
import fs from 'fs';
3+
import os from 'os';
4+
import path from 'path';
5+
import { RenamePropertyNameTask } from '../src/migrate/runner/tasks/common/RenamePropertyNameTask';
6+
7+
8+
describe('RenamePropertyNameTask', () => {
9+
it('renames property in code files', () => {
10+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'kolibri-cli-'));
11+
const tsxPath = path.join(tmpDir, 'component.tsx');
12+
fs.writeFileSync(tsxPath, '<KolButton _icon="close" />');
13+
const htmlPath = path.join(tmpDir, 'sample.html');
14+
fs.writeFileSync(htmlPath, '<kol-button _icon="close"></kol-button>');
15+
16+
const task = RenamePropertyNameTask.getInstance('kol-button', '_icon', '_icons', '^1');
17+
task.run(tmpDir);
18+
19+
const tsxContent = fs.readFileSync(tsxPath, 'utf8');
20+
const htmlContent = fs.readFileSync(htmlPath, 'utf8');
21+
assert.ok(tsxContent.includes('_icons'));
22+
assert.ok(htmlContent.includes('_icons'));
23+
});
24+
});

0 commit comments

Comments
 (0)