UNPKG

@carbon/ibm-cloud-cognitive-cdai

Version:
64 lines (62 loc) 3.61 kB
"use strict"; var _typeof = require("@babel/runtime/helpers/typeof"); var _IdeNavigationItems = require("./IdeNavigationItems"); var jth = _interopRequireWildcard(require("../../../component_helpers/jest_test_helper_functions.js")); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } // // Copyright IBM Corp. 2020, 2020 // // This source code is licensed under the Apache-2.0 license found in the // LICENSE file in the root directory of this source tree. // describe('IdeNavigationItem unit tests', function () { var component, unmount; var mountTestComponent = function mountTestComponent(testComponent) { var defaultProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var test = jth.mountComponent(jth.getJSXForComponent(testComponent, defaultProps, props)); component = test.component; unmount = test.unmount; }; afterEach(function () { // if unmount defined, call it to clear up any mounted component unmount && unmount(); }); it('IdeSideNavLink the expected structure with no props provided', function () { mountTestComponent(_IdeNavigationItems.IdeSideNavLink); expect(component.hasClass('undefined')).toBe(false); // confirm if no className passed we dont put undefined in expect(component.hasClass('ide-navigation--altHover-link')).toBe(true); expect(component.props().large).toBe(true); }); it('IdeSideNavMenu the expected structure with no props provided', function () { mountTestComponent(_IdeNavigationItems.IdeSideNavMenu); expect(component.hasClass('undefined')).toBe(false); // confirm if no className passed we dont put undefined in expect(component.hasClass('ide-navigation--altHover-menu')).toBe(true); expect(component.props().large).toBe(true); }); it('IdeSideNavLink is gets the expected props', function () { mountTestComponent(_IdeNavigationItems.IdeSideNavLink, { myProp: true, className: 'foo' }); // check expected prop and classname are added expect(component.props().large).toBe(true); expect(component.hasClass('ide-navigation--altHover-link')).toBe(true); // other props passed through expect(component.props().myProp).toBe(true); expect(component.hasClass('foo')).toBe(true); }); it('IdeSideNavMenu is gets the expected props', function () { mountTestComponent(_IdeNavigationItems.IdeSideNavMenu, { myProp: true, className: 'foo' }); // check expected prop and classname are added expect(component.props().large).toBe(true); expect(component.hasClass('ide-navigation--altHover-menu')).toBe(true); // other props passed through expect(component.props().myProp).toBe(true); expect(component.hasClass('foo')).toBe(true); }); });