Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. diff --git a/app/frontend/js/containers/product/ProductCardContainer/index.spec.jsx b/app/frontend/js/containers/product/ProductCardContainer/index.spec.jsx
  2. index 4eb46cebf8..345f54eb50 100644
  3. --- a/app/frontend/js/containers/product/ProductCardContainer/index.spec.jsx
  4. +++ b/app/frontend/js/containers/product/ProductCardContainer/index.spec.jsx
  5. @@ -12,12 +12,13 @@ import * as tracking from '../../../utils/tracking'
  6. import * as experiments from '../../../utils/experiments'
  7. import { getVariantListImages } from '../../../models/variant'
  8. import { UnconnectedProductCardContainer } from '.'
  9. -
  10. +import { checkPageLocation } from '../../../utils/location'
  11. jest.mock('../../../utils/env')
  12. jest.mock('../../../utils/featureFlags')
  13. jest.mock('../../../utils/tracking')
  14. jest.mock('../../../models/variant')
  15. jest.mock('../../../utils/experiments')
  16. +jest.mock('../../../utils/location')
  17.  
  18. describe('ProductCardContainer', () => {
  19. beforeEach(() => {
  20. @@ -387,6 +388,9 @@ describe('ProductCardContainer', () => {
  21. when(experiments.findExperiment)
  22. .calledWith('pdp_variant_preselect')
  23. .mockReturnValue({ alternative: 'control:no_preselect' })
  24. + })
  25. +
  26. + test('it calls experimentViewed on render', () => {
  27. const wrapper = shallow(
  28. <UnconnectedProductCardContainer
  29. product={{ ...boyBrow, isInitial: true }}
  30. @@ -395,9 +399,6 @@ describe('ProductCardContainer', () => {
  31. icon={13}
  32. />
  33. )
  34. - })
  35. -
  36. - test('it calls experimentViewed on render', () => {
  37. expect(tracking.experimentViewed).toHaveBeenCalledWith(
  38. 'pdp_variant_preselect',
  39. 'control:no_preselect'
  40. @@ -410,6 +411,12 @@ describe('ProductCardContainer', () => {
  41. when(experiments.findExperiment)
  42. .calledWith('pdp_variant_preselect')
  43. .mockReturnValue({ alternative: 'variant:preselect' })
  44. + when(checkPageLocation)
  45. + .calledWith('/products')
  46. + .mockReturnValue(true)
  47. + })
  48. +
  49. + test('it calls experimentViewed on render', () => {
  50. const wrapper = shallow(
  51. <UnconnectedProductCardContainer
  52. product={{ ...boyBrow, isInitial: true }}
  53. @@ -418,13 +425,23 @@ describe('ProductCardContainer', () => {
  54. icon={13}
  55. />
  56. )
  57. - })
  58. -
  59. - test('it calls experimentViewed on render', () => {
  60. expect(tracking.experimentViewed).toHaveBeenCalledWith(
  61. 'pdp_variant_preselect',
  62. 'variant:preselect'
  63. )
  64. })
  65. +
  66. + test('it displays the correct selected variant', () => {
  67. + const wrapper = shallow(
  68. + <UnconnectedProductCardContainer
  69. + product={boyBrow}
  70. + addToBag={noop}
  71. + listId="list"
  72. + icon={13}
  73. + />
  74. + )
  75. + wrapper.instance().setInitialSelection()
  76. + expect(wrapper.state().selectedVariant.sku).toBe('BBR-008-00-00')
  77. + })
  78. })
  79. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement