diff --git a/test/css-in-js.html b/test/css-in-js.html
index 2cdf011..c6a1c19 100644
--- a/test/css-in-js.html
+++ b/test/css-in-js.html
@@ -7,11 +7,6 @@
content="width=device-width,initial-scale=1,shrink-to-fit=no"
/>
React App
-
diff --git a/test/fixture.css b/test/fixture.css
index 1fa6a8f..7c88d8e 100644
--- a/test/fixture.css
+++ b/test/fixture.css
@@ -1,3 +1 @@
-body {
- color: teal;
-}
+.fixture { color: red; }
diff --git a/test/index.js b/test/index.js
index a5edb31..462062d 100644
--- a/test/index.js
+++ b/test/index.js
@@ -8,121 +8,60 @@ const extractCss = require('..')
let server
const fixture = readFileSync(resolve(__dirname, 'fixture.css'), 'utf8')
+function staticFile(req, res) {
+ const fileContents = readFileSync(resolve(__dirname, req.path.slice(1)), 'utf8')
+ res.send(fileContents)
+}
+
test.before(async () => {
server = await createTestServer()
- server.get('/fixture.css', (req, res) => {
- res.send(fixture)
- })
+ server.get('/fixture.css', staticFile)
})
test.after(async () => {
await server.close()
})
-test('it fetches css from a page with CSS in a server generated inside the ', async t => {
- const url = '/server-link-head'
- server.get(url, (req, res) => {
- res.send(`
-
-
-
-
-
-
- `)
- })
-
- const actual = await extractCss(server.url + url)
+test('it finds css in a tag - HTML', async t => {
+ server.get('/link-tag-html.html', staticFile)
+ const actual = await extractCss(server.url + '/link-tag-html.html')
const expected = fixture
-
t.is(actual, expected)
})
-test('it fetches css from a page with CSS in server generated
- `)
- })
-
- const actual = await extractCss(server.url + url)
- const expected = 'body { color: teal; }'
-
- t.is(actual, expected)
-})
-
-test('it finds JS generated CSS', async t => {
- const path = '/js-generated-link'
- const cssInJsExampleHtml = readFileSync(
- resolve(__dirname, 'js-create-link-element.html'),
- 'utf8'
- )
-
- server.get(path, (req, res) => {
- res.send(cssInJsExampleHtml)
- })
-
- const actual = await extractCss(server.url + path)
+test('it finds css in a tag - JS', async t => {
+ server.get('/link-tag-js.html', staticFile)
+ const actual = await extractCss(server.url + '/link-tag-js.html')
const expected = fixture
-
t.is(actual, expected)
})
-test('it finds JS generated
CSS', async t => {
- const url = '/js-generated-js-style-tag'
- const cssInJsExampleHtml = readFileSync(
- resolve(__dirname, 'js-create-style-element.html'),
- 'utf8'
- )
- server.get(url, (req, res) => {
- res.send(cssInJsExampleHtml)
- })
-
- const actual = await extractCss(server.url + url, {waitUntil: 'load'})
- const expected = 'body { color: teal; }'
-
+test('it finds css in a
-
-Title
-server-style:
-
-
diff --git a/test/link-tag-html.html b/test/link-tag-html.html
new file mode 100644
index 0000000..7f5fb70
--- /dev/null
+++ b/test/link-tag-html.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+ Document
+
+
+
+ <link> tag in HTML
+
+
\ No newline at end of file
diff --git a/test/link-tag-js.html b/test/link-tag-js.html
new file mode 100644
index 0000000..1170980
--- /dev/null
+++ b/test/link-tag-js.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+ Document
+
+
+
+ <link> tag in JS
+
+
+
\ No newline at end of file
diff --git a/test/style-tag-html.html b/test/style-tag-html.html
new file mode 100644
index 0000000..e3a446b
--- /dev/null
+++ b/test/style-tag-html.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ Document
+
+
+
+ <style> tag in HTML
+
+
\ No newline at end of file
diff --git a/test/style-tag-js.html b/test/style-tag-js.html
new file mode 100644
index 0000000..ce161b2
--- /dev/null
+++ b/test/style-tag-js.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+ Document
+
+
+ <style> tag in JS
+
+
+
\ No newline at end of file