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';
|
2017-06-22 13:31:13 -04:00
|
|
|
import configureStore from 'redux-mock-store';
|
|
|
|
import thunk from 'redux-thunk';
|
|
|
|
|
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
import sinon from 'sinon';
|
2016-10-25 19:44:32 -04:00
|
|
|
|
2018-10-24 01:33:51 -04:00
|
|
|
import App from 'src/SqlLab/components/App';
|
|
|
|
import TabbedSqlEditors from 'src/SqlLab/components/TabbedSqlEditors';
|
2018-11-07 02:12:32 -05:00
|
|
|
import sqlLabReducer from 'src/SqlLab/reducers/index';
|
2016-10-25 19:44:32 -04:00
|
|
|
|
2018-10-01 14:47:06 -04:00
|
|
|
describe('SqlLab App', () => {
|
2017-06-22 13:31:13 -04:00
|
|
|
const middlewares = [thunk];
|
|
|
|
const mockStore = configureStore(middlewares);
|
2018-10-24 01:33:51 -04:00
|
|
|
const store = mockStore(sqlLabReducer(undefined, {}), {});
|
2017-06-22 13:31:13 -04:00
|
|
|
let wrapper;
|
2018-10-01 14:47:06 -04:00
|
|
|
|
2017-06-22 13:31:13 -04:00
|
|
|
beforeEach(() => {
|
2018-10-01 14:47:06 -04:00
|
|
|
wrapper = shallow(<App />, { context: { store } });
|
|
|
|
});
|
|
|
|
|
2016-10-25 19:44:32 -04:00
|
|
|
it('is valid', () => {
|
2018-10-15 16:10:18 -04:00
|
|
|
expect(React.isValidElement(<App />)).toBe(true);
|
2016-10-25 19:44:32 -04:00
|
|
|
});
|
2018-07-12 14:50:25 -04:00
|
|
|
|
2017-06-22 13:31:13 -04:00
|
|
|
it('should handler resize', () => {
|
2018-10-01 14:47:06 -04:00
|
|
|
const inner = wrapper.dive();
|
|
|
|
sinon.spy(inner.instance(), 'getHeight');
|
|
|
|
inner.instance().handleResize();
|
2018-10-15 16:10:18 -04:00
|
|
|
expect(inner.instance().getHeight.callCount).toBe(1);
|
2018-10-01 14:47:06 -04:00
|
|
|
inner.instance().getHeight.restore();
|
2017-06-22 13:31:13 -04:00
|
|
|
});
|
2018-07-12 14:50:25 -04:00
|
|
|
|
2017-06-22 13:31:13 -04:00
|
|
|
it('should render', () => {
|
2018-10-01 14:47:06 -04:00
|
|
|
const inner = wrapper.dive();
|
2018-10-15 16:10:18 -04:00
|
|
|
expect(inner.find('.SqlLab')).toHaveLength(1);
|
|
|
|
expect(inner.find(TabbedSqlEditors)).toHaveLength(1);
|
2017-06-22 13:31:13 -04:00
|
|
|
});
|
2016-10-25 19:44:32 -04:00
|
|
|
});
|