Skip to content

Commit 0dd6576

Browse files
committed
feature: @putout/plugin-putout: replace-test-message: transform with options -> transform
1 parent 414251e commit 0dd6576

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
test('plugin-putout: convert-traverse-to-include: transform', (t) => {
2+
t.transform('traverse');
3+
t.end();
4+
});
5+
6+
t.transform('abc');
7+
8+
test((t) => {
9+
t.transform('traverse');
10+
t.end();
11+
});
12+
13+
test('lib: select: transform', (t) => {
14+
t.transform('select');
15+
t.end();
16+
});

packages/plugin-putout/lib/replace-test-message/fixture/transform.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ test((t) => {
99
t.transform('traverse');
1010
t.end();
1111
});
12+
13+
test('lib: select: transform with options', (t) => {
14+
t.transform('select');
15+
t.end();
16+
});
17+

packages/plugin-putout/lib/replace-test-message/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const INCORRECT = {
1717
NO_REPORT: /: (no report after transform|report|(transform|no transform)(\swith options)?)/,
1818
NO_REPORT_AFTER_TRANSFORM: /: (report|transform|no transform|no report)/,
1919
NO_REPORT_WITH_OPTIONS: /: (no report after transform(\swith options)?|report|transform|no transform|no report)/,
20-
TRANSFORM: /: (no report after transform|no transform|report|no report)/,
20+
TRANSFORM: /: (transform with options|no report after transform|no transform|report|no report)/,
2121
NO_TRANSFORM: /: (no report after transform|transform|report|no report)/,
2222
TRANSFORM_WITH_OPTIONS: /: (no report after transform|transform|no transform(\swith options)?|report|no report)/,
2323
NO_TRANSFORM_WITH_OPTIONS: /: (no report after transform|transform(\swith options)?|no transform|report|no report)/,
@@ -109,10 +109,19 @@ function isCorrect({path, correct, incorrect}) {
109109

110110
const {value} = messagePath.node;
111111

112-
if (value.includes(correct))
112+
if (containsCorrect(value, correct))
113113
return [CORRECT];
114114

115115
const is = !incorrect.test(value);
116116

117117
return [is, messagePath];
118118
}
119+
120+
function containsCorrect(value, correct) {
121+
if (!value.includes(correct))
122+
return false;
123+
124+
const nextIndex = value.indexOf(correct) + correct.length;
125+
126+
return value.charAt(nextIndex) !== ' ';
127+
}

packages/plugin-putout/lib/replace-test-message/index.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test('plugin-putout: replace-test-message: transform', (t) => {
1818
});
1919

2020
test('plugin-putout: replace-test-message: no report', (t) => {
21-
t.noReport('transform');
21+
t.transform('transform');
2222
t.end();
2323
});
2424

0 commit comments

Comments
 (0)