Skip to content

Commit

Permalink
fix: remove old tests
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksii Orel <oorel@redhat.com>
  • Loading branch information
olexii4 committed Aug 16, 2022
1 parent f83cf4a commit df24158
Showing 1 changed file with 0 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,41 +72,6 @@ const getFactoryResolverSpy = jest.spyOn(cheWorkspaceClient.restApiClient, 'getF

describe('FactoryResolver store', () => {
describe('requestFactoryResolver action', () => {
it('should NOT convert resolved devfile v1 with devworkspace mode DISABLED', async () => {
const resolver = {
devfile: {
apiVersion: '1.0.0',
} as che.WorkspaceDevfile,
} as factoryResolverStore.ResolverState;

getFactoryResolverSpy.mockResolvedValueOnce(resolver);

const store = new FakeStoreBuilder()
.withWorkspacesSettings({
'che.devworkspaces.enabled': 'false',
'che.workspace.storage.preferred_type': 'ephemeral',
})
.build() as MockStoreEnhanced<
AppState,
ThunkDispatch<AppState, undefined, factoryResolverStore.KnownAction>
>;

const location = 'http://factory-link';
await store.dispatch(factoryResolverStore.actionCreators.requestFactoryResolver(location));

const actions = store.getActions();
expect(actions).toEqual(
expect.arrayContaining([
expect.objectContaining({
type: 'RECEIVE_FACTORY_RESOLVER',
converted: expect.objectContaining({
isConverted: false,
}),
}),
]),
);
});

it('should convert resolved devfile v1 with devworkspace mode ENABLED', async () => {
const resolver = {
devfile: {
Expand Down Expand Up @@ -176,80 +141,9 @@ describe('FactoryResolver store', () => {
]),
);
});

it('should convert resolved devfile v2.x.x with devworkspace mode DISABLED', async () => {
const resolver = {
devfile: {
schemaVersion: '2.0.0',
} as devfileApi.Devfile,
} as factoryResolverStore.ResolverState;

getFactoryResolverSpy.mockResolvedValueOnce(resolver);

const store = new FakeStoreBuilder()
.withWorkspacesSettings({
'che.devworkspaces.enabled': 'false',
'che.workspace.storage.preferred_type': 'ephemeral',
})
.build() as MockStoreEnhanced<
AppState,
ThunkDispatch<AppState, undefined, factoryResolverStore.KnownAction>
>;

const location = 'http://factory-link';
await store.dispatch(factoryResolverStore.actionCreators.requestFactoryResolver(location));

const actions = store.getActions();
expect(actions).toEqual(
expect.arrayContaining([
expect.objectContaining({
type: 'RECEIVE_FACTORY_RESOLVER',
converted: expect.objectContaining({
isConverted: true,
}),
}),
]),
);
});
});

describe('actions', () => {
it('should create REQUEST_FACTORY_RESOLVER and RECEIVE_FACTORY_RESOLVER', async () => {
const resolver = {
devfile: {
schemaVersion: '2.0.0',
},
} as factoryResolverStore.ResolverState;

getFactoryResolverSpy.mockResolvedValueOnce(resolver);

const store = new FakeStoreBuilder()
.withWorkspacesSettings({
'che.devworkspaces.enabled': 'false',
'che.workspace.storage.preferred_type': 'ephemeral',
})
.build() as MockStoreEnhanced<
AppState,
ThunkDispatch<AppState, undefined, factoryResolverStore.KnownAction>
>;

const location = 'http://factory-link';
await store.dispatch(factoryResolverStore.actionCreators.requestFactoryResolver(location));

const actions = store.getActions();
const expectedActions: factoryResolverStore.KnownAction[] = [
{
type: 'REQUEST_FACTORY_RESOLVER',
},
{
type: 'RECEIVE_FACTORY_RESOLVER',
resolver: expect.objectContaining(resolver),
converted: expect.objectContaining({ isConverted: true }),
},
];
expect(actions).toEqual(expectedActions);
});

it('should create REQUEST_FACTORY_RESOLVER and RECEIVE_FACTORY_RESOLVER_ERROR', async () => {
getFactoryResolverSpy.mockRejectedValueOnce({
isAxiosError: true,
Expand Down

0 comments on commit df24158

Please sign in to comment.