Repository: facebook/react
File: packages/react-dom/src/__tests__/ReactDOMSelect-test.js (JavaScript)

Code before:
          <option value="gorilla">A gorilla!</option>
        </select>,
      );
    });

    it('should not warn about missing onChange if onChange is set', () => {
      const change = jest.fn();

      ReactTestUtils.renderIntoDocument(
        <select value="monkey" onChange={change}>
          <option value="monkey">A monkey!</option>
          <option value="giraffe">A giraffe!</option>
          <option value="gorilla">A gorilla!</option>
        </select>,
      );
    });

    it('should not warn about missing onChange if disabled is true', () => {
      ReactTestUtils.renderIntoDocument(
        <select value="monkey" disabled={true}>
          <option value="monkey">A monkey!</option>
          <option value="giraffe">A giraffe!</option>
          <option value="gorilla">A gorilla!</option>
        </select>,
      );
    });

    it('should warn about missing onChange if value is false', () => {
      expect(() =>
        ReactTestUtils.renderIntoDocument(
          <select value={false}>
            <option value="monkey">A monkey!</option>
            <option value="giraffe">A giraffe!</option>
            <option value="gorilla">A gorilla!</option>
          </select>,
        ),
      ).toErrorDev(
        'Warning: You provided a `value` prop to a form ' +
          'field without an `onChange` handler. This will render a read-only ' +
          'field. If the field should be mutable use `defaultValue`. ' +
          'Otherwise, set `onChange`.',
      );
    });

    it('should warn about missing onChange if value is 0', () => {
      expect(() =>
        ReactTestUtils.renderIntoDocument(
          <select value={0}>
            <option value="monkey">A monkey!</option>
            <option value="giraffe">A giraffe!</option>
            <option value="gorilla">A gorilla!</option>

Review comment (bug):
Why is there no `expect` statement? If these blocks will be executed and print the error, would all of these tests fail?

Code after:
          <select value={undefined}>
            <option value="monkey">A monkey!</option>
            <option value="giraffe">A giraffe!</option>
            <option value="gorilla">A gorilla!</option>
          </select>,
        );
      }).not.toThrow();
    });

    it('should not warn about missing onChange if onChange is set', () => {
      const change = jest.fn();
      expect(() => {
        ReactTestUtils.renderIntoDocument(
          <select value="monkey" onChange={change}>
            <option value="monkey">A monkey!</option>
            <option value="giraffe">A giraffe!</option>
            <option value="gorilla">A gorilla!</option>
          </select>,
        );
      }).not.toThrow();
    });

    it('should not warn about missing onChange if disabled is true', () => {
      expect(() => {
        ReactTestUtils.renderIntoDocument(
          <select value="monkey" disabled={true}>
            <option value="monkey">A monkey!</option>
            <option value="giraffe">A giraffe!</option>
            <option value="gorilla">A gorilla!</option>
          </select>,
        );
      }).not.toThrow();
    });

    it('should warn about missing onChange if value is false', () => {
      expect(() =>
        ReactTestUtils.renderIntoDocument(
          <select value={false}>
            <option value="monkey">A monkey!</option>
            <option value="giraffe">A giraffe!</option>
            <option value="gorilla">A gorilla!</option>
          </select>,
        ),
      ).toErrorDev(
        'Warning: You provided a `value` prop to a form ' +
          'field without an `onChange` handler. This will render a read-only ' +
          'field. If the field should be mutable use `defaultValue`. ' +
          'Otherwise, set `onChange`.',
      );
    });