Files
bower/test/util/relativeToBaseDir.js
2018-03-28 19:28:43 +02:00

26 lines
904 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')
);
});
});