-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
53 lines (44 loc) · 1.24 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict';
require('mocha');
var path = require('path');
var assert = require('assert');
var cwd = require('./');
var Base = require('base');
var app;
describe('base-cwd', function() {
beforeEach(function() {
app = new Base();
app.isApp = true;
app.use(cwd());
});
it('should export a function', function() {
assert.equal(typeof cwd, 'function');
});
it('should add a `cwd` property to app', function() {
assert.equal(typeof app.cwd, 'string');
});
it('should get the current working directory', function() {
assert.equal(app.cwd, process.cwd());
});
it('should use the cwd defined on options', function() {
app.options.cwd = 'foo/bar';
assert.equal(app.cwd, path.resolve(process.cwd(), 'foo/bar'));
});
it('should set cwd directly', function() {
app.cwd = 'foo/bar';
assert.equal(app.cwd, path.resolve(process.cwd(), 'foo/bar'));
});
it('should set app.cache.cwd when defined directly', function() {
app.cwd = 'foo/bar';
assert.equal(app.cache.cwd, app.cwd);
});
it('should emit cwd', function() {
var count = 0;
app.on('cwd', function() {
count++;
});
app.cwd = 'foo/bar';
assert.equal(app.cache.cwd, app.cwd);
assert.equal(count, 1);
});
});