Mock Math.random()

This commit is contained in:
Nathan Bierema 2021-10-21 23:58:27 -04:00
parent a8876fb71a
commit 41a955eddf
2 changed files with 18 additions and 6 deletions

View File

@ -5,6 +5,18 @@ import { Form } from '../src';
import { schema, uiSchema, formData } from '../src/Form/schema';
describe('Form', function () {
let random: () => number;
beforeAll(() => {
random = Math.random;
Math.random = jest.fn(() => 0.25546350798039463);
});
afterAll(() => {
Math.random = random;
console.log(Math.random());
});
it('renders correctly', () => {
const { container } = render(
<Form formData={formData} schema={schema} uiSchema={uiSchema} />

View File

@ -618,7 +618,7 @@ exports[`Form renders with no button 1`] = `
>
<span>
<input
name="0.8152240754640543"
name="0.25546350798039463"
type="radio"
value="1"
/>
@ -632,7 +632,7 @@ exports[`Form renders with no button 1`] = `
>
<span>
<input
name="0.8152240754640543"
name="0.25546350798039463"
type="radio"
value="2"
/>
@ -646,7 +646,7 @@ exports[`Form renders with no button 1`] = `
>
<span>
<input
name="0.8152240754640543"
name="0.25546350798039463"
type="radio"
value="3"
/>
@ -960,7 +960,7 @@ exports[`Form renders with primary button 1`] = `
>
<span>
<input
name="0.6341426827216534"
name="0.25546350798039463"
type="radio"
value="1"
/>
@ -974,7 +974,7 @@ exports[`Form renders with primary button 1`] = `
>
<span>
<input
name="0.6341426827216534"
name="0.25546350798039463"
type="radio"
value="2"
/>
@ -988,7 +988,7 @@ exports[`Form renders with primary button 1`] = `
>
<span>
<input
name="0.6341426827216534"
name="0.25546350798039463"
type="radio"
value="3"
/>