Skip to content

Commit 2a0cb7d

Browse files
committed
test: resolve local plugin, issue #336, #338
1 parent 8307ed3 commit 2a0cb7d

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

test/plugins/custom-plugin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = function (options) {
2+
return function (tree) {
3+
return tree;
4+
};
5+
}

test/test-cli.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ test('Transform html from two file', async t => {
6565
t.is((await read('test/expected/output-indent.html')), (await read(`${folder}/input-indent.html`)));
6666
});
6767

68+
test('Dont not transform html with local plugin', async t => {
69+
const filename = tempfile('.html');
70+
await execa(cli, [
71+
'test/fixtures/input.html',
72+
'-o',
73+
filename,
74+
'-u',
75+
'test/plugins/custom-plugin.js',
76+
]);
77+
t.true(await pathExists(filename));
78+
t.is((await read('test/fixtures/input.html')), (await read(filename)));
79+
});
80+
6881
// test('Transform html with options replace', async t => {
6982
// t.plan(2);
7083
// const folder = await tempfile();

test/test-plugin-resolve.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import path from 'path';
2+
import test from 'ava';
3+
import pluginResolve from '../src/plugin-resolve';
4+
5+
test('should return function', t => {
6+
t.true(typeof pluginResolve === 'function');
7+
});
8+
9+
test('should return node_modules module path', t => {
10+
const pluginName = 'posthtml-custom-elements';
11+
const pluginPath = pluginResolve(pluginName);
12+
t.is(pluginPath, pluginName);
13+
});
14+
15+
test('should return custom module path', t => {
16+
const pluginName = 'test/plugins/custom-plugin.js';
17+
const pluginPath = pluginResolve(pluginName);
18+
t.is(pluginPath, path.resolve(path.join('./', pluginName)));
19+
});

0 commit comments

Comments
 (0)