| 1 |
const resolve = require('../..'); |
| 2 |
const assert = require('assert'); |
| 3 |
|
| 4 |
describe('readme', () => { |
| 5 |
const _any_ = 'https://foo/'; |
| 6 |
const _rest_ = 'foo'; |
| 7 |
describe('table 0', () => { |
| 8 |
it('input = `https://example.com`, base = _any_', () => { |
| 9 |
const input = `https://example.com`; |
| 10 |
const base = _any_; |
| 11 |
const expected = `https://example.com/`; |
| 12 |
|
| 13 |
assert.strictEqual(resolve(input, base), expected); |
| 14 |
}); |
| 15 |
|
| 16 |
it('input = `//example.com`, base = `https://base.com/`', () => { |
| 17 |
const input = `//example.com`; |
| 18 |
const base = `https://base.com/`; |
| 19 |
const expected = `https://example.com/`; |
| 20 |
|
| 21 |
assert.strictEqual(resolve(input, base), expected); |
| 22 |
}); |
| 23 |
|
| 24 |
it('input = `//example.com`, base = _rest_', () => { |
| 25 |
const input = `//example.com`; |
| 26 |
const base = _rest_; |
| 27 |
const expected = `//example.com/`; |
| 28 |
|
| 29 |
assert.strictEqual(resolve(input, base), expected); |
| 30 |
}); |
| 31 |
|
| 32 |
it('input = `/example`, base = `https://base.com/`', () => { |
| 33 |
const input = `/example`; |
| 34 |
const base = `https://base.com/`; |
| 35 |
const expected = `https://base.com/example`; |
| 36 |
|
| 37 |
assert.strictEqual(resolve(input, base), expected); |
| 38 |
}); |
| 39 |
|
| 40 |
it('input = `/example`, base = `//base.com/`', () => { |
| 41 |
const input = `/example`; |
| 42 |
const base = `//base.com/`; |
| 43 |
const expected = `//base.com/example`; |
| 44 |
|
| 45 |
assert.strictEqual(resolve(input, base), expected); |
| 46 |
}); |
| 47 |
|
| 48 |
it('input = `/example`, base = _rest_', () => { |
| 49 |
const input = `/example`; |
| 50 |
const base = _rest_; |
| 51 |
const expected = `/example`; |
| 52 |
|
| 53 |
assert.strictEqual(resolve(input, base), expected); |
| 54 |
}); |
| 55 |
|
| 56 |
it('input = `example`, base = `https://base.com/dir/`', () => { |
| 57 |
const input = `example`; |
| 58 |
const base = `https://base.com/dir/`; |
| 59 |
const expected = `https://base.com/dir/example`; |
| 60 |
|
| 61 |
assert.strictEqual(resolve(input, base), expected); |
| 62 |
}); |
| 63 |
|
| 64 |
it('input = `example`, base = `https://base.com/file`', () => { |
| 65 |
const input = `example`; |
| 66 |
const base = `https://base.com/file`; |
| 67 |
const expected = `https://base.com/example`; |
| 68 |
|
| 69 |
assert.strictEqual(resolve(input, base), expected); |
| 70 |
}); |
| 71 |
|
| 72 |
it('input = `example`, base = `//base.com/dir/`', () => { |
| 73 |
const input = `example`; |
| 74 |
const base = `//base.com/dir/`; |
| 75 |
const expected = `//base.com/dir/example`; |
| 76 |
|
| 77 |
assert.strictEqual(resolve(input, base), expected); |
| 78 |
}); |
| 79 |
|
| 80 |
it('input = `example`, base = `//base.com/file`', () => { |
| 81 |
const input = `example`; |
| 82 |
const base = `//base.com/file`; |
| 83 |
const expected = `//base.com/example`; |
| 84 |
|
| 85 |
assert.strictEqual(resolve(input, base), expected); |
| 86 |
}); |
| 87 |
|
| 88 |
it('input = `example`, base = `/base/dir/`', () => { |
| 89 |
const input = `example`; |
| 90 |
const base = `/base/dir/`; |
| 91 |
const expected = `/base/dir/example`; |
| 92 |
|
| 93 |
assert.strictEqual(resolve(input, base), expected); |
| 94 |
}); |
| 95 |
|
| 96 |
it('input = `example`, base = `/base/file`', () => { |
| 97 |
const input = `example`; |
| 98 |
const base = `/base/file`; |
| 99 |
const expected = `/base/example`; |
| 100 |
|
| 101 |
assert.strictEqual(resolve(input, base), expected); |
| 102 |
}); |
| 103 |
|
| 104 |
it('input = `example`, base = `base/dir/`', () => { |
| 105 |
const input = `example`; |
| 106 |
const base = `base/dir/`; |
| 107 |
const expected = `base/dir/example`; |
| 108 |
|
| 109 |
assert.strictEqual(resolve(input, base), expected); |
| 110 |
}); |
| 111 |
|
| 112 |
it('input = `example`, base = `base/file`', () => { |
| 113 |
const input = `example`; |
| 114 |
const base = `base/file`; |
| 115 |
const expected = `base/example`; |
| 116 |
|
| 117 |
assert.strictEqual(resolve(input, base), expected); |
| 118 |
}); |
| 119 |
}); |
| 120 |
}); |