Files
bower/test/util/relativeToBaseDir.js
2016-03-31 00:27:17 +02:00

19 lines
821 B
JavaScript

var path = require('path');
var expect = require('expect.js');
var relativeToBaseDir = require('../../lib/util/relativeToBaseDir');
describe('relativeToBaseDir', function () {
var joinOrReturnAbsolutePath = relativeToBaseDir('/tmp');
it('returns a partial function that joins paths of the partials first arguments', function () {
expect(joinOrReturnAbsolutePath('foo')).to.be.equal(path.resolve('/tmp/foo'));
expect(joinOrReturnAbsolutePath('./foo')).to.be.equal(path.resolve('/tmp/foo'));
});
it('returns a partial function that returns it\'s first argument when it begins with /', function () {
expect(joinOrReturnAbsolutePath('/foo')).to.be.equal(path.resolve('/foo'));
expect(joinOrReturnAbsolutePath('/foo/bar')).to.be.equal(path.resolve('/foo/bar'));
});
});