2016-11-21 18:19:51 -05:00
|
|
|
/* global environmentsList */
|
|
|
|
|
2016-10-25 10:14:08 -04:00
|
|
|
//= require vue
|
2016-11-15 07:07:11 -05:00
|
|
|
//= require environments/stores/environments_store
|
2016-10-25 10:14:08 -04:00
|
|
|
//= require ./mock_data
|
2016-11-21 18:19:51 -05:00
|
|
|
|
2016-10-25 10:14:08 -04:00
|
|
|
(() => {
|
|
|
|
describe('Store', () => {
|
2016-11-14 17:37:13 -05:00
|
|
|
beforeEach(() => {
|
|
|
|
gl.environmentsList.EnvironmentsStore.create();
|
|
|
|
});
|
|
|
|
|
2016-10-26 13:17:00 -04:00
|
|
|
it('should start with a blank state', () => {
|
2016-10-25 10:14:08 -04:00
|
|
|
expect(gl.environmentsList.EnvironmentsStore.state.environments.length).toBe(0);
|
2016-10-26 13:17:00 -04:00
|
|
|
expect(gl.environmentsList.EnvironmentsStore.state.stoppedCounter).toBe(0);
|
2016-11-07 16:11:58 -05:00
|
|
|
expect(gl.environmentsList.EnvironmentsStore.state.availableCounter).toBe(0);
|
2016-10-25 10:14:08 -04:00
|
|
|
});
|
2016-10-26 04:17:32 -04:00
|
|
|
|
2016-10-26 13:17:00 -04:00
|
|
|
describe('store environments', () => {
|
|
|
|
beforeEach(() => {
|
2016-11-07 16:11:58 -05:00
|
|
|
gl.environmentsList.EnvironmentsStore.storeEnvironments(environmentsList);
|
2016-10-26 13:17:00 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should count stopped environments and save the count in the state', () => {
|
|
|
|
expect(gl.environmentsList.EnvironmentsStore.state.stoppedCounter).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should count available environments and save the count in the state', () => {
|
2016-11-07 16:11:58 -05:00
|
|
|
expect(gl.environmentsList.EnvironmentsStore.state.availableCounter).toBe(3);
|
2016-10-26 13:17:00 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should store environments with same environment_type as sibilings', () => {
|
2016-11-07 16:11:58 -05:00
|
|
|
expect(gl.environmentsList.EnvironmentsStore.state.environments.length).toBe(3);
|
2016-10-27 05:51:44 -04:00
|
|
|
|
2016-11-07 16:11:58 -05:00
|
|
|
const parentFolder = gl.environmentsList.EnvironmentsStore.state.environments
|
|
|
|
.filter(env => env.children && env.children.length > 0);
|
2016-10-26 13:17:00 -04:00
|
|
|
|
|
|
|
expect(parentFolder[0].children.length).toBe(2);
|
|
|
|
expect(parentFolder[0].children[0].environment_type).toBe('review');
|
|
|
|
expect(parentFolder[0].children[1].environment_type).toBe('review');
|
2016-11-07 16:11:58 -05:00
|
|
|
expect(parentFolder[0].children[0].name).toBe('test-environment');
|
|
|
|
expect(parentFolder[0].children[1].name).toBe('test-environment-1');
|
2016-10-26 13:17:00 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should sort the environments alphabetically', () => {
|
|
|
|
const { environments } = gl.environmentsList.EnvironmentsStore.state;
|
|
|
|
|
|
|
|
expect(environments[0].name).toBe('production');
|
2016-11-07 16:11:58 -05:00
|
|
|
expect(environments[1].name).toBe('review');
|
|
|
|
expect(environments[1].children[0].name).toBe('test-environment');
|
|
|
|
expect(environments[1].children[1].name).toBe('test-environment-1');
|
2016-11-09 05:55:00 -05:00
|
|
|
expect(environments[2].name).toBe('review_app');
|
2016-10-26 13:17:00 -04:00
|
|
|
});
|
|
|
|
});
|
2016-11-15 07:07:11 -05:00
|
|
|
|
|
|
|
describe('toggleFolder', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
gl.environmentsList.EnvironmentsStore.storeEnvironments(environmentsList);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should toggle the open property for the given environment', () => {
|
|
|
|
gl.environmentsList.EnvironmentsStore.toggleFolder('review');
|
|
|
|
|
|
|
|
const { environments } = gl.environmentsList.EnvironmentsStore.state;
|
|
|
|
const environment = environments.filter(env => env['vue-isChildren'] === true && env.name === 'review');
|
|
|
|
|
|
|
|
expect(environment[0].isOpen).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
2016-10-25 10:14:08 -04:00
|
|
|
});
|
|
|
|
})();
|