UNPKG

@kiwicom/smart-faq

Version:

Smart FAQ

88 lines (80 loc) 2.53 kB
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); var React = _interopRequireWildcard(require("react")); var _enzyme = require("enzyme"); var _mockdate = _interopRequireDefault(require("mockdate")); var _GuaranteeNeededResolver = require("../GuaranteeNeededResolver"); // @flow var mockRefType /*: any*/ = null; beforeEach(function () { return _mockdate.default.set('2018-08-29T21:00:00.000Z'); }); afterEach(function () { return _mockdate.default.reset(); }); jest.mock('../../helpers/analytics/cuckoo'); var commonFields = { databaseId: '1234567', status: 'CONFIRMED', contactDetails: null }; describe('GuaranteeNeededResolver', function () { it("turn on Guarantee chat when it's not supported for booking", function () { var booking = (0, _objectSpread2.default)({ $refType: mockRefType }, commonFields, { upcomingLeg: { departure: { airport: null }, arrival: { airport: null } }, customerSupport: { hasGuaranteeChat: true } }); var toggleGuaranteeChat = jest.fn(); (0, _enzyme.shallow)(React.createElement(_GuaranteeNeededResolver.UnwrappedGuaranteeNeededResolver, { booking: booking, eventSource: "smartFAQ", showGuaranteeChat: false, guaranteeChatBookingInfo: null, toggleGuaranteeChat: toggleGuaranteeChat, onSetBookingInfo: jest.fn() })); expect(toggleGuaranteeChat).toBeCalledWith(true); }); it("does not turn on Guarantee when it's not supported for booking", function () { var booking = (0, _objectSpread2.default)({ $refType: mockRefType }, commonFields, { upcomingLeg: { departure: { airport: null }, arrival: { airport: null } }, customerSupport: { hasGuaranteeChat: false } }); var toggleGuaranteeChat = jest.fn(); (0, _enzyme.shallow)(React.createElement(_GuaranteeNeededResolver.UnwrappedGuaranteeNeededResolver, { booking: booking, eventSource: "smartFAQ", showGuaranteeChat: false, guaranteeChatBookingInfo: null, toggleGuaranteeChat: toggleGuaranteeChat, onSetBookingInfo: jest.fn() })); expect(toggleGuaranteeChat).not.toBeCalled(); }); });