Skip to content

Commit a1188b2

Browse files
committed
test: for skip options, issue #332
1 parent ad6737c commit a1188b2

7 files changed

Lines changed: 46 additions & 1 deletion

File tree

test/config/.config-skip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
'skip': 'input-skip.html'
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<custome-element>input-skip-skip</custome-element>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div>input-skip-index</div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<custome-element>input-skip-skip</custome-element>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div>input-skip-index</div>

test/test-cfg-resolve.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ test('should return simple config', t => {
2727
plugins: {
2828
'posthtml-custom-elements': {}
2929
},
30-
root: './'
30+
root: './',
31+
skip: []
3132
};
3233

3334
t.deepEqual(config, expected);
@@ -136,6 +137,16 @@ test('should return config when input param from config', t => {
136137
t.deepEqual(config.input, expected);
137138
});
138139

140+
test('should return config when skip param from config', t => {
141+
const input = 'input.html';
142+
const flags = {
143+
config: 'test/config/.config-skip'
144+
};
145+
const config = cfgResolve({input, flags});
146+
const expected = [normalizePath(path.resolve('input-skip.html'))];
147+
t.deepEqual(config.skip, expected);
148+
});
149+
139150
test('should return config when output param from config', t => {
140151
const input = 'input.html';
141152
const flags = {

test/test-cli.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,30 @@ test('Ignoring files by pattern', async t => {
294294
);
295295
t.false(await pathExists('test/expected/input-ignoring/ignoring-input-child'));
296296
});
297+
298+
test('Skip parsing file', async t => {
299+
const outputPath = 'test/expected/output-skip';
300+
rimraf.sync(outputPath);
301+
t.plan(3);
302+
await execa(cli, [
303+
'**/*.html',
304+
'-o',
305+
outputPath,
306+
'-a',
307+
'-r',
308+
'test/fixtures/input-skip',
309+
'-s',
310+
'input-skip.html',
311+
'-u',
312+
'posthtml-custom-elements'
313+
]);
314+
t.true(await pathExists(outputPath));
315+
t.is(
316+
(await read('test/fixtures/input-skip/input.html')),
317+
(await read(`${outputPath}/input.html`))
318+
);
319+
t.is(
320+
(await read('test/fixtures/input-skip/input-skip.html')),
321+
(await read(`${outputPath}/input-skip.html`))
322+
);
323+
});

0 commit comments

Comments
 (0)