set-state-compare
Version:
setState for React that compares with the current state and only sets the state if changed.
25 lines (18 loc) • 717 B
JavaScript
import {arrayDifferent} from "../src/index.js"
describe("arrayDifferent", () => {
it("returns true if the length isn't the same", () => {
const object1 = ["Kasper"]
const object2 = ["Kasper", "Christina"]
expect(arrayDifferent(object1, object2)).toBe(true)
})
it("returns false if an element in the arrays are different", () => {
const object1 = ["Kasper", "Christina"]
const object2 = ["Kasper", "Christina S."]
expect(arrayDifferent(object1, object2)).toBe(true)
})
it("returns false if the arrays are identical", () => {
const object1 = ["Kasper", "Christina"]
const object2 = ["Kasper", "Christina"]
expect(arrayDifferent(object1, object2)).toBe(false)
})
})