1 | var test = require('ava')
|
2 | var resolveUrl = require('../utils/resolve-url')
|
3 |
|
4 | test('should correctly resolve a .. relative link', (t) => {
|
5 | t.deepEqual(
|
6 | resolveUrl('http://foo.com/some/path', '../bar.css'),
|
7 | 'http://foo.com/some/bar.css'
|
8 | )
|
9 | })
|
10 |
|
11 | test('should correctly resolve a .. relative link when the url has a trailing /', (t) => {
|
12 | t.deepEqual(
|
13 | resolveUrl('http://foo.com/some/path/', '../bar.css'),
|
14 | 'http://foo.com/some/bar.css'
|
15 | )
|
16 | })
|
17 |
|
18 | test('should correctly resolve a relative link', (t) => {
|
19 | t.deepEqual(
|
20 | resolveUrl('http://foo.com/some/path', 'bar.css'),
|
21 | 'http://foo.com/some/path/bar.css'
|
22 | )
|
23 | })
|
24 |
|
25 | test('should correctly return a full link', (t) => {
|
26 | t.deepEqual(
|
27 | resolveUrl('http://foo.com', 'http://foo.com/some/path/bar.css'),
|
28 | 'http://foo.com/some/path/bar.css'
|
29 | )
|
30 | })
|
31 |
|
32 | test('should correctly resolve an absolute link', (t) => {
|
33 | t.deepEqual(
|
34 | resolveUrl('http://foo.com/some/path', '/bar.css'),
|
35 | 'http://foo.com/bar.css'
|
36 | )
|
37 | })
|
38 |
|
39 | test('should correctly resolve a relative url from an html file', (t) => {
|
40 | t.deepEqual(
|
41 | resolveUrl('http://foo.bar/awesome/baz.html', 'baz.css'),
|
42 | 'http://foo.bar/awesome/baz.css'
|
43 | )
|
44 | })
|
45 |
|
46 | test('should correctly resolve an absolute url from an html file', (t) => {
|
47 | t.deepEqual(
|
48 | resolveUrl('http://foo.bar/awesome/baz.html', '/baz.css'),
|
49 | 'http://foo.bar/baz.css'
|
50 | )
|
51 | })
|