Repository: react-hook-form/react-hook-form
File: src/useForm.test.tsx (TypeScript)

Code before:
        checked: true,
      });

      expect(result.current.control.watchFieldsRef).toEqual({
        current: new Set(['test', 'test1']),
      });
      expect(result.current.watch(['test', 'test1'])).toEqual({
        test: 'data1',
        test1: 'data2',
      });
    });

    it('should watch every fields', () => {
      const { result } = renderHook(() =>
        useForm<{ test: string; test1: string }>(),
      );

      result.current.register({ type: 'radio', name: 'test', value: '' });
      result.current.register({ type: 'radio', name: 'test1', value: '' });

      expect(result.current.watch()).toEqual({ test: '', test1: '' });
      expect(result.current.control.isWatchAllRef.current).toBeTruthy();
    });
  });

  describe('watchInternal', () => {
    const tests: [
      string,
      [string | string[] | undefined, unknown | undefined, string | undefined],
      {
        watchValue?: unknown;
        watchFieldsHookRef: string[];
        watchFieldsRef: string[];
        isWatchAllRef: boolean;
      },
    ][] = [
      [
        'should set value to watchFieldsHookRef if id is defined',
        ['test', undefined, 'id'],
        {
          watchValue: undefined,
          watchFieldsHookRef: ['test'],
          watchFieldsRef: [],
          isWatchAllRef: false,
        },
      ],
      [
        'should return default value if fields are undefined',
        [undefined, { test: 'default', test1: 'default1' }, 'id'],
        {
          watchValue: { test: 'default', test1: 'default1' },

Review comment (suggestion):
I moved these test because I think these test should be performed with `useWatch`.
And I removed unnecessary test cases.

Code after:
        checked: true,
      });
      result.current.register({
        type: 'radio',
        name: 'test1',
        value: 'data2',
        checked: true,
      });

      expect(result.current.watch(['test', 'test1'])).toEqual({
        test: 'data1',
        test1: 'data2',
      });
    });

    it('should watch every fields', () => {
      const { result } = renderHook(() =>
        useForm<{ test: string; test1: string }>(),
      );

      result.current.register({ type: 'radio', name: 'test', value: '' });
      result.current.register({ type: 'radio', name: 'test1', value: '' });

      expect(result.current.watch()).toEqual({ test: '', test1: '' });
      expect(result.current.control.isWatchAllRef.current).toBeTruthy();
    });
  });

  describe('reset', () => {
    it('should reset the form and re-render the form', async () => {
      const { result } = renderHook(() => useForm<{ test: string }>());

      result.current.register({ name: 'test' });
      result.current.setValue('test', 'data');

      expect(result.current.formState.isSubmitted).toBeFalsy();
      await act(async () => {
        await result.current.handleSubmit((data) => {
          expect(data).toEqual({
            test: 'data',
          });
        })({
          preventDefault: () => {},
          persist: () => {},
        } as React.SyntheticEvent);
      });

      expect(result.current.formState.isSubmitted).toBeTruthy();
      act(() => result.current.reset());
      expect(result.current.formState.isSubmitted).toBeFalsy();
    });