1 | import ExpoRandom from '../ExpoRandom';
|
2 | import * as Random from '../Random';
|
3 |
|
4 | it(`invokes native method correctly`, async () => {
|
5 | ExpoRandom.getRandomBase64StringAsync.mockImplementationOnce(async () => '');
|
6 | const value = await Random.getRandomBytesAsync(0);
|
7 | expect(value instanceof Uint8Array).toBe(true);
|
8 | expect(ExpoRandom.getRandomBase64StringAsync).toHaveBeenLastCalledWith(0);
|
9 | });
|
10 |
|
11 | it(`returns an array with the desired number of bytes`, async () => {
|
12 | ExpoRandom.getRandomBase64StringAsync.mockImplementationOnce(async () => 'r6ip');
|
13 | const value = await Random.getRandomBytesAsync(3);
|
14 | expect(value.length).toBe(3);
|
15 | });
|
16 |
|
17 | it(`accepts valid byte counts`, async () => {
|
18 | await expect(Random.getRandomBytesAsync(0));
|
19 | await expect(Random.getRandomBytesAsync(1024));
|
20 | await expect(Random.getRandomBytesAsync(512.5));
|
21 | });
|