-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit tests for avatarDeepComparisonCheck (#1836)
* Add participant editing to the media gallery * Change files * Updated displayName changes to use useEffect hook. * Fixed initial state bug * rework async protection * Update mapping logic * move function out of gallery * move to hook function * move data provider in avatarPersona * listify * memoize useDataProvider * remove stale imports * fixed default behavior and deep comparison * add sorting and flatten deep comparison * remove stale imports * fix media gallery comments * fix AvatarPersona nits * move custom hook to utils file * fix imports * fix comments * James made me do it * moved to customDataModelUtils for all composites * Saint James found a bug because he's too stubborn * fix nits * add unit tests for deep compare * Change files * add tests for should update
- Loading branch information
1 parent
4c4fb0e
commit 0baf8b7
Showing
3 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@internal-react-composites-71e4d4f5-b5c9-47a2-9af0-56813ce9a34c.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Introduce tests to support new custom data model behaviors.", | ||
"packageName": "@internal/react-composites", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
100 changes: 100 additions & 0 deletions
100
packages/react-composites/src/composites/common/CustomDataModelUtils.test.ts
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,100 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { AvatarPersonaData } from './AvatarPersona'; | ||
import { avatarDeepDifferenceCheck, shouldUpdate } from './CustomDataModelUtils'; | ||
|
||
const testAvatar3: AvatarPersonaData = { | ||
text: undefined, | ||
imageUrl: undefined, | ||
imageInitials: undefined, | ||
initialsColor: undefined, | ||
initialsTextColor: undefined | ||
}; | ||
|
||
const testAvatarset1: AvatarPersonaData[] = [ | ||
{ | ||
text: 'apples', | ||
imageUrl: 'test1', | ||
imageInitials: 'aa', | ||
initialsColor: 'white', | ||
initialsTextColor: 'blue' | ||
}, | ||
{ | ||
text: 'Saint James', | ||
imageUrl: 'test3', | ||
imageInitials: 'aa', | ||
initialsColor: 'black', | ||
initialsTextColor: 'blue' | ||
} | ||
]; | ||
|
||
const testAvatarset2: AvatarPersonaData[] = [ | ||
{ | ||
text: 'apples', | ||
imageUrl: 'test1', | ||
imageInitials: 'aa', | ||
initialsColor: 'white', | ||
initialsTextColor: 'blue' | ||
}, | ||
{ | ||
text: 'Saint James', | ||
imageUrl: 'test3', | ||
imageInitials: 'aa', | ||
initialsColor: 'green', | ||
initialsTextColor: 'blue' | ||
} | ||
]; | ||
|
||
const testAvatarset3: AvatarPersonaData[] = [ | ||
{ | ||
text: 'apples', | ||
imageUrl: 'test1', | ||
imageInitials: 'aa', | ||
initialsColor: 'white', | ||
initialsTextColor: 'blue' | ||
}, | ||
{ | ||
text: 'Saint James', | ||
imageUrl: 'test3', | ||
imageInitials: 'aa', | ||
initialsColor: 'black', | ||
initialsTextColor: 'blue' | ||
}, | ||
{ | ||
text: 'apples', | ||
imageUrl: 'test1', | ||
imageInitials: 'aa', | ||
initialsColor: 'white', | ||
initialsTextColor: 'blue' | ||
} | ||
]; | ||
|
||
describe('Custom data model utils tests', () => { | ||
describe('avatarDeepDifferenceCheck tests', () => { | ||
test('avatarDeepDifferenceCheck should return false for same avatar', () => { | ||
expect(avatarDeepDifferenceCheck(testAvatarset1[1], testAvatarset1[1])).toBe(false); | ||
}); | ||
test('avatarDeepDifferenceCheck should return true for different avatars', () => { | ||
expect(avatarDeepDifferenceCheck(testAvatarset1[1], testAvatarset1[2])).toBe(true); | ||
}); | ||
test('avatarDeepDifferenceCheck should return true for avatar with data and avatar with undefined data', () => { | ||
expect(avatarDeepDifferenceCheck(testAvatarset1[1], testAvatar3)).toBe(true); | ||
}); | ||
test('avatarDeepDifferenceCheck should return true for two undefined avatars', () => { | ||
expect(avatarDeepDifferenceCheck(testAvatar3, testAvatar3)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('shouldUpdate tests', () => { | ||
test('shouldUpdate should return true with two different avatar sets', () => { | ||
expect(shouldUpdate(testAvatarset1, testAvatarset2)).toBe(true); | ||
}); | ||
test('shouldUpdate should return false with two of the same sets of AvatarPersonaData', () => { | ||
expect(shouldUpdate(testAvatarset1, testAvatarset1)).toBe(false); | ||
}); | ||
test('shouldUpdate should return true with two avatar sets of different lengths', () => { | ||
expect(shouldUpdate(testAvatarset1, testAvatarset3)).toBe(true); | ||
}); | ||
}); | ||
}); |
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