forked from blakeembrey/code-problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflatten-array.js
More file actions
24 lines (20 loc) · 719 Bytes
/
Copy pathflatten-array.js
File metadata and controls
24 lines (20 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* global describe, it */
var fs = require('fs');
var expect = require('chai').expect;
var dirname = __dirname + '/../../solutions/javascript/flatten-array';
// Load all the solutions from the test directory.
var solutions = fs.readdirSync(dirname).filter(function (file) {
return /\.js$/.test(file);
}).map(function (file) {
return [file.replace(/\.js$/, ''), require(dirname + '/' + file)];
});
describe('flatten-array', function () {
solutions.forEach(function (solution) {
var flatten = solution[1];
describe(solution[0], function () {
it('should flatten an array', function () {
expect(flatten([1, [2, [3], 2], 1])).to.deep.equal([1, 2, 3, 2, 1]);
});
});
});
});