-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UDCSL #54 - Adding check to ObjectUtils to handle function equality
- Loading branch information
1 parent
1411ba2
commit bce4032
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import ObjectUtils from '../../src/utils/Object'; | ||
|
||
describe('isEqual', () => { | ||
test('should be equal for two null objects', () => { | ||
expect(ObjectUtils.isEqual(null, null)).toBeTruthy(); | ||
}); | ||
|
||
test('should be equal for two strings of the same value', () => { | ||
expect(ObjectUtils.isEqual('abc', 'abc')).toBeTruthy(); | ||
}); | ||
|
||
test('should be equal for the same object', () => { | ||
const obj1 = { | ||
id: 1, | ||
name: 'Test', | ||
children: [{ | ||
id: 1 | ||
}, { | ||
id: 2 | ||
}] | ||
}; | ||
|
||
const obj2 = { | ||
id: 1, | ||
name: 'Test', | ||
children: [{ | ||
id: 1 | ||
}, { | ||
id: 2 | ||
}] | ||
}; | ||
|
||
expect(ObjectUtils.isEqual(obj1, obj2)).toBeTruthy(); | ||
}); | ||
|
||
test('should be equal for the same function', () => { | ||
const func1 = () => 'test'; | ||
const func2 = () => 'test'; | ||
|
||
expect(ObjectUtils.isEqual(func1, func2)).toBeTruthy(); | ||
}); | ||
}); |