UNPKG

1.74 kBJavaScriptView Raw
1'use strict';
2
3var assert = require('chai').assert,
4 PATH = require('path'),
5 QFS = require('q-io/fs'),
6
7 LibNodes = require('..').require('./nodes/lib');
8
9/**
10 * Mocha BDD interface.
11 *
12 * @name describe @function
13 * @name it @function
14 * @name before @function
15 * @name after @function
16 * @name beforeEach @function
17 * @name afterEach @function
18 */
19
20describe('nodes', function() {
21
22 describe('new SymlinkLibraryNode()', function() {
23
24 var node = new LibNodes.SymlinkLibraryNode({
25 root: PATH.resolve(__dirname, 'data'),
26 target: 'symlink',
27 relative: 'lib'
28 }),
29 symlink = PATH.resolve(__dirname, 'data', 'symlink');
30
31 describe('.getId()', function() {
32 it('equals to target', function() {
33 assert.equal(node.getId(), 'symlink');
34 });
35 });
36
37 describe('.getPath()', function() {
38 it('equals to absolute path to target', function() {
39 assert.equal(node.getPath(), symlink);
40 });
41 });
42
43 describe('.make()', function() {
44
45 afterEach(function() {
46 QFS.remove(symlink);
47 });
48
49 it('creates symlink', function(done) {
50
51 node.make()
52 .then(function() {
53
54 return QFS.statLink(symlink)
55 .then(function(stat) {
56 assert.ok(stat.isSymbolicLink());
57 done();
58 })
59 .fail(done);
60
61 })
62 .fail(done)
63 .done();
64
65 });
66
67 });
68
69 });
70
71});