UNPKG

877 BJavaScriptView Raw
1/* jshint expr: true */
2var expect = require('chai').expect;
3var read = require('../index');
4
5describe('read.files', function () {
6 var res;
7
8 beforeEach(function (next) {
9 read(['./test/read.js', './foo'], function (err, _res) {
10 expect(err).falsy;
11 res = _res;
12 next();
13 });
14 });
15
16 it('returns .files', function () {
17 expect(res.files).array;
18 expect(res.files).have.length(2);
19 });
20
21 it('concatenates res', function () {
22 expect(res.data).eql(res.files[0].data);
23 });
24
25 it('gives res', function () {
26 var file = res.files[0];
27 expect(file.data).a('string');
28 expect(file.data).match(/Hola mundo/);
29 expect(file.name).eql('./test/read.js');
30 });
31
32 it('gives errors', function () {
33 var file = res.files[1];
34 expect(file.error).instanceOf(Error);
35 expect(file.error.code).eql('ENOENT');
36 });
37});
38
39/* Hola mundo */