Merge pull request #18 from jantimon/feature/plugin-integration-tests

Integration tests for extract-text-webpack-plugin
This commit is contained in:
Charles Blaxland 2015-04-24 09:12:48 +10:00
commit 0b755ad75b
4 changed files with 88 additions and 0 deletions

View File

@ -23,9 +23,12 @@
},
"homepage": "https://github.com/ampedandwired/html-webpack-plugin",
"devDependencies": {
"css-loader": "^0.9.1",
"extract-text-webpack-plugin": "^0.5.0",
"jasmine-node": "^1.14.5",
"jshint": "^2.5.2",
"rimraf": "^2.2.8",
"style-loader": "^0.9.0",
"webpack": "^1.3.3-beta1"
},
"dependencies": {

View File

@ -263,6 +263,86 @@ describe('HtmlWebpackPlugin', function() {
}, ['<script src="index_bundle.js?%hash%"'], null, done);
});
it('should work with the css extract plugin', function (done) {
var ExtractTextPlugin = require("extract-text-webpack-plugin");
testHtmlPlugin({
entry: path.join(__dirname, 'fixtures/theme.js'),
output: {
path: OUTPUT_DIR,
filename: 'index_bundle.js'
},
module: {
loaders: [
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') }
]
},
plugins: [
new HtmlWebpackPlugin(),
new ExtractTextPlugin("styles.css")
]
}, ['<link href="styles.css"'], null, done);
});
it('should allow to add cache hashes to with the css assets', function (done) {
var ExtractTextPlugin = require("extract-text-webpack-plugin");
testHtmlPlugin({
entry: path.join(__dirname, 'fixtures/theme.js'),
output: {
path: OUTPUT_DIR,
filename: 'index_bundle.js'
},
module: {
loaders: [
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') }
]
},
plugins: [
new HtmlWebpackPlugin({hash: true}),
new ExtractTextPlugin("styles.css")
]
}, ['<link href="styles.css?%hash%"'], null, done);
});
it('should inject css files when using the extract text plugin', function (done) {
var ExtractTextPlugin = require("extract-text-webpack-plugin");
testHtmlPlugin({
entry: path.join(__dirname, 'fixtures/theme.js'),
output: {
path: OUTPUT_DIR,
filename: 'index_bundle.js'
},
module: {
loaders: [
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') }
]
},
plugins: [
new HtmlWebpackPlugin({inject: true}),
new ExtractTextPlugin("styles.css")
]
}, ['<link href="styles.css"'], null, done);
});
it('should allow to add cache hashes to with injected css assets', function (done) {
var ExtractTextPlugin = require("extract-text-webpack-plugin");
testHtmlPlugin({
entry: path.join(__dirname, 'fixtures/theme.js'),
output: {
path: OUTPUT_DIR,
filename: 'index_bundle.js'
},
module: {
loaders: [
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') }
]
},
plugins: [
new HtmlWebpackPlugin({hash: true, inject: true}),
new ExtractTextPlugin("styles.css")
]
}, ['<link href="styles.css?%hash%"'], null, done);
});
it('prepends the webpack public path to script src', function(done) {
testHtmlPlugin({
entry: path.join(__dirname, 'fixtures/index.js'),

3
spec/fixtures/main.css vendored Normal file
View File

@ -0,0 +1,3 @@
body {
background: snow;
}

2
spec/fixtures/theme.js vendored Normal file
View File

@ -0,0 +1,2 @@
require('./main.css');
require('./index.js');