{"size": 523, "ext": "js", "max_stars_repo_path": "tests/array-insert.test.js", "max_stars_repo_name": "Creuna-Oslo/js-utils", "max_stars_repo_stars_event_min_datetime": "2018-04-28T10:36:33.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-07T10:25:44.000Z", "max_issues_repo_path": "tests/array-insert.test.js", "max_issues_repo_name": "Creuna-Oslo/js-utils", "max_issues_repo_issues_event_min_datetime": "2018-05-03T15:49:48.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-11T14:48:19.000Z", "max_forks_repo_path": "tests/array-insert.test.js", "max_forks_repo_name": "Creuna-Oslo/js-utils", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": 7, "max_forks_count": null, "avg_line_length": 18.6785714286, "max_line_length": 45, "alphanum_fraction": 0.5334608031}
import test from 'ava';

import insert from '../source/array-insert';

test('throws on no array', t => {
  t.throws(() => {
    insert();
  });
});

test('inserts at beginning', t => {
  const newArray = insert([0, 1, 2], 0, 'x');

  t.deepEqual(newArray, ['x', 0, 1, 2]);
});

test('inserts at end', t => {
  const newArray = insert([0, 1, 2], 3, 'x');

  t.deepEqual(newArray, [0, 1, 2, 'x']);
});

test('inserts inside', t => {
  const newArray = insert([0, 1, 2], 1, 'x');

  t.deepEqual(newArray, [0, 'x', 1, 2]);
});
