source: imaps-frontend/node_modules/safe-push-apply/test/index.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 730 bytes
Line 
1'use strict';
2
3var test = require('tape');
4
5var safePushApply = require('../');
6
7test('safe-push-apply', function (t) {
8 t.equal(typeof safePushApply, 'function', 'is a function');
9 t.equal(safePushApply.length, 2, 'has a length of 2');
10
11 t['throws'](
12 // @ts-expect-error
13 function () { safePushApply({}, []); },
14 TypeError,
15 'throws if target is not an array'
16 );
17
18 var a = [1, 2];
19 var b = [3, 4];
20 safePushApply(a, b);
21 t.deepEqual(a, [1, 2, 3, 4], 'b is pushed into a');
22 t.deepEqual(b, [3, 4], 'b is not modified');
23
24 var c = '567';
25 // @ts-expect-error TS ArrayLike doesn't accept strings for some reason
26 safePushApply(a, c);
27 t.deepEqual(a, [1, 2, 3, 4, '5', '6', '7'], 'works with arraylike source');
28
29 t.end();
30});
Note: See TracBrowser for help on using the repository browser.