Skip to content

Commit

Permalink
test(*): add test for reshape, close #48
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrum committed Feb 13, 2017
1 parent 490082b commit 7223c38
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"posthtml-standard-config": "0.0.5",
"posthtml-style-to-file": "^0.1.1",
"reshape": "^0.4.1",
"reshape-beautify": "^0.1.2",
"tempfile": "^1.1.1",
"testen": "^1.8.2",
"updtr": "^0.2.1"
Expand Down
3 changes: 3 additions & 0 deletions test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"postcss-csso": "^1.1.2",
"postcss-at-rules-variables": "*",
"postcss-cli": "^2.5.2",
"reshape": "^0.4.1",
"reshape-beautify": "0.1.2",
"posthtml": "^0.9.0",
"posthtml-bem": "^0.2.2",
"posthtml-css-modules": "^0.1.0",
Expand Down Expand Up @@ -105,6 +107,7 @@
}
}
},
"reshape": {},
"posthtml": {
"bem": {
"elemPrefix": "__",
Expand Down
29 changes: 29 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path';
import {readFile, existsSync} from 'fs';
import posthtml from 'posthtml';
import postcss from 'postcss';
import reshape from 'reshape';
import execa from 'execa';
import tempfile from 'tempfile';
import test from 'ava';
Expand Down Expand Up @@ -45,3 +46,31 @@ test('post-load-pliguns default config for postcss-cli from package.json', async
t.true(existsSync(filename));
t.is(fix, exp);
});

test('reshape with post-load-pliguns should return equal html', async t => {
const html = '<div class="test">test</div>';
t.is(html, (await reshape({plugins: [postLoadPlugins()]}).process(html)).output());
});

test('reshape with post-load-pliguns should report not install pkg', async t => {
const html = '<my-custom class="test">test</my-custom>';
const ext = {
reshape: {
plugins: {
'custom-elements': {
defaultTag: 'span'
}
}
}
};
t.is(html, (await reshape({plugins: [postLoadPlugins(ext)]}).process(html)).output());
});

test('reshape with post-load-pliguns with reshape-beautify plugin', async t => {
const html = `<body><p>hi there</p><div class='wow'>this is minified</div></body>`;
const fixtures = `<body>
<p>hi there</p>
<div class="wow">this is minified</div>
</body>`;
t.is(fixtures, (await reshape({plugins: [postLoadPlugins()]}).process(html)).output());
});

0 comments on commit 7223c38

Please sign in to comment.