forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SaveQuery_spec.jsx
41 lines (40 loc) · 1.32 KB
/
SaveQuery_spec.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from 'react';
import { FormControl } from 'react-bootstrap';
import { shallow } from 'enzyme';
import { describe, it } from 'mocha';
import { expect } from 'chai';
import SaveQuery from '../../../javascripts/SqlLab/components/SaveQuery';
import ModalTrigger from '../../../javascripts/components/ModalTrigger';
describe('SavedQuery', () => {
const mockedProps = {
dbId: 1,
schema: 'main',
sql: 'SELECT * FROM t',
defaultLabel: 'untitled',
animation: false,
};
it('is valid', () => {
expect(
React.isValidElement(<SaveQuery />),
).to.equal(true);
});
it('is valid with props', () => {
expect(
React.isValidElement(<SaveQuery {...mockedProps} />),
).to.equal(true);
});
it('has a ModalTrigger', () => {
const wrapper = shallow(<SaveQuery {...mockedProps} />);
expect(wrapper.find(ModalTrigger)).to.have.length(1);
});
it('has a cancel button', () => {
const wrapper = shallow(<SaveQuery {...mockedProps} />);
const modal = shallow(wrapper.instance().renderModalBody());
expect(modal.find('.cancelQuery')).to.have.length(1);
});
it('has 2 FormControls', () => {
const wrapper = shallow(<SaveQuery {...mockedProps} />);
const modal = shallow(wrapper.instance().renderModalBody());
expect(modal.find(FormControl)).to.have.length(2);
});
});