xref: /expo/apps/test-suite/tests/Random.js (revision 4a05dfd5)
1import * as Random from 'expo-random';
2
3export const name = 'Random';
4
5export async function test({ describe, it, expect }) {
6  describe('Random', async () => {
7    it('getRandomBytesAsync()', async () => {
8      const length = 4;
9      const bytes = await Random.getRandomBytesAsync(length);
10      expect(bytes instanceof Uint8Array).toBe(true);
11      expect(bytes.length).toBe(length);
12
13      // Verify with high likelihood that we get different values each time
14      const moreBytes = await Random.getRandomBytesAsync(length);
15      expect([...moreBytes]).not.toEqual([...bytes]);
16    });
17  });
18}
19