1import ExpoRandom from '../ExpoRandom'; 2import * as Random from '../Random'; 3 4it(`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 11it(`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 17it(`accepts valid byte counts`, async () => { 18 ExpoRandom.getRandomBase64StringAsync.mockImplementation(async () => ''); 19 await expect(Random.getRandomBytesAsync(0)); 20 await expect(Random.getRandomBytesAsync(1024)); 21 await expect(Random.getRandomBytesAsync(512.5)); 22}); 23