-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathuseTestsList.ts
More file actions
80 lines (74 loc) · 2.33 KB
/
useTestsList.ts
File metadata and controls
80 lines (74 loc) · 2.33 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
import { useState, useCallback } from 'react';
import type { TestSuites } from '../types/tests';
import { TestsContext } from '../tests/util';
import '../tests/blake3/blake3_tests';
import '../tests/cipher/cipher_tests';
import '../tests/cipher/chacha_tests';
import '../tests/cipher/xsalsa20_tests';
import '../tests/cipher/xsalsa20_poly1305_tests';
import '../tests/cipher/xchacha20_poly1305_tests';
import '../tests/dh/dh_tests';
import '../tests/ecdh/ecdh_tests';
import '../tests/hash/hash_tests';
import '../tests/hmac/hmac_tests';
import '../tests/hkdf/hkdf_tests';
import '../tests/jose/jose';
import '../tests/keys/create_keys';
import '../tests/keys/generate_key';
import '../tests/keys/generate_keypair';
import '../tests/keys/public_cipher';
import '../tests/keys/sign_verify_streaming';
import '../tests/keys/sign_verify_oneshot';
import '../tests/pbkdf2/pbkdf2_tests';
import '../tests/random/random_tests';
import '../tests/scrypt/scrypt_tests';
import '../tests/subtle/deriveBits';
import '../tests/subtle/derive_key';
import '../tests/subtle/digest';
import '../tests/subtle/encrypt_decrypt';
import '../tests/subtle/generateKey';
import '../tests/subtle/import_export';
import '../tests/subtle/jwk_rfc7517_tests';
import '../tests/subtle/sign_verify';
import '../tests/subtle/wrap_unwrap';
import '../tests/utils/utils_tests';
export const useTestsList = (): [
TestSuites,
(description: string) => void,
() => void,
() => void,
] => {
const [suites, setSuites] = useState<TestSuites>(TestsContext);
const toggle = useCallback(
(description: string) => {
setSuites(prevSuites => {
const newSuites = { ...prevSuites };
if (newSuites[description]) {
newSuites[description] = {
...newSuites[description],
value: !newSuites[description].value,
};
}
return newSuites;
});
},
[setSuites],
);
const clearAll = useCallback(() => {
setSuites(suites => {
Object.values(suites).forEach(suite => {
suite.value = false;
});
return { ...suites };
});
}, [setSuites]);
const checkAll = useCallback(() => {
setSuites(suites => {
Object.values(suites).forEach(suite => {
suite.value = true;
});
return { ...suites };
});
}, [setSuites]);
return [suites, toggle, clearAll, checkAll];
};