mardi 17 juillet 2018

Test for equality of arrays

How in the test to compare each value of the array, and not the entire array? In my test, I compared the standardArray, but I need to compare List [1,2,3,4], but I'll get it so that the test does not lose its meaning. Maybe somehow by the indexes or otherwise ...

import { List, Set } from "immutable"
let standardArray = List([1,2,3,4]);

export function mass(standardArray) {
  let mutatedArray = standardArray.map(x => x * 2);
  return mutatedArray;
};

test code:

import { List, Set, isImmutable, Record, Map } from "immutable"
import { mass } from "./sum";


test('aligning arrays', () => {
  let standardArray = List([1,2,3,4]);
  for (let i = 0; i < 1; i++) {
   expect(mass(standardArray)).toEqual(standardArray.map(x => x * 2));
  };
});

Aucun commentaire:

Enregistrer un commentaire