现代 JavaScript 教程(The Modern JavaScript Tutorial),以最新的 ECMAScript 规范为基准,通过简单但足够详细的内容,为你讲解从基础到高阶的 JavaScript 相关知识。
|
|
describe("concat", function() {
|
||
|
|
let chunks = [
|
||
|
|
new Uint8Array([0, 1, 2]),
|
||
|
|
new Uint8Array([3, 4, 5]),
|
||
|
|
new Uint8Array([6, 7, 8])
|
||
|
|
];
|
||
|
|
|
||
|
|
it("result has the same array type", function() {
|
||
|
|
|
||
|
|
let result = concat(chunks);
|
||
|
|
|
||
|
|
assert.equal(result.constructor, Uint8Array);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("concatenates arrays", function() {
|
||
|
|
|
||
|
|
let result = concat(chunks);
|
||
|
|
|
||
|
|
assert.deepEqual(result, new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8]));
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
it("returns empty array on empty input", function() {
|
||
|
|
|
||
|
|
let result = concat([]);
|
||
|
|
|
||
|
|
assert.equal(result.length, 0);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
});
|