Skip to content

Commit 31e70f3

Browse files
refactor: tests (#398)
1 parent 80ce578 commit 31e70f3

37 files changed

+1630
-849
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# style-loader
1818

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

2121
## Getting Started
2222

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`attributes option should add attributes to tag ("injectType" option is "linkTag"): DOM 1`] = `
4+
"<!DOCTYPE html><html><head>
5+
<title>style-loader test</title>
6+
<style id=\\"existing-style\\">.existing { color: yellow }</style>
7+
<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"ceb98dd1e5ab94be0d4081cb8b89f79d.css\\" id=\\"style-tag-id\\"></head>
8+
<body>
9+
<h1>Body</h1>
10+
<div class=\\"target\\"></div>
11+
<iframe class=\\"iframeTarget\\"></iframe>
12+
13+
14+
</body></html>"
15+
`;
16+
17+
exports[`attributes option should add attributes to tag ("injectType" option is "linkTag"): errors 1`] = `Array []`;
18+
19+
exports[`attributes option should add attributes to tag ("injectType" option is "linkTag"): warnings 1`] = `Array []`;
20+
21+
exports[`attributes option should add attributes to tag ("injectType" option is "styleTag"): DOM 1`] = `
22+
"<!DOCTYPE html><html><head>
23+
<title>style-loader test</title>
24+
<style id=\\"existing-style\\">.existing { color: yellow }</style>
25+
<style id=\\"style-tag-id\\" type=\\"text/css\\">body {
26+
color: red;
27+
}
28+
</style></head>
29+
<body>
30+
<h1>Body</h1>
31+
<div class=\\"target\\"></div>
32+
<iframe class=\\"iframeTarget\\"></iframe>
33+
34+
35+
</body></html>"
36+
`;
37+
38+
exports[`attributes option should add attributes to tag ("injectType" option is "styleTag"): errors 1`] = `Array []`;
39+
40+
exports[`attributes option should add attributes to tag ("injectType" option is "styleTag"): warnings 1`] = `Array []`;
41+
42+
exports[`attributes option should add attributes to tag ("injectType" option is "useableStyleTag"): DOM 1`] = `
43+
"<!DOCTYPE html><html><head>
44+
<title>style-loader test</title>
45+
<style id=\\"existing-style\\">.existing { color: yellow }</style>
46+
<style id=\\"style-tag-id\\" type=\\"text/css\\">h1 {
47+
color: blue;
48+
}
49+
</style></head>
50+
<body>
51+
<h1>Body</h1>
52+
<div class=\\"target\\"></div>
53+
<iframe class=\\"iframeTarget\\"></iframe>
54+
55+
56+
</body></html>"
57+
`;
58+
59+
exports[`attributes option should add attributes to tag ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;
60+
61+
exports[`attributes option should add attributes to tag ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;
62+
63+
exports[`attributes option should add nonce attribute #2: DOM 1`] = `
64+
"<!DOCTYPE html><html><head>
65+
<title>style-loader test</title>
66+
<style id=\\"existing-style\\">.existing { color: yellow }</style>
67+
<style type=\\"text/css\\" nonce=\\"12345678\\">body {
68+
color: red;
69+
}
70+
</style></head>
71+
<body>
72+
<h1>Body</h1>
73+
<div class=\\"target\\"></div>
74+
<iframe class=\\"iframeTarget\\"></iframe>
75+
76+
77+
</body></html>"
78+
`;
79+
80+
exports[`attributes option should add nonce attribute #2: errors 1`] = `Array []`;
81+
82+
exports[`attributes option should add nonce attribute #2: warnings 1`] = `Array []`;
83+
84+
exports[`attributes option should add nonce attribute: DOM 1`] = `
85+
"<!DOCTYPE html><html><head>
86+
<title>style-loader test</title>
87+
<style id=\\"existing-style\\">.existing { color: yellow }</style>
88+
<style type=\\"text/css\\" nonce=\\"12345678\\">body {
89+
color: red;
90+
}
91+
</style></head>
92+
<body>
93+
<h1>Body</h1>
94+
<div class=\\"target\\"></div>
95+
<iframe class=\\"iframeTarget\\"></iframe>
96+
97+
98+
</body></html>"
99+
`;
100+
101+
exports[`attributes option should add nonce attribute: errors 1`] = `Array []`;
102+
103+
exports[`attributes option should add nonce attribute: warnings 1`] = `Array []`;
104+
105+
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "linkTag"): DOM 1`] = `
106+
"<!DOCTYPE html><html><head>
107+
<title>style-loader test</title>
108+
<style id=\\"existing-style\\">.existing { color: yellow }</style>
109+
<link rel=\\"stylesheet\\" type=\\"text/less\\" href=\\"ceb98dd1e5ab94be0d4081cb8b89f79d.css\\"></head>
110+
<body>
111+
<h1>Body</h1>
112+
<div class=\\"target\\"></div>
113+
<iframe class=\\"iframeTarget\\"></iframe>
114+
115+
116+
</body></html>"
117+
`;
118+
119+
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "linkTag"): errors 1`] = `Array []`;
120+
121+
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "linkTag"): warnings 1`] = `Array []`;
122+
123+
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "styleTag"): DOM 1`] = `
124+
"<!DOCTYPE html><html><head>
125+
<title>style-loader test</title>
126+
<style id=\\"existing-style\\">.existing { color: yellow }</style>
127+
<style type=\\"text/less\\">body {
128+
color: red;
129+
}
130+
</style></head>
131+
<body>
132+
<h1>Body</h1>
133+
<div class=\\"target\\"></div>
134+
<iframe class=\\"iframeTarget\\"></iframe>
135+
136+
137+
</body></html>"
138+
`;
139+
140+
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "styleTag"): errors 1`] = `Array []`;
141+
142+
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "styleTag"): warnings 1`] = `Array []`;
143+
144+
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "useableStyleTag"): DOM 1`] = `
145+
"<!DOCTYPE html><html><head>
146+
<title>style-loader test</title>
147+
<style id=\\"existing-style\\">.existing { color: yellow }</style>
148+
<style type=\\"text/less\\">h1 {
149+
color: blue;
150+
}
151+
</style></head>
152+
<body>
153+
<h1>Body</h1>
154+
<div class=\\"target\\"></div>
155+
<iframe class=\\"iframeTarget\\"></iframe>
156+
157+
158+
</body></html>"
159+
`;
160+
161+
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;
162+
163+
exports[`attributes option should override/add default type attribute to tag ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`base option should work: DOM 1`] = `
4+
"<!DOCTYPE html><html><head>
5+
<title>style-loader test</title>
6+
<style id=\\"existing-style\\">.existing { color: yellow }</style>
7+
<style type=\\"text/css\\">body {
8+
color: red;
9+
}
10+
</style></head>
11+
<body>
12+
<h1>Body</h1>
13+
<div class=\\"target\\"></div>
14+
<iframe class=\\"iframeTarget\\"></iframe>
15+
16+
17+
</body></html>"
18+
`;
19+
20+
exports[`base option should work: errors 1`] = `Array []`;
21+
22+
exports[`base option should work: warnings 1`] = `Array []`;
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`hmr option false with HotModuleReplacementPlugin ("injectType" option is "linkTag"): errors 1`] = `Array []`;
4+
5+
exports[`hmr option false with HotModuleReplacementPlugin ("injectType" option is "linkTag"): warnings 1`] = `Array []`;
6+
7+
exports[`hmr option false with HotModuleReplacementPlugin ("injectType" option is "styleTag"): errors 1`] = `Array []`;
8+
9+
exports[`hmr option false with HotModuleReplacementPlugin ("injectType" option is "styleTag"): warnings 1`] = `Array []`;
10+
11+
exports[`hmr option false with HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;
12+
13+
exports[`hmr option false with HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;
14+
15+
exports[`hmr option false without HotModuleReplacementPlugin ("injectType" option is "linkTag"): errors 1`] = `Array []`;
16+
17+
exports[`hmr option false without HotModuleReplacementPlugin ("injectType" option is "linkTag"): warnings 1`] = `Array []`;
18+
19+
exports[`hmr option false without HotModuleReplacementPlugin ("injectType" option is "styleTag"): errors 1`] = `Array []`;
20+
21+
exports[`hmr option false without HotModuleReplacementPlugin ("injectType" option is "styleTag"): warnings 1`] = `Array []`;
22+
23+
exports[`hmr option false without HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;
24+
25+
exports[`hmr option false without HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;
26+
27+
exports[`hmr option not specified with HotModuleReplacementPlugin ("injectType" option is "linkTag"): errors 1`] = `Array []`;
28+
29+
exports[`hmr option not specified with HotModuleReplacementPlugin ("injectType" option is "linkTag"): warnings 1`] = `Array []`;
30+
31+
exports[`hmr option not specified with HotModuleReplacementPlugin ("injectType" option is "styleTag"): errors 1`] = `Array []`;
32+
33+
exports[`hmr option not specified with HotModuleReplacementPlugin ("injectType" option is "styleTag"): warnings 1`] = `Array []`;
34+
35+
exports[`hmr option not specified with HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;
36+
37+
exports[`hmr option not specified with HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;
38+
39+
exports[`hmr option not specified without HotModuleReplacementPlugin ("injectType" option is "linkTag"): errors 1`] = `Array []`;
40+
41+
exports[`hmr option not specified without HotModuleReplacementPlugin ("injectType" option is "linkTag"): warnings 1`] = `Array []`;
42+
43+
exports[`hmr option not specified without HotModuleReplacementPlugin ("injectType" option is "styleTag"): errors 1`] = `Array []`;
44+
45+
exports[`hmr option not specified without HotModuleReplacementPlugin ("injectType" option is "styleTag"): warnings 1`] = `Array []`;
46+
47+
exports[`hmr option not specified without HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;
48+
49+
exports[`hmr option not specified without HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;
50+
51+
exports[`hmr option true with HotModuleReplacementPlugin ("injectType" option is "linkTag"): errors 1`] = `Array []`;
52+
53+
exports[`hmr option true with HotModuleReplacementPlugin ("injectType" option is "linkTag"): warnings 1`] = `Array []`;
54+
55+
exports[`hmr option true with HotModuleReplacementPlugin ("injectType" option is "styleTag"): errors 1`] = `Array []`;
56+
57+
exports[`hmr option true with HotModuleReplacementPlugin ("injectType" option is "styleTag"): warnings 1`] = `Array []`;
58+
59+
exports[`hmr option true with HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;
60+
61+
exports[`hmr option true with HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;
62+
63+
exports[`hmr option true without HotModuleReplacementPlugin ("injectType" option is "linkTag"): errors 1`] = `Array []`;
64+
65+
exports[`hmr option true without HotModuleReplacementPlugin ("injectType" option is "linkTag"): warnings 1`] = `Array []`;
66+
67+
exports[`hmr option true without HotModuleReplacementPlugin ("injectType" option is "styleTag"): errors 1`] = `Array []`;
68+
69+
exports[`hmr option true without HotModuleReplacementPlugin ("injectType" option is "styleTag"): warnings 1`] = `Array []`;
70+
71+
exports[`hmr option true without HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): errors 1`] = `Array []`;
72+
73+
exports[`hmr option true without HotModuleReplacementPlugin ("injectType" option is "useableStyleTag"): warnings 1`] = `Array []`;

0 commit comments

Comments
 (0)