Imagine I have two similar arrays and I want to write unit tests to verify if these arrays contain the same values and if those values are equal. I am using mocha and enzyme for unit testing. What is the most effective approach to comparing these values?
const devices = [{
deviceType: 'Tag',
deviceId: 1,
name: 'Tag For Sending and alarm',
version: '',
location: 'Room1',
lastAliveMessage: '',
deviceStatus: 'Active',
actions: 'offline',
},{
deviceType: 'Tag1',
deviceId: 2,
name: 'Tag For Sending and alarm2 ',
version: '',
location: 'Room2',
lastAliveMessage: '',
deviceStatus: 'Active',
actions: 'offline',
}]
const devices2 = [{
deviceType: 'Tag',
deviceId: 1,
name: 'Tag For Sending and alarm',
version: '',
location: 'Room1',
lastAliveMessage: '',
deviceStatus: 'Active',
actions: 'offline',
},{
deviceType: 'Tag1',
deviceId: 2,
name: 'Tag For Sending and alarm2 ',
version: '',
location: 'Room2',
lastAliveMessage: '',
deviceStatus: 'Active',
actions: 'offline',
}]
data.forEach(item => {
devices.forEach(device =>{
item.deviceId.should.be.equal(device.deviceId))
})
})