Skip to content

Commit a0e093a

Browse files
committed
test: for options in config, issue #306
1 parent dbbbee8 commit a0e093a

5 files changed

Lines changed: 57 additions & 6 deletions

File tree

test/config/.config-options

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
'options': {
3+
sync: true
4+
}
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
<?php echo $title; ?>
11+
</body>
12+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
input: 'test/fixtures/by-config/options/input.html',
3+
output: 'test/expected/by-config/options/output.html',
4+
options: {
5+
directives: [{name: '?php', start: '<', end: '>'}]
6+
}
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
<?php echo $title; ?>
11+
</body>
12+
</html>

test/test-cli.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import readPkg from 'read-pkg';
88
import tempfile from 'tempfile';
99

1010
const cli = path.resolve('lib/cli.js');
11-
const read = file => new Promise((resolve, reject) => fs.readFile(file, 'utf8', (error, data) => {
12-
if (error) {
13-
return reject(error);
14-
}
11+
const read = file => new Promise((resolve, reject) => {
12+
fs.readFile(file, 'utf8', (error, data) => {
13+
if (error) {
14+
return reject(error);
15+
}
1516

16-
resolve(data);
17-
}));
17+
resolve(data);
18+
});
19+
});
1820

1921
test('Check version', async t => {
2022
const {stdout} = await execa(cli, ['-v']);
@@ -145,6 +147,19 @@ test('Transform html stdin options use witch modules', async t => {
145147
t.is((await read('test/expected/output-modules.html')), (await read(filename)));
146148
});
147149

150+
test('Transform html stdin options', async t => {
151+
t.plan(2);
152+
await execa(cli, [
153+
'-c',
154+
'test/fixtures/by-config/options/.config'
155+
]);
156+
t.true(await pathExists('test/expected/by-config/options/output.html'));
157+
t.is(
158+
(await read('test/expected/by-config/options/output.html')),
159+
(await read('test/fixtures/by-config/options/input.html'))
160+
);
161+
});
162+
148163
test('Transform html stdin options only config one-io', async t => {
149164
t.plan(2);
150165
await execa(cli, [

0 commit comments

Comments
 (0)