mercredi 11 juillet 2018

verification of the equality of immutable arrays

I have two immutable arrays. One is ordinary ([1,2,3,4]), the other is multiplied by two ([2,4,6,8]). How in the test to equalize each value of the first array with the value of the second I use the iteration? That 1 is 2, and 2 is 3 and so on. I think this can be done with a for loop, but I do not know how to write this in practice.

import { List, Set } from "immutable"

export function mass() {
  let standardArray = List([1,2,3,4]);
  let mutatedArray = standardArray.map(x => x * 2);
  return mutatedArray;
};

test code (I do not know how to proceed)

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

test('Array Multiplication Test', () => {
  let standardArray = List([1,2,3,4]);
  let mutatedArray = standardArray.map(x => x * 2);
  expect(standardArray).not.toEqual(mutatedArray);
});

Aucun commentaire:

Enregistrer un commentaire