@carbon/ibm-cloud-cognitive-cdai
Version:
Carbon for Cloud & Cognitive CD&AI UI components
46 lines (45 loc) • 1.66 kB
JavaScript
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
//
// 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.
//
import React from 'react';
import { idePrefix } from './settings';
import { shallow } from 'enzyme';
describe('settings', function () {
beforeEach(function () {
jest.resetAllMocks();
});
it('uses the default css prefix', function () {
expect(idePrefix).toEqual('ide');
});
it('can use custom prefix with a react component', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
var _yield$import, IdeButton, wrapper;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
jest.mock('./settings', function () {
return {
idePrefix: 'my-prefix'
};
});
// dynamic import so we can modify the import on the component before using it
_context.next = 3;
return import('../../components/IdeButton');
case 3:
_yield$import = _context.sent;
IdeButton = _yield$import.IdeButton;
wrapper = shallow(/*#__PURE__*/React.createElement(IdeButton, {
iconAnimation: "rotate-180-anti"
}));
expect(wrapper.find('.my-prefix-btn--rotate-180-anti')).toHaveLength(1);
case 7:
case "end":
return _context.stop();
}
}, _callee);
})));
});