Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Home-test.tsx 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2018 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 Home from '../Home';
  23. import { waitAndUpdate } from '../../../../helpers/testUtils';
  24. jest.mock('../utils', () => ({
  25. requestHomepageData: jest.fn(() =>
  26. Promise.resolve({
  27. publicProjects: 236,
  28. publicLoc: 12345,
  29. pullRequests: 123456,
  30. rules: 1234,
  31. featuredProjects: [
  32. {
  33. key: 'sonarsource-jfrog.simple-js-php-project',
  34. avatarUrl: null,
  35. organizationKey: 'sonarsource-jfrog',
  36. organizationName: 'SonarSource & JFrog',
  37. name: 'Simple JS & PHP project',
  38. bugs: 0,
  39. codeSmells: 7,
  40. coverage: 9.7,
  41. duplications: 56.2,
  42. gateStatus: 'OK',
  43. languages: ['js', 'php'],
  44. maintainabilityRating: 1,
  45. ncloc: 123456,
  46. reliabilityRating: 1,
  47. securityRating: 1,
  48. vulnerabilities: 654321
  49. }
  50. ]
  51. })
  52. )
  53. }));
  54. it('should render', async () => {
  55. const wrapper = shallow(<Home />);
  56. await waitAndUpdate(wrapper);
  57. expect(wrapper).toMatchSnapshot();
  58. expect(wrapper.find('PageBackgroundHeader').dive()).toMatchSnapshot();
  59. expect(wrapper.find('PageTitle').dive()).toMatchSnapshot();
  60. expect(wrapper.find('EnhanceWorkflow').dive()).toMatchSnapshot();
  61. expect(wrapper.find('Functionality').dive()).toMatchSnapshot();
  62. expect(wrapper.find('Languages').dive()).toMatchSnapshot();
  63. expect(wrapper.find('Stats').dive()).toMatchSnapshot();
  64. expect(wrapper.find('Projects').dive()).toMatchSnapshot();
  65. });