UNPKG

2.4 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports['default'] = validateAdapter;
7
8var _EnzymeAdapter = require('./EnzymeAdapter');
9
10var _EnzymeAdapter2 = _interopRequireDefault(_EnzymeAdapter);
11
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
13
14function validateAdapter(adapter) {
15 if (!adapter) {
16 throw new Error('\n Enzyme Internal Error: Enzyme expects an adapter to be configured, but found none.\n To configure an adapter, you should call `Enzyme.configure({ adapter: new Adapter() })`\n before using any of Enzyme\'s top level APIs, where `Adapter` is the adapter\n corresponding to the library currently being tested. For example:\n\n import Adapter from \'enzyme-adapter-react-15\';\n\n To find out more about this, see http://airbnb.io/enzyme/docs/installation/index.html\n ');
17 }
18 if (typeof adapter === 'function') {
19 if (Object.getPrototypeOf(adapter) === _EnzymeAdapter2['default']) {
20 throw new Error('\n Enzyme Internal Error: Enzyme expects an adapter instance to be configured -\n you provided an adapter *constructor*.\n To configure an adapter, you should call `Enzyme.configure({ adapter: new Adapter() })`\n before using any of Enzyme\'s top level APIs, where `Adapter` is the adapter\n corresponding to the library currently being tested. For example:\n\n import Adapter from \'enzyme-adapter-react-15\';\n\n To find out more about this, see http://airbnb.io/enzyme/docs/installation/index.html\n ');
21 }
22 throw new Error('\n Enzyme Internal Error: Enzyme expects an adapter to be configured -\n an enzyme adapter must be an object instance; you provided a function.\n To configure an adapter, you should call `Enzyme.configure({ adapter: new Adapter() })`\n before using any of Enzyme\'s top level APIs, where `Adapter` is the adapter\n corresponding to the library currently being tested. For example:\n\n import Adapter from \'enzyme-adapter-react-15\';\n\n To find out more about this, see http://airbnb.io/enzyme/docs/installation/index.html\n ');
23 }
24 if (!(adapter instanceof _EnzymeAdapter2['default'])) {
25 throw new Error('Enzyme Internal Error: configured enzyme adapter did not inherit from the EnzymeAdapter base class');
26 }
27}
\No newline at end of file