-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfs.js
36 lines (30 loc) · 1012 Bytes
/
fs.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
/*!
* template-helpers <https://github.com/jonschlinkert/template-helpers>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
var assert = require('assert');
var helpers = require('..')('fs');
var template = require('lodash.template');
var imports = { imports: helpers };
describe('fs', function() {
describe('exists', function() {
it('should return false when the file does not exist.', function() {
assert.equal(template('<%= exists("fooosos.js") %>', imports)(), 'false');
});
});
describe('read', function() {
it('should return an empty string when the file does not exist.', function() {
assert.equal(template('<%= read("fooosos.js") %>', imports)(), '');
});
it('should read a file and inject its content.', function() {
assert.equal(template('<%= read("test/fixtures/a.js") %>', imports)(), [
'function foo(a, b, c) {',
' return a + b + c;',
'}'
].join('\n'));
});
});
});