-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(unit): Add IP getter and head extension
- Loading branch information
Showing
5 changed files
with
61 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import test from 'ava' | ||
|
||
import getHostIPs from '../../../lib/get-host-ips.js' | ||
|
||
test('gets host IPs', t => { | ||
const result = getHostIPs() | ||
|
||
for (const ip of result) { | ||
t.true(typeof ip === 'string') | ||
} | ||
}) |
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,29 @@ | ||
import test from 'ava' | ||
|
||
import PangolinHeadExtension from '../../../lib/pangolin-head-extension.js' | ||
|
||
test.serial('creates <head> markup in dev mode', t => { | ||
const nodeEnvCopy = process.env.NODE_ENV | ||
process.env.NODE_ENV = 'development' | ||
|
||
const publicPath = '/hello/world/' | ||
const assets = { js: [], css: [] } | ||
|
||
const result = new PangolinHeadExtension({ publicPath, assets }) | ||
t.snapshot(result.run().val) | ||
|
||
process.env.NODE_ENV = nodeEnvCopy | ||
}) | ||
|
||
test.serial('creates <head> markup in prod mode', t => { | ||
const publicPath = '/hello/world/' | ||
const assets = { | ||
js: ['vendor.js', 'app.js'], | ||
css: ['vendor.css', 'app.css'] | ||
} | ||
|
||
const result = new PangolinHeadExtension({ publicPath, assets }) | ||
|
||
t.deepEqual(result.tags, ['pangolin_head']) | ||
t.snapshot(result.run().val) | ||
}) |
20 changes: 20 additions & 0 deletions
20
test/unit/lib/snapshots/pangolin-head-extension.spec.js.md
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,20 @@ | ||
# Snapshot report for `test/unit/lib/pangolin-head-extension.spec.js` | ||
|
||
The actual snapshot is saved in `pangolin-head-extension.spec.js.snap`. | ||
|
||
Generated by [AVA](https://avajs.dev). | ||
|
||
## creates <head> markup in dev mode | ||
|
||
> Snapshot 1 | ||
'<script src="/hello/world/main.js" defer></script>' | ||
|
||
## creates <head> markup in prod mode | ||
|
||
> Snapshot 1 | ||
`<script src="/hello/world/vendor.js" defer></script>␊ | ||
<script src="/hello/world/app.js" defer></script>␊ | ||
<link rel="stylesheet" href="/hello/world/vendor.css">␊ | ||
<link rel="stylesheet" href="/hello/world/app.css">` |
Binary file not shown.