Skip to content

Commit 41b807a

Browse files
committed
feature: @putout/plugin-tape: convert-deep-equal-to-equal: join
1 parent 7b2ae8a commit 41b807a

4 files changed

Lines changed: 41 additions & 2 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
test('palabra: borrar', (t) => {
2+
const result = borrar(['hello', 'world'], {
3+
directorio: '~/.local/share',
4+
});
5+
6+
const expected = [
7+
'rm rf ~/.local/share/hello',
8+
'rm rf ~/.local/bin/hello',
9+
'rm rf ~/.local/share/world',
10+
'rm rf ~/.local/bin/world',
11+
].join(' && ');
12+
13+
t.equal(result, expected);
14+
t.end();
15+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
test('palabra: borrar', (t) => {
2+
const result = borrar(['hello', 'world'], {
3+
directorio: '~/.local/share',
4+
});
5+
const expected = [
6+
'rm rf ~/.local/share/hello',
7+
'rm rf ~/.local/bin/hello',
8+
'rm rf ~/.local/share/world',
9+
'rm rf ~/.local/bin/world',
10+
].join(' && ');
11+
12+
t.deepEqual(result, expected);
13+
t.end();
14+
});
15+
16+

packages/plugin-tape/lib/convert-deep-equal-to-equal/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const isBool = (a) => typeof a === 'boolean';
66
const isNumber = (a) => typeof a === 'number';
77
const isString = (a) => typeof a === 'string';
88
const isPrimitive = (a) => isString(a) || isNumber(a) || isBool(a) || isNull(a) || isUndefined(a);
9-
const {compute} = operator;
9+
const {compute, compare} = operator;
1010

1111
const {
1212
isLiteral,
@@ -68,5 +68,8 @@ function checkExpected(path) {
6868

6969
const initPath = binding.path.get('init');
7070

71-
return initPath.isTaggedTemplateExpression();
71+
if (initPath.isTaggedTemplateExpression())
72+
return true;
73+
74+
return compare(initPath, '__array.join(__b)');
7275
}

packages/plugin-tape/lib/convert-deep-equal-to-equal/index.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ test('plugin-tape: convert-deep-equal-to-equal: transform: bool', (t) => {
4242
t.end();
4343
});
4444

45+
test('plugin-tape: convert-deep-equal-to-equal: transform: join', (t) => {
46+
t.transform('join');
47+
t.end();
48+
});
49+
4550
test('plugin-tape: convert-deep-equal-to-equal: no transform: expected', (t) => {
4651
t.noTransform('expected');
4752
t.end();

0 commit comments

Comments
 (0)