/
test.js
33 lines (26 loc) · 910 Bytes
/
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
/*!
* flatten-arguments <https://github.com/tunnckoCore/flatten-arguments>
*
* Copyright (c) 2016 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)
* Released under the MIT license.
*/
/* jshint asi:true */
'use strict'
var test = require('assertit')
var flatten = require('./index')
function flattenArguments () {
return flatten(arguments)
}
function flattenMultiple () {
return flatten.apply(this, arguments)
}
test('should be able to accept `arguments` object directly', function (done) {
var args = flattenArguments(1, ['a', 'b'], 2, 3, ['c', ['d'], 4, 'e'], 5)
test.deepEqual(args, [1, 'a', 'b', 2, 3, 'c', 'd', 4, 'e', 5])
done()
})
test('should be able to accept multiple arguments and flatten', function (done) {
var args = flattenMultiple(1, ['a', 2, 'b'], 3, ['c', 4], {foo: 'bar'})
test.deepEqual(args, [1, 'a', 2, 'b', 3, 'c', 4, {foo: 'bar'}])
done()
})