@fluentui-react-native/experimental-avatar 0.14.44 → 0.14.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +16 -1
- package/CHANGELOG.md +10 -2
- package/package.json +1 -1
- package/src/__tests__/JSAvatar.test.jsx +74 -107
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "@fluentui-react-native/experimental-avatar",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Tue, 21 Jun 2022 20:05:09 GMT",
|
|
6
|
+
"tag": "@fluentui-react-native/experimental-avatar_v0.14.45",
|
|
7
|
+
"version": "0.14.45",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "v.kozova13@gmail.com",
|
|
12
|
+
"package": "@fluentui-react-native/experimental-avatar",
|
|
13
|
+
"commit": "f93c1716455fb220897d993f4450f00b05f0bf0a",
|
|
14
|
+
"comment": "Rewrote tests using it.each method"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Thu, 16 Jun 2022 19:11:01 GMT",
|
|
6
21
|
"tag": "@fluentui-react-native/experimental-avatar_v0.14.44",
|
|
7
22
|
"version": "0.14.44",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - @fluentui-react-native/experimental-avatar
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 21 Jun 2022 20:05:09 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.14.45
|
|
8
|
+
|
|
9
|
+
Tue, 21 Jun 2022 20:05:09 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Rewrote tests using it.each method (v.kozova13@gmail.com)
|
|
14
|
+
|
|
7
15
|
## 0.14.44
|
|
8
16
|
|
|
9
|
-
Thu, 16 Jun 2022 19:
|
|
17
|
+
Thu, 16 Jun 2022 19:11:01 GMT
|
|
10
18
|
|
|
11
19
|
### Patches
|
|
12
20
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-react-native/experimental-avatar",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.45",
|
|
4
4
|
"description": "A cross-platform Avatar component using the Fluent Design System. Currently only implemented on iOS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Microsoft <fluentuinativeowners@microsoft.com>",
|
|
@@ -3,23 +3,69 @@ import { JSAvatar } from '..';
|
|
|
3
3
|
import { getInitials } from '../useAvatar';
|
|
4
4
|
import * as renderer from 'react-test-renderer';
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
'
|
|
8
|
-
|
|
9
|
-
'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
6
|
+
const emptyData = [
|
|
7
|
+
[undefined, ''],
|
|
8
|
+
[null, ''],
|
|
9
|
+
['', ''],
|
|
10
|
+
];
|
|
11
|
+
const testData = [
|
|
12
|
+
['Marie', 'M'],
|
|
13
|
+
['Aadi KaPoor', 'AK'],
|
|
14
|
+
['Marie Beaudouin', 'MB'],
|
|
15
|
+
['Aadi Meni KaPoor', 'AK'],
|
|
16
|
+
['Will Little (Teams)', 'WL'],
|
|
17
|
+
['Will Little-Tanaka', 'WL'],
|
|
18
|
+
['-Aadi Kapoor', 'AK'],
|
|
19
|
+
['Richard 23 Feynman', 'RF'],
|
|
20
|
+
['* Richard *', 'R'],
|
|
21
|
+
['Richard Feynman [Teams],', 'RF'],
|
|
22
|
+
['Richard Feynman {Teams}', 'RF'],
|
|
23
|
+
['-Test str with *spaces', 'TS'],
|
|
24
|
+
['Second, First', 'SF'],
|
|
25
|
+
];
|
|
26
|
+
const namesWithTitles = [
|
|
27
|
+
['Mr Feynman', 'F'],
|
|
28
|
+
['Dr Richard Feynman', 'RF'],
|
|
29
|
+
['Aadi Meni Ka Jr', 'AK'],
|
|
30
|
+
['Consul General Richard Faynman', 'RF'],
|
|
31
|
+
['Major General Victor', 'V'],
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const languageTestData = [
|
|
35
|
+
['خسرو رحیمی', 'خ'], // Arabic
|
|
36
|
+
['桂英', '桂'], // Chinese
|
|
37
|
+
['佳', '佳'],
|
|
38
|
+
['宋智洋', '宋'],
|
|
39
|
+
['강현', '강'], // Korean
|
|
40
|
+
['최종래', '최'],
|
|
41
|
+
['남궁 성종', '남'],
|
|
42
|
+
['松田', '松'], // Japanese
|
|
43
|
+
['海野', '海'],
|
|
44
|
+
['かり', 'か'],
|
|
45
|
+
['Илон Маск', 'ИМ'], // Cyrillic
|
|
46
|
+
['Írissa Þórðardóttir', 'ÍÞ'], // non-ASCII characters
|
|
47
|
+
['Øyvind Åsen', 'ØÅ'],
|
|
48
|
+
['ثابت بن قره', 'ث'], // Thābit ibn Qurra - result in PCX - ثابت
|
|
49
|
+
['שירה לוי', 'של'], // Hebrew - Shira Levi
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const phoneNumbersAndDigits = [
|
|
53
|
+
['12345678', ''],
|
|
54
|
+
['+47 12 34 56 78 (X 5678)', ''],
|
|
55
|
+
['47 12 34', ''],
|
|
56
|
+
['47 12', ''],
|
|
57
|
+
['James Ext 2', 'JE'],
|
|
58
|
+
['1', ''],
|
|
59
|
+
['A2', 'A'],
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
const edgeCaseData = [
|
|
63
|
+
['4lex 5loo', 'LL'],
|
|
64
|
+
[' !@#$%^&*()=+ (Alpha) David (The man) `~<>,./?[]{}| Goff (Gamma) ', 'DG'],
|
|
65
|
+
['+1 (555) 123-4567 ext.4567', 'E'],
|
|
66
|
+
['1 Ext 2', 'E'],
|
|
67
|
+
['1x1', 'X'],
|
|
19
68
|
];
|
|
20
|
-
const alphabeticalInitials = ['M', 'AK', 'MB', 'AK', 'AK', 'WL', 'WL', 'AK', 'RF', 'R', 'RF', 'RF'];
|
|
21
|
-
const namesWithTitles = ['Mr Feynman', 'Dr Richard Feynman'];
|
|
22
|
-
const initialsForNameWithTitles = ['F', 'RF'];
|
|
23
69
|
|
|
24
70
|
describe('Avatar rendering', () => {
|
|
25
71
|
it('renders Avatar', () => {
|
|
@@ -28,102 +74,23 @@ describe('Avatar rendering', () => {
|
|
|
28
74
|
});
|
|
29
75
|
});
|
|
30
76
|
|
|
31
|
-
describe('getInitials - names with titles', () => {
|
|
32
|
-
it('returns initials without title', () => {
|
|
33
|
-
expect(getInitials('Mr Faynman')).toBe('F');
|
|
34
|
-
});
|
|
35
|
-
it('returns initials for names with multi-word titles', () => {
|
|
36
|
-
expect(getInitials('Consul General Richard Faynman')).toBe('RF');
|
|
37
|
-
expect(getInitials('Major General Victor')).toBe('V');
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe('getInitials method - language support', () => {
|
|
42
|
-
it('returns correct initials cyrillic language', () => {
|
|
43
|
-
const test = getInitials('Илон Маск');
|
|
44
|
-
expect(test).toBe('ИМ');
|
|
45
|
-
});
|
|
46
|
-
it('calculates correct initials for non-ASCII characters', () => {
|
|
47
|
-
const test = getInitials('Írissa Þórðardóttir');
|
|
48
|
-
expect(test).toBe('ÍÞ');
|
|
49
|
-
});
|
|
50
|
-
it('returns correct initials for non-ASCII characters', () => {
|
|
51
|
-
const test = getInitials('Øyvind Åsen');
|
|
52
|
-
expect(test).toBe('ØÅ');
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
77
|
describe('getInitials method', () => {
|
|
57
|
-
it(
|
|
58
|
-
|
|
59
|
-
expect(test).toBe('TS');
|
|
60
|
-
});
|
|
61
|
-
it('returns an empty string if name is undefined', () => {
|
|
62
|
-
expect(getInitials(undefined)).toBe('');
|
|
63
|
-
});
|
|
64
|
-
it('return initials for alphabetical words', () => {
|
|
65
|
-
for (let i = 0; i < alphabeticalTestNames.length; i++) {
|
|
66
|
-
expect(getInitials(alphabeticalTestNames[i])).toBe(alphabeticalInitials[i]);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
it('return initials for words with titles', () => {
|
|
70
|
-
for (let i = 0; i < namesWithTitles.length; i++) {
|
|
71
|
-
expect(getInitials(namesWithTitles[i])).toBe(initialsForNameWithTitles[i]);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
it("returns initials when there's a coma", () => {
|
|
75
|
-
expect(getInitials('Second, First')).toEqual('SF');
|
|
78
|
+
it.each(emptyData)("returns an empty string for '%s'", (text, expected) => {
|
|
79
|
+
expect(getInitials(text)).toBe(expected);
|
|
76
80
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
expect(getInitials(null)).toEqual('');
|
|
80
|
-
expect(getInitials(undefined)).toEqual('');
|
|
81
|
+
it.each(testData)("render correct initials for input '%s'", (text, expected) => {
|
|
82
|
+
expect(getInitials(text)).toBe(expected);
|
|
81
83
|
});
|
|
82
|
-
it(
|
|
83
|
-
expect(getInitials(
|
|
84
|
+
it.each(namesWithTitles)("render initials for names with titles: '%s'", (text, expected) => {
|
|
85
|
+
expect(getInitials(text)).toBe(expected);
|
|
84
86
|
});
|
|
85
|
-
it(
|
|
86
|
-
expect(getInitials(
|
|
87
|
+
it.each(languageTestData)("render initials for different languages: '%s'", (text, expected) => {
|
|
88
|
+
expect(getInitials(text)).toBe(expected);
|
|
87
89
|
});
|
|
88
|
-
it(
|
|
89
|
-
|
|
90
|
-
expect(result).toEqual('DG');
|
|
90
|
+
it.each(phoneNumbersAndDigits)("returns an empty string for phone numbers: '%s'", (text, expected) => {
|
|
91
|
+
expect(getInitials(text)).toBe(expected);
|
|
91
92
|
});
|
|
92
|
-
it(
|
|
93
|
-
|
|
94
|
-
expect(result).toEqual('DG');
|
|
95
|
-
});
|
|
96
|
-
it('calculates an expected initials for Arabic names', () => {
|
|
97
|
-
expect(getInitials('خسرو رحیمی')).toEqual('خ');
|
|
98
|
-
});
|
|
99
|
-
it('calculates an expected initials for Chinese names', () => {
|
|
100
|
-
expect(getInitials('桂英')).toEqual('桂');
|
|
101
|
-
expect(getInitials('佳')).toEqual('佳');
|
|
102
|
-
expect(getInitials('宋智洋')).toEqual('宋');
|
|
103
|
-
});
|
|
104
|
-
it('calculates an expected initials for Korean names', () => {
|
|
105
|
-
expect(getInitials('강현')).toEqual('강');
|
|
106
|
-
expect(getInitials('최종래')).toEqual('최');
|
|
107
|
-
expect(getInitials('남궁 성종')).toEqual('남');
|
|
108
|
-
});
|
|
109
|
-
it('calculates an expected initials for Japanese names', () => {
|
|
110
|
-
expect(getInitials('松田')).toEqual('松');
|
|
111
|
-
expect(getInitials('海野')).toEqual('海');
|
|
112
|
-
expect(getInitials('かり')).toEqual('か');
|
|
113
|
-
});
|
|
114
|
-
it('validates phone numbers', () => {
|
|
115
|
-
expect(getInitials('12345678')).toEqual('');
|
|
116
|
-
// expect(getInitials('+1 (555) 123-4567 ext.4567')).toEqual('');
|
|
117
|
-
expect(getInitials('+47 12 34 56 78 (X 5678)')).toEqual('');
|
|
118
|
-
expect(getInitials('47 12 34')).toEqual('');
|
|
119
|
-
expect(getInitials('47 12')).toEqual('');
|
|
120
|
-
|
|
121
|
-
expect(getInitials('James Ext 2')).toEqual('JE');
|
|
122
|
-
// expect(getInitials('1 Ext 2')).toEqual('');
|
|
123
|
-
// expect(getInitials('1x1')).toEqual('');
|
|
124
|
-
result = getInitials('1');
|
|
125
|
-
expect(result).toEqual('');
|
|
126
|
-
result = getInitials('A 2');
|
|
127
|
-
expect(result).toEqual('A');
|
|
93
|
+
it.each(edgeCaseData)("render initials for edge cases: '%s'", (text, expected) => {
|
|
94
|
+
expect(getInitials(text)).toBe(expected);
|
|
128
95
|
});
|
|
129
96
|
});
|