-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bff4f5
commit a89c0f9
Showing
11 changed files
with
289 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`linkType option should work when linkType option is "false": DOM 1`] = ` | ||
"<!DOCTYPE html><html><head> | ||
<title>style-loader test</title> | ||
<style id=\\"existing-style\\">.existing { color: yellow }</style> | ||
<link rel=\\"stylesheet\\" href=\\"simple.css\\"><script charset=\\"utf-8\\" src=\\"simple.bundle.js\\"></script></head> | ||
<body> | ||
<h1>Body</h1> | ||
<div class=\\"target\\"></div> | ||
<iframe class=\\"iframeTarget\\"></iframe> | ||
</body></html>" | ||
`; | ||
exports[`linkType option should work when linkType option is "false": errors 1`] = `Array []`; | ||
exports[`linkType option should work when linkType option is "false": warnings 1`] = `Array []`; | ||
exports[`linkType option should work when linkType option is "text/css": DOM 1`] = ` | ||
"<!DOCTYPE html><html><head> | ||
<title>style-loader test</title> | ||
<style id=\\"existing-style\\">.existing { color: yellow }</style> | ||
<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"simple.css\\"><script charset=\\"utf-8\\" src=\\"simple.bundle.js\\"></script></head> | ||
<body> | ||
<h1>Body</h1> | ||
<div class=\\"target\\"></div> | ||
<iframe class=\\"iframeTarget\\"></iframe> | ||
</body></html>" | ||
`; | ||
exports[`linkType option should work when linkType option is "text/css": errors 1`] = `Array []`; | ||
exports[`linkType option should work when linkType option is "text/css": warnings 1`] = `Array []`; | ||
exports[`linkType option should work without linkType option: DOM 1`] = ` | ||
"<!DOCTYPE html><html><head> | ||
<title>style-loader test</title> | ||
<style id=\\"existing-style\\">.existing { color: yellow }</style> | ||
<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"simple.css\\"><script charset=\\"utf-8\\" src=\\"simple.bundle.js\\"></script></head> | ||
<body> | ||
<h1>Body</h1> | ||
<div class=\\"target\\"></div> | ||
<iframe class=\\"iframeTarget\\"></iframe> | ||
</body></html>" | ||
`; | ||
exports[`linkType option should work without linkType option: errors 1`] = `Array []`; | ||
exports[`linkType option should work without linkType option: warnings 1`] = `Array []`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* eslint-env browser */ | ||
import path from 'path'; | ||
|
||
import MiniCssExtractPlugin from '../src/cjs'; | ||
|
||
import { | ||
compile, | ||
getCompiler, | ||
getErrors, | ||
getWarnings, | ||
runInJsDom, | ||
} from './helpers/index'; | ||
|
||
describe('linkType option', () => { | ||
it(`should work without linkType option`, async () => { | ||
const compiler = getCompiler( | ||
'attributes.js', | ||
{}, | ||
{ | ||
output: { | ||
publicPath: '', | ||
path: path.resolve(__dirname, '../outputs'), | ||
filename: '[name].bundle.js', | ||
}, | ||
plugins: [ | ||
new MiniCssExtractPlugin({ | ||
filename: '[name].css', | ||
}), | ||
], | ||
} | ||
); | ||
const stats = await compile(compiler); | ||
|
||
runInJsDom('main.bundle.js', compiler, stats, (dom) => { | ||
expect(dom.serialize()).toMatchSnapshot('DOM'); | ||
}); | ||
|
||
expect(getWarnings(stats)).toMatchSnapshot('warnings'); | ||
expect(getErrors(stats)).toMatchSnapshot('errors'); | ||
}); | ||
|
||
it(`should work when linkType option is "false"`, async () => { | ||
const compiler = getCompiler( | ||
'attributes.js', | ||
{}, | ||
{ | ||
output: { | ||
publicPath: '', | ||
path: path.resolve(__dirname, '../outputs'), | ||
filename: '[name].bundle.js', | ||
}, | ||
plugins: [ | ||
new MiniCssExtractPlugin({ | ||
linkType: false, | ||
filename: '[name].css', | ||
}), | ||
], | ||
} | ||
); | ||
const stats = await compile(compiler); | ||
|
||
runInJsDom('main.bundle.js', compiler, stats, (dom) => { | ||
expect(dom.serialize()).toMatchSnapshot('DOM'); | ||
}); | ||
|
||
expect(getWarnings(stats)).toMatchSnapshot('warnings'); | ||
expect(getErrors(stats)).toMatchSnapshot('errors'); | ||
}); | ||
|
||
it(`should work when linkType option is "text/css"`, async () => { | ||
const compiler = getCompiler( | ||
'attributes.js', | ||
{}, | ||
{ | ||
output: { | ||
publicPath: '', | ||
path: path.resolve(__dirname, '../outputs'), | ||
filename: '[name].bundle.js', | ||
}, | ||
plugins: [ | ||
new MiniCssExtractPlugin({ | ||
linkType: 'text/css', | ||
filename: '[name].css', | ||
}), | ||
], | ||
} | ||
); | ||
const stats = await compile(compiler); | ||
|
||
runInJsDom('main.bundle.js', compiler, stats, (dom) => { | ||
expect(dom.serialize()).toMatchSnapshot('DOM'); | ||
}); | ||
|
||
expect(getWarnings(stats)).toMatchSnapshot('warnings'); | ||
expect(getErrors(stats)).toMatchSnapshot('errors'); | ||
}); | ||
}); |
Oops, something went wrong.