2017-06-20 04:50:31 -04:00
|
|
|
import Vue from 'vue';
|
2017-08-30 12:11:19 -04:00
|
|
|
import GraphFlag from '~/monitoring/components/graph/flag.vue';
|
2018-01-08 04:35:23 -05:00
|
|
|
import { deploymentData } from '../mock_data';
|
2017-06-20 04:50:31 -04:00
|
|
|
|
|
|
|
const createComponent = (propsData) => {
|
2017-08-30 12:11:19 -04:00
|
|
|
const Component = Vue.extend(GraphFlag);
|
2017-06-20 04:50:31 -04:00
|
|
|
|
|
|
|
return new Component({
|
|
|
|
propsData,
|
|
|
|
}).$mount();
|
|
|
|
};
|
|
|
|
|
2017-10-05 04:52:06 -04:00
|
|
|
const defaultValuesComponent = {
|
|
|
|
currentXCoordinate: 200,
|
|
|
|
currentYCoordinate: 100,
|
|
|
|
currentFlagPosition: 100,
|
|
|
|
currentData: {
|
|
|
|
time: new Date('2017-06-04T18:17:33.501Z'),
|
|
|
|
value: '1.49609375',
|
|
|
|
},
|
|
|
|
graphHeight: 300,
|
|
|
|
graphHeightOffset: 120,
|
|
|
|
showFlagContent: true,
|
2018-01-08 04:35:23 -05:00
|
|
|
realPixelRatio: 1,
|
|
|
|
timeSeries: [{
|
|
|
|
values: [{
|
|
|
|
time: new Date('2017-06-04T18:17:33.501Z'),
|
|
|
|
value: '1.49609375',
|
|
|
|
}],
|
|
|
|
}],
|
|
|
|
unitOfDisplay: 'ms',
|
|
|
|
currentDataIndex: 0,
|
|
|
|
legendTitle: 'Average',
|
|
|
|
};
|
|
|
|
|
|
|
|
const deploymentFlagData = {
|
|
|
|
...deploymentData[0],
|
|
|
|
ref: deploymentData[0].ref.name,
|
|
|
|
xPos: 10,
|
|
|
|
time: new Date(deploymentData[0].created_at),
|
2017-10-05 04:52:06 -04:00
|
|
|
};
|
|
|
|
|
2017-08-30 12:11:19 -04:00
|
|
|
describe('GraphFlag', () => {
|
2018-01-08 04:35:23 -05:00
|
|
|
let component;
|
2017-06-20 04:50:31 -04:00
|
|
|
|
2018-01-08 04:35:23 -05:00
|
|
|
it('has a line at the currentXCoordinate', () => {
|
|
|
|
component = createComponent(defaultValuesComponent);
|
|
|
|
|
|
|
|
expect(component.$el.style.left)
|
|
|
|
.toEqual(`${70 + component.currentXCoordinate}px`);
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
|
|
|
|
2018-01-08 04:35:23 -05:00
|
|
|
describe('Deployment flag', () => {
|
|
|
|
it('shows a deployment flag when deployment data provided', () => {
|
|
|
|
const deploymentFlagComponent = createComponent({
|
|
|
|
...defaultValuesComponent,
|
|
|
|
deploymentFlagData,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(
|
|
|
|
deploymentFlagComponent.$el.querySelector('.popover-title'),
|
|
|
|
).toContainText('Deployed');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('contains the ref when a tag is available', () => {
|
|
|
|
const deploymentFlagComponent = createComponent({
|
|
|
|
...defaultValuesComponent,
|
|
|
|
deploymentFlagData: {
|
|
|
|
...deploymentFlagData,
|
|
|
|
sha: 'f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187',
|
|
|
|
tag: true,
|
|
|
|
ref: '1.0',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(
|
|
|
|
deploymentFlagComponent.$el.querySelector('.deploy-meta-content'),
|
|
|
|
).toContainText('f5bcd1d9');
|
|
|
|
|
|
|
|
expect(
|
|
|
|
deploymentFlagComponent.$el.querySelector('.deploy-meta-content'),
|
|
|
|
).toContainText('1.0');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not contain the ref when a tag is unavailable', () => {
|
|
|
|
const deploymentFlagComponent = createComponent({
|
|
|
|
...defaultValuesComponent,
|
|
|
|
deploymentFlagData: {
|
|
|
|
...deploymentFlagData,
|
|
|
|
sha: 'f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187',
|
|
|
|
tag: false,
|
|
|
|
ref: '1.0',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(
|
|
|
|
deploymentFlagComponent.$el.querySelector('.deploy-meta-content'),
|
|
|
|
).toContainText('f5bcd1d9');
|
2017-06-20 04:50:31 -04:00
|
|
|
|
2018-01-08 04:35:23 -05:00
|
|
|
expect(
|
|
|
|
deploymentFlagComponent.$el.querySelector('.deploy-meta-content'),
|
|
|
|
).not.toContainText('1.0');
|
|
|
|
});
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('Computed props', () => {
|
2018-01-08 04:35:23 -05:00
|
|
|
beforeEach(() => {
|
|
|
|
component = createComponent(defaultValuesComponent);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('formatTime', () => {
|
|
|
|
expect(component.formatTime).toMatch(/\d:17PM/);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('formatDate', () => {
|
|
|
|
expect(component.formatDate).toEqual('Sun, Jun 4');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('cursorStyle', () => {
|
|
|
|
expect(component.cursorStyle).toEqual({
|
|
|
|
top: '20px',
|
|
|
|
left: '270px',
|
|
|
|
height: '180px',
|
|
|
|
});
|
|
|
|
});
|
2017-06-20 04:50:31 -04:00
|
|
|
|
2018-01-08 04:35:23 -05:00
|
|
|
it('flagOrientation', () => {
|
|
|
|
expect(component.flagOrientation).toEqual('left');
|
2017-06-20 04:50:31 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|