2019-01-15 18:53:27 -05:00
|
|
|
/**
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
|
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
|
|
* to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
2016-10-25 19:44:32 -04:00
|
|
|
import React from 'react';
|
2018-10-22 21:36:07 -04:00
|
|
|
import configureStore from 'redux-mock-store';
|
2017-06-19 14:39:32 -04:00
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
import sinon from 'sinon';
|
2018-10-22 21:36:07 -04:00
|
|
|
import thunk from 'redux-thunk';
|
2020-05-07 17:18:10 -04:00
|
|
|
import SqlEditorLeftBar from 'src/SqlLab/components/SqlEditorLeftBar';
|
|
|
|
import TableElement from 'src/SqlLab/components/TableElement';
|
2016-10-25 19:44:32 -04:00
|
|
|
|
2019-01-15 11:53:24 -05:00
|
|
|
import { table, defaultQueryEditor, initialState } from './fixtures';
|
2017-04-13 18:04:09 -04:00
|
|
|
|
2016-10-25 19:44:32 -04:00
|
|
|
describe('SqlEditorLeftBar', () => {
|
|
|
|
const mockedProps = {
|
2017-06-19 14:39:32 -04:00
|
|
|
actions: {
|
|
|
|
queryEditorSetSchema: sinon.stub(),
|
|
|
|
queryEditorSetDb: sinon.stub(),
|
|
|
|
setDatabases: sinon.stub(),
|
|
|
|
addTable: sinon.stub(),
|
2018-07-12 14:50:25 -04:00
|
|
|
addDangerToast: sinon.stub(),
|
2017-06-19 14:39:32 -04:00
|
|
|
},
|
2016-10-25 19:44:32 -04:00
|
|
|
tables: [table],
|
|
|
|
queryEditor: defaultQueryEditor,
|
2018-03-09 17:54:39 -05:00
|
|
|
database: {},
|
2017-04-30 13:58:09 -04:00
|
|
|
height: 0,
|
2016-10-25 19:44:32 -04:00
|
|
|
};
|
2018-10-22 21:36:07 -04:00
|
|
|
const middlewares = [thunk];
|
|
|
|
const mockStore = configureStore(middlewares);
|
|
|
|
const store = mockStore(initialState);
|
2017-06-19 14:39:32 -04:00
|
|
|
|
|
|
|
let wrapper;
|
2018-10-18 13:40:30 -04:00
|
|
|
|
2017-06-19 14:39:32 -04:00
|
|
|
beforeEach(() => {
|
2018-10-22 21:36:07 -04:00
|
|
|
wrapper = shallow(<SqlEditorLeftBar {...mockedProps} />, {
|
|
|
|
context: { store },
|
2019-01-15 11:53:24 -05:00
|
|
|
});
|
2017-06-19 14:39:32 -04:00
|
|
|
});
|
|
|
|
|
2016-10-25 19:44:32 -04:00
|
|
|
it('is valid', () => {
|
2019-11-27 17:02:48 -05:00
|
|
|
expect(React.isValidElement(<SqlEditorLeftBar {...mockedProps} />)).toBe(
|
|
|
|
true,
|
|
|
|
);
|
2016-10-25 19:44:32 -04:00
|
|
|
});
|
2018-10-18 13:40:30 -04:00
|
|
|
|
2016-10-25 19:44:32 -04:00
|
|
|
it('renders a TableElement', () => {
|
2020-07-29 13:53:06 -04:00
|
|
|
expect(wrapper.find(TableElement)).toExist();
|
2016-10-25 19:44:32 -04:00
|
|
|
});
|
|
|
|
});
|