Prompt, how to check up an array on? In the end result, the test should check whether the array has changed, and if yes, give an error that it can not be changed.
import { List, Set } from "immutable"
export let list1: number[] = [1, 2, 3];
export function mass(list1) {
let listFromArray = List(list1);
if (listFromArray == List(list1)) {
throw new Error("immutable");
}
return listFromArray;
};
Test code:
import {mass} from "./sum"
import { List, Set, isImmutable } from "immutable"
test('check for variability', () => {
const list1: number[] = [1, 2, 3];
const listFromArray = mass(list1);
const expectedResult = List([1, 2, 3]);
expect(expectedResult).toThrowError('Error');
});