You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ValidationInput-test.tsx 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import * as React from 'react';
  21. import { shallow } from 'enzyme';
  22. import ValidationInput from '../ValidationInput';
  23. it('should render', () => {
  24. expect(
  25. shallow(
  26. <ValidationInput
  27. description="My description"
  28. error={undefined}
  29. help="Help message"
  30. id="field-id"
  31. isInvalid={false}
  32. isValid={false}
  33. label="Field label"
  34. required={true}>
  35. <div />
  36. </ValidationInput>
  37. )
  38. ).toMatchSnapshot();
  39. });
  40. it('should render with error', () => {
  41. expect(
  42. shallow(
  43. <ValidationInput
  44. description="My description"
  45. error="Field error message"
  46. id="field-id"
  47. isInvalid={true}
  48. isValid={false}
  49. label="Field label">
  50. <div />
  51. </ValidationInput>
  52. )
  53. ).toMatchSnapshot();
  54. });
  55. it('should render when valid', () => {
  56. expect(
  57. shallow(
  58. <ValidationInput
  59. description="My description"
  60. error={undefined}
  61. id="field-id"
  62. isInvalid={false}
  63. isValid={true}
  64. label="Field label"
  65. required={true}>
  66. <div />
  67. </ValidationInput>
  68. )
  69. ).toMatchSnapshot();
  70. });