Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add coverage for undef config case #761

Merged
merged 4 commits into from
Oct 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const scEnvironment = {
rev: 2,
status: 'active',
description: 'sample description',
envTypeConfigId: 'env type config id',
envTypeConfigId: 'existingConfigId',
name: 'name',
projectId: 'project id',
envTypeId: 'env type id',
Expand All @@ -51,10 +51,15 @@ const scEnvironment = {
outputs: [],
};

const scEnvConfig = {
name: 'name',
instanceType: 'instanceType',
};

const envTypesStore = {
getEnvTypeConfigsStore: jest.fn(() => envTypesStore),
load: jest.fn(),
getEnvTypeConfig: jest.fn(),
getEnvTypeConfig: jest.fn(envTypeConfigId => (envTypeConfigId === 'existingConfigId' ? scEnvConfig : undefined)),
};

describe('ScEnvironmentCard', () => {
Expand Down Expand Up @@ -86,10 +91,26 @@ describe('ScEnvironmentCard', () => {
const spyOnConfigsStore = jest.spyOn(component, 'getEnvTypeConfigsStore');

// OPERATE
component.getConfiguration(scEnvironment.envTypeConfigId);
const config = component.getConfiguration(scEnvironment.envTypeConfigId);

// CHECK
expect(spyOnConfigsStore).toHaveBeenCalled();
expect(envTypesStore.getEnvTypeConfig).toHaveBeenCalledWith(scEnvironment.envTypeConfigId);
expect(config.name).toBeDefined();
expect(config.instanceType).toBeDefined();
expect(config).toEqual(scEnvConfig);
});

it('should get undefined configuration', async () => {
// BUILD
const spyOnConfigsStore = jest.spyOn(component, 'getEnvTypeConfigsStore');

// OPERATE
const config = component.getConfiguration('deletedConfigId');

// CHECK
expect(spyOnConfigsStore).toHaveBeenCalled();
expect(envTypesStore.getEnvTypeConfig).toHaveBeenCalledWith('deletedConfigId');
expect(config).toBeUndefined();
});
});