Skip to content

Commit 4b83bc2

Browse files
authoredOct 16, 2020
Merge pull request #1346 from nextcloud/tests/noid/color-snapshot
2 parents 1ea8340 + cb71924 commit 4b83bc2

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed
 

‎build/usernameToColor-export.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const snapshot = require('./../src/functions/usernameToColor/__snapshots__/usernameToColor.spec.js.snap')
2+
const result = {}
3+
Object.keys(snapshot).map((key) => {
4+
const uid = key.replace('usernameToColor ', '').replace(' has the proper color 1', '')
5+
result[uid] = JSON.parse(snapshot[key])
6+
})
7+
console.log(JSON.stringify(result))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`usernameToColor has the proper color 1`] = `"#0082c9"`;
4+
5+
exports[`usernameToColor , has the proper color 1`] = `"#1e78c1"`;
6+
7+
exports[`usernameToColor . has the proper color 1`] = `"#c98879"`;
8+
9+
exports[`usernameToColor 123e4567-e89b-12d3-a456-426614174000 has the proper color 1`] = `"#bc5c91"`;
10+
11+
exports[`usernameToColor Akeel Robertson has the proper color 1`] = `"#9750a4"`;
12+
13+
exports[`usernameToColor Alishia Ann Lowry has the proper color 1`] = `"#d09e6d"`;
14+
15+
exports[`usernameToColor Arham Johnson has the proper color 1`] = `"#0082c9"`;
16+
17+
exports[`usernameToColor Brayden Truong has the proper color 1`] = `"#d09e6d"`;
18+
19+
exports[`usernameToColor Daphne Roy has the proper color 1`] = `"#9750a4"`;
20+
21+
exports[`usernameToColor Ellena Wright Frederic Conway has the proper color 1`] = `"#c37285"`;
22+
23+
exports[`usernameToColor Gianluca Hills has the proper color 1`] = `"#d6b461"`;
24+
25+
exports[`usernameToColor Haseeb Stephens has the proper color 1`] = `"#d6b461"`;
26+
27+
exports[`usernameToColor Idris Mac has the proper color 1`] = `"#9750a4"`;
28+
29+
exports[`usernameToColor Kristi Fisher has the proper color 1`] = `"#0082c9"`;
30+
31+
exports[`usernameToColor Lillian Wall has the proper color 1`] = `"#bc5c91"`;
32+
33+
exports[`usernameToColor Lorelai Taylor has the proper color 1`] = `"#ddcb55"`;
34+
35+
exports[`usernameToColor Madina Knight has the proper color 1`] = `"#9750a4"`;
36+
37+
exports[`usernameToColor Meeting has the proper color 1`] = `"#c98879"`;
38+
39+
exports[`usernameToColor Private Circle has the proper color 1`] = `"#c37285"`;
40+
41+
exports[`usernameToColor Rae Hope has the proper color 1`] = `"#795aab"`;
42+
43+
exports[`usernameToColor Santiago Singleton has the proper color 1`] = `"#bc5c91"`;
44+
45+
exports[`usernameToColor Sid Combs has the proper color 1`] = `"#d09e6d"`;
46+
47+
exports[`usernameToColor TestCircle has the proper color 1`] = `"#499aa2"`;
48+
49+
exports[`usernameToColor Tom Mörtel has the proper color 1`] = `"#248eb5"`;
50+
51+
exports[`usernameToColor Vivienne Jacobs has the proper color 1`] = `"#1e78c1"`;
52+
53+
exports[`usernameToColor Zaki Cortes has the proper color 1`] = `"#6ea68f"`;
54+
55+
exports[`usernameToColor a user has the proper color 1`] = `"#5b64b3"`;
56+
57+
exports[`usernameToColor admin has the proper color 1`] = `"#d09e6d"`;
58+
59+
exports[`usernameToColor admin@cloud.example.com has the proper color 1`] = `"#9750a4"`;
60+
61+
exports[`usernameToColor another user has the proper color 1`] = `"#ddcb55"`;
62+
63+
exports[`usernameToColor asd has the proper color 1`] = `"#248eb5"`;
64+
65+
exports[`usernameToColor bar has the proper color 1`] = `"#0082c9"`;
66+
67+
exports[`usernameToColor foo has the proper color 1`] = `"#d09e6d"`;
68+
69+
exports[`usernameToColor wasd has the proper color 1`] = `"#b6469d"`;
70+
71+
exports[`usernameToColor مرحبا بالعالم has the proper color 1`] = `"#c98879"`;
72+
73+
exports[`usernameToColor 🙈 has the proper color 1`] = `"#b6469d"`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import usernameToColor from '@/functions/usernameToColor/index'
2+
3+
const rgbToHex = (color) => {
4+
return '#' + ((1 << 24) + (color.r << 16) + (color.g << 8) + color.b).toString(16).slice(1)
5+
}
6+
7+
describe('usernameToColor', () => {
8+
'use strict'
9+
10+
const usernames = [
11+
'', ',', '.', 'admin', 'foo', 'bar', 'asd', 'wasd', 'a user', 'another user', 'admin@cloud.example.com',
12+
'Lorelai Taylor',
13+
'Lillian Wall',
14+
'Haseeb Stephens',
15+
'Rae Hope',
16+
'Santiago Singleton',
17+
'Daphne Roy',
18+
'Arham Johnson',
19+
'Madina Knight',
20+
'Sid Combs',
21+
'Zaki Cortes',
22+
'Ellena Wright Frederic Conway',
23+
'Alishia Ann Lowry',
24+
'Idris Mac',
25+
'Kristi Fisher',
26+
'Gianluca Hills',
27+
'Vivienne Jacobs',
28+
'Brayden Truong',
29+
'Akeel Robertson',
30+
'Tom Mörtel',
31+
'🙈',
32+
'مرحبا بالعالم',
33+
'123e4567-e89b-12d3-a456-426614174000',
34+
'Meeting', 'TestCircle', 'Private Circle',
35+
]
36+
37+
usernames.forEach((key) => {
38+
it(key + ' has the proper color', () => {
39+
expect(rgbToHex(usernameToColor(key))).toMatchSnapshot()
40+
})
41+
})
42+
43+
})

0 commit comments

Comments
 (0)
Please sign in to comment.