1 |
|
2 | var assert = require('assert')
|
3 | var path = require('path')
|
4 |
|
5 | var resolve = require('..')
|
6 |
|
7 | describe('Resolve Path', function () {
|
8 | it('should default to process.cwd()', function () {
|
9 | assert.equal(resolve('index.js'), path.resolve('index.js'))
|
10 | })
|
11 |
|
12 | it('should work with a root', function () {
|
13 | assert.equal(resolve(__dirname, 'resolve.js'), path.resolve(__dirname, 'resolve.js'))
|
14 | })
|
15 |
|
16 | it('should not out of bounds', function () {
|
17 | assert.equal(resolve(__dirname + '/../', 'index.js'), path.resolve(__dirname, '../index.js'))
|
18 | })
|
19 |
|
20 | describe('should throw if path', function () {
|
21 | it('is absolute', function () {
|
22 | assert.throws(function () {
|
23 | resolve('/home')
|
24 | })
|
25 | })
|
26 |
|
27 | it('contains a null byte', function () {
|
28 | assert.throws(function () {
|
29 | resolve('klajsdkfjasdf\0lkjalksjdfklasf')
|
30 | })
|
31 | })
|
32 |
|
33 | it('is out of bounds', function () {
|
34 | assert.throws(function () {
|
35 | resolve(__dirname, '../index.js')
|
36 | })
|
37 | })
|
38 | })
|
39 | })
|