Skip to content

Commit

Permalink
refactor: tests (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Jul 30, 2019
1 parent 80ce578 commit 31e70f3
Show file tree
Hide file tree
Showing 37 changed files with 1,630 additions and 849 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# style-loader

Adds CSS to the DOM by injecting a <code>&lt;style&gt;</code> tag
Adds CSS to the DOM.

## Getting Started

Expand Down
163 changes: 163 additions & 0 deletions test/__snapshots__/attributes-option.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`attributes option should add attributes to tag ("injectType" option is "linkTag"): 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=\\"ceb98dd1e5ab94be0d4081cb8b89f79d.css\\" id=\\"style-tag-id\\"></head>
<body>
<h1>Body</h1>
<div class=\\"target\\"></div>
<iframe class=\\"iframeTarget\\"></iframe>
</body></html>"
`;
exports[`attributes option should add attributes to tag ("injectType" option is "linkTag"): errors 1`] = `Array []`;
exports[`attributes option should add attributes to tag ("injectType" option is "linkTag"): warnings 1`] = `Array []`;
exports[`attributes option should add attributes to tag ("injectType" option is "styleTag"): DOM 1`] = `
"<!DOCTYPE html><html><head>
<title>style-loader test</title>
<style id=\\"existing-style\\">.existing { color: yellow }</style>
<style id=\\"style-tag-id\\" type=\\"text/css\\">body {
color: red;
}
</style></head>
<body>
<h1>Body</h1>
<div class=\\"target\\"></div>
<iframe class=\\"iframeTarget\\"></iframe>
</body></html>"
`;
exports[`attributes option should add attributes to tag ("injectType" option is "styleTag"): errors 1`] = `Array []`;
exports[`attributes option should add attributes to tag ("injectType" option is "styleTag"): warnings 1`] = `Array []`;
exports[`attributes option should add attributes to tag ("injectType" option is "useableStyleTag"): DOM 1`] = `
"<!DOCTYPE html><html><head>
<title>style-loader test</title>
<style id=\\"existing-style\\">.existing { color: yellow }</style>
<style id=\\"style-tag-id\\" type=\\"text/css\\">h1 {
color: blue;
}
</style></head>
<body>
<h1>Body</h1>
<div class=\\"target\\"></div>
<iframe class=\\"iframeTarget\\"></iframe>
</body></html>"
`;
exports[`attributes option should add attributes to tag ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;
exports[`attributes option should add attributes to tag ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;
exports[`attributes option should add nonce attribute #2: DOM 1`] = `
"<!DOCTYPE html><html><head>
<title>style-loader test</title>
<style id=\\"existing-style\\">.existing { color: yellow }</style>
<style type=\\"text/css\\" nonce=\\"12345678\\">body {
color: red;
}
</style></head>
<body>
<h1>Body</h1>
<div class=\\"target\\"></div>
<iframe class=\\"iframeTarget\\"></iframe>
</body></html>"
`;
exports[`attributes option should add nonce attribute #2: errors 1`] = `Array []`;
exports[`attributes option should add nonce attribute #2: warnings 1`] = `Array []`;
exports[`attributes option should add nonce attribute: DOM 1`] = `
"<!DOCTYPE html><html><head>
<title>style-loader test</title>
<style id=\\"existing-style\\">.existing { color: yellow }</style>
<style type=\\"text/css\\" nonce=\\"12345678\\">body {
color: red;
}
</style></head>
<body>
<h1>Body</h1>
<div class=\\"target\\"></div>
<iframe class=\\"iframeTarget\\"></iframe>
</body></html>"
`;
exports[`attributes option should add nonce attribute: errors 1`] = `Array []`;
exports[`attributes option should add nonce attribute: warnings 1`] = `Array []`;
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "linkTag"): DOM 1`] = `
"<!DOCTYPE html><html><head>
<title>style-loader test</title>
<style id=\\"existing-style\\">.existing { color: yellow }</style>
<link rel=\\"stylesheet\\" type=\\"text/less\\" href=\\"ceb98dd1e5ab94be0d4081cb8b89f79d.css\\"></head>
<body>
<h1>Body</h1>
<div class=\\"target\\"></div>
<iframe class=\\"iframeTarget\\"></iframe>
</body></html>"
`;
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "linkTag"): errors 1`] = `Array []`;
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "linkTag"): warnings 1`] = `Array []`;
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "styleTag"): DOM 1`] = `
"<!DOCTYPE html><html><head>
<title>style-loader test</title>
<style id=\\"existing-style\\">.existing { color: yellow }</style>
<style type=\\"text/less\\">body {
color: red;
}
</style></head>
<body>
<h1>Body</h1>
<div class=\\"target\\"></div>
<iframe class=\\"iframeTarget\\"></iframe>
</body></html>"
`;
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "styleTag"): errors 1`] = `Array []`;
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "styleTag"): warnings 1`] = `Array []`;
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "useableStyleTag"): DOM 1`] = `
"<!DOCTYPE html><html><head>
<title>style-loader test</title>
<style id=\\"existing-style\\">.existing { color: yellow }</style>
<style type=\\"text/less\\">h1 {
color: blue;
}
</style></head>
<body>
<h1>Body</h1>
<div class=\\"target\\"></div>
<iframe class=\\"iframeTarget\\"></iframe>
</body></html>"
`;
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;
22 changes: 22 additions & 0 deletions test/__snapshots__/base-option.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`base option should work: DOM 1`] = `
"<!DOCTYPE html><html><head>
<title>style-loader test</title>
<style id=\\"existing-style\\">.existing { color: yellow }</style>
<style type=\\"text/css\\">body {
color: red;
}
</style></head>
<body>
<h1>Body</h1>
<div class=\\"target\\"></div>
<iframe class=\\"iframeTarget\\"></iframe>
</body></html>"
`;
exports[`base option should work: errors 1`] = `Array []`;
exports[`base option should work: warnings 1`] = `Array []`;
73 changes: 73 additions & 0 deletions test/__snapshots__/hmr-option.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`hmr option false with HotModuleReplacementPlugin ("injectType" option is "linkTag"): errors 1`] = `Array []`;

exports[`hmr option false with HotModuleReplacementPlugin ("injectType" option is "linkTag"): warnings 1`] = `Array []`;

exports[`hmr option false with HotModuleReplacementPlugin ("injectType" option is "styleTag"): errors 1`] = `Array []`;

exports[`hmr option false with HotModuleReplacementPlugin ("injectType" option is "styleTag"): warnings 1`] = `Array []`;

exports[`hmr option false with HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;

exports[`hmr option false with HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;

exports[`hmr option false without HotModuleReplacementPlugin ("injectType" option is "linkTag"): errors 1`] = `Array []`;

exports[`hmr option false without HotModuleReplacementPlugin ("injectType" option is "linkTag"): warnings 1`] = `Array []`;

exports[`hmr option false without HotModuleReplacementPlugin ("injectType" option is "styleTag"): errors 1`] = `Array []`;

exports[`hmr option false without HotModuleReplacementPlugin ("injectType" option is "styleTag"): warnings 1`] = `Array []`;

exports[`hmr option false without HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;

exports[`hmr option false without HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;

exports[`hmr option not specified with HotModuleReplacementPlugin ("injectType" option is "linkTag"): errors 1`] = `Array []`;

exports[`hmr option not specified with HotModuleReplacementPlugin ("injectType" option is "linkTag"): warnings 1`] = `Array []`;

exports[`hmr option not specified with HotModuleReplacementPlugin ("injectType" option is "styleTag"): errors 1`] = `Array []`;

exports[`hmr option not specified with HotModuleReplacementPlugin ("injectType" option is "styleTag"): warnings 1`] = `Array []`;

exports[`hmr option not specified with HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;

exports[`hmr option not specified with HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;

exports[`hmr option not specified without HotModuleReplacementPlugin ("injectType" option is "linkTag"): errors 1`] = `Array []`;

exports[`hmr option not specified without HotModuleReplacementPlugin ("injectType" option is "linkTag"): warnings 1`] = `Array []`;

exports[`hmr option not specified without HotModuleReplacementPlugin ("injectType" option is "styleTag"): errors 1`] = `Array []`;

exports[`hmr option not specified without HotModuleReplacementPlugin ("injectType" option is "styleTag"): warnings 1`] = `Array []`;

exports[`hmr option not specified without HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;

exports[`hmr option not specified without HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;

exports[`hmr option true with HotModuleReplacementPlugin ("injectType" option is "linkTag"): errors 1`] = `Array []`;

exports[`hmr option true with HotModuleReplacementPlugin ("injectType" option is "linkTag"): warnings 1`] = `Array []`;

exports[`hmr option true with HotModuleReplacementPlugin ("injectType" option is "styleTag"): errors 1`] = `Array []`;

exports[`hmr option true with HotModuleReplacementPlugin ("injectType" option is "styleTag"): warnings 1`] = `Array []`;

exports[`hmr option true with HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;

exports[`hmr option true with HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;

exports[`hmr option true without HotModuleReplacementPlugin ("injectType" option is "linkTag"): errors 1`] = `Array []`;

exports[`hmr option true without HotModuleReplacementPlugin ("injectType" option is "linkTag"): warnings 1`] = `Array []`;

exports[`hmr option true without HotModuleReplacementPlugin ("injectType" option is "styleTag"): errors 1`] = `Array []`;

exports[`hmr option true without HotModuleReplacementPlugin ("injectType" option is "styleTag"): warnings 1`] = `Array []`;

exports[`hmr option true without HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;

exports[`hmr option true without HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;
Loading

0 comments on commit 31e70f3

Please sign in to comment.