-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.spec.js
67 lines (56 loc) · 2.27 KB
/
index.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const { getFirstName, getLastName, getFullName } = require('.');
describe('test hebrew-names', () => {
describe('getFirstName', () => {
test.each([
['christian', 'male', 'אליאס'],
['christian', 'female', 'מריה'],
['druze', 'male', 'סולימאן'],
['druze', 'female', 'נור'],
['jew', 'male', 'דוד'],
['jew', 'female', 'נועה'],
['muslim', 'male', 'מוחמד'],
['muslim', 'female', 'פאטמה'],
['other', 'male', 'דניאל'],
['other', 'female', 'ניקול'],
])('should get random first name for ethnicity=%s and gender=%s', (ethnicity, gender, expectedName) => {
expect(getFirstName(ethnicity, gender)).toMatch(expectedName);
});
test('should get random first name', () => {
expect(getFirstName()).toStrictEqual(expect.any(String));
});
test('should throw an error with unsupported gender', () => {
expect(() => getFirstName(undefined, 'unknown')).toThrow(TypeError);
});
test('should throw an error with unsupported ethnicity', () => {
expect(() => getFirstName('unknown', undefined)).toThrow(TypeError);
});
});
describe('getLastName', () => {
test.each([
['christian', "ח'ורי"],
['druze', 'חלבי'],
['jew', 'כהן'],
['muslim', 'אגבאריה'],
['other', ''],
])('should get random last name for ethnicity=%s', (ethnicity, expectedName) => {
expect(getLastName(ethnicity)).toMatch(expectedName);
});
test('should get random last name', () => {
expect(getLastName()).toStrictEqual(expect.any(String));
});
test('should throw an error with unsupported ethnicity', () => {
expect(() => getLastName('unknown')).toThrow(TypeError);
});
});
describe('getFullName', () => {
test('should get random full name', () => {
expect(getFullName()).toStrictEqual(expect.any(String));
});
test('should throw an error with unsupported gender', () => {
expect(() => getFullName(undefined, 'unknown')).toThrow(TypeError);
});
test('should throw an error with unsupported ethnicity', () => {
expect(() => getFullName('unknown', undefined)).toThrow(TypeError);
});
});
});