2017-06-20 04:50:31 -04:00
|
|
|
import Vue from 'vue';
|
2017-08-30 12:11:19 -04:00
|
|
|
import EmptyState from '~/monitoring/components/empty_state.vue';
|
2017-06-20 04:50:31 -04:00
|
|
|
import { statePaths } from './mock_data';
|
|
|
|
|
|
|
|
const createComponent = (propsData) => {
|
2017-08-30 12:11:19 -04:00
|
|
|
const Component = Vue.extend(EmptyState);
|
2017-06-20 04:50:31 -04:00
|
|
|
|
|
|
|
return new Component({
|
|
|
|
propsData,
|
|
|
|
}).$mount();
|
|
|
|
};
|
|
|
|
|
|
|
|
function getTextFromNode(component, selector) {
|
|
|
|
return component.$el.querySelector(selector).firstChild.nodeValue.trim();
|
|
|
|
}
|
|
|
|
|
2017-08-30 12:11:19 -04:00
|
|
|
describe('EmptyState', () => {
|
2017-06-20 04:50:31 -04:00
|
|
|
describe('Computed props', () => {
|
|
|
|
it('currentState', () => {
|
|
|
|
const component = createComponent({
|
|
|
|
selectedState: 'gettingStarted',
|
|
|
|
settingsPath: statePaths.settingsPath,
|
|
|
|
documentationPath: statePaths.documentationPath,
|
2017-09-22 04:39:47 -04:00
|
|
|
emptyGettingStartedSvgPath: 'foo',
|
|
|
|
emptyLoadingSvgPath: 'foo',
|
|
|
|
emptyUnableToConnectSvgPath: 'foo',
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(component.currentState).toBe(component.states.gettingStarted);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('showButtonDescription returns a description with a link for the unableToConnect state', () => {
|
|
|
|
const component = createComponent({
|
|
|
|
selectedState: 'unableToConnect',
|
|
|
|
settingsPath: statePaths.settingsPath,
|
|
|
|
documentationPath: statePaths.documentationPath,
|
2017-09-22 04:39:47 -04:00
|
|
|
emptyGettingStartedSvgPath: 'foo',
|
|
|
|
emptyLoadingSvgPath: 'foo',
|
|
|
|
emptyUnableToConnectSvgPath: 'foo',
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(component.showButtonDescription).toEqual(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('showButtonDescription returns the description without a link for any other state', () => {
|
|
|
|
const component = createComponent({
|
|
|
|
selectedState: 'loading',
|
|
|
|
settingsPath: statePaths.settingsPath,
|
|
|
|
documentationPath: statePaths.documentationPath,
|
2017-09-22 04:39:47 -04:00
|
|
|
emptyGettingStartedSvgPath: 'foo',
|
|
|
|
emptyLoadingSvgPath: 'foo',
|
|
|
|
emptyUnableToConnectSvgPath: 'foo',
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(component.showButtonDescription).toEqual(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should show the gettingStarted state', () => {
|
|
|
|
const component = createComponent({
|
|
|
|
selectedState: 'gettingStarted',
|
|
|
|
settingsPath: statePaths.settingsPath,
|
2018-01-31 18:11:18 -05:00
|
|
|
clustersPath: statePaths.clustersPath,
|
2017-06-20 04:50:31 -04:00
|
|
|
documentationPath: statePaths.documentationPath,
|
2017-09-22 04:39:47 -04:00
|
|
|
emptyGettingStartedSvgPath: 'foo',
|
|
|
|
emptyLoadingSvgPath: 'foo',
|
|
|
|
emptyUnableToConnectSvgPath: 'foo',
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(component.$el.querySelector('svg')).toBeDefined();
|
|
|
|
expect(getTextFromNode(component, '.state-title')).toEqual(component.states.gettingStarted.title);
|
|
|
|
expect(getTextFromNode(component, '.state-description')).toEqual(component.states.gettingStarted.description);
|
|
|
|
expect(getTextFromNode(component, '.btn-success')).toEqual(component.states.gettingStarted.buttonText);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should show the loading state', () => {
|
|
|
|
const component = createComponent({
|
|
|
|
selectedState: 'loading',
|
|
|
|
settingsPath: statePaths.settingsPath,
|
|
|
|
documentationPath: statePaths.documentationPath,
|
2017-09-22 04:39:47 -04:00
|
|
|
emptyGettingStartedSvgPath: 'foo',
|
|
|
|
emptyLoadingSvgPath: 'foo',
|
|
|
|
emptyUnableToConnectSvgPath: 'foo',
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(component.$el.querySelector('svg')).toBeDefined();
|
|
|
|
expect(getTextFromNode(component, '.state-title')).toEqual(component.states.loading.title);
|
|
|
|
expect(getTextFromNode(component, '.state-description')).toEqual(component.states.loading.description);
|
|
|
|
expect(getTextFromNode(component, '.btn-success')).toEqual(component.states.loading.buttonText);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should show the unableToConnect state', () => {
|
|
|
|
const component = createComponent({
|
|
|
|
selectedState: 'unableToConnect',
|
|
|
|
settingsPath: statePaths.settingsPath,
|
|
|
|
documentationPath: statePaths.documentationPath,
|
2017-09-22 04:39:47 -04:00
|
|
|
emptyGettingStartedSvgPath: 'foo',
|
|
|
|
emptyLoadingSvgPath: 'foo',
|
|
|
|
emptyUnableToConnectSvgPath: 'foo',
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(component.$el.querySelector('svg')).toBeDefined();
|
|
|
|
expect(getTextFromNode(component, '.state-title')).toEqual(component.states.unableToConnect.title);
|
|
|
|
expect(component.$el.querySelector('.state-description a')).toBeDefined();
|
|
|
|
expect(getTextFromNode(component, '.btn-success')).toEqual(component.states.unableToConnect.buttonText);
|
|
|
|
});
|
|
|
|
});
|