Commit 78136c0d authored by Nick Kipling's avatar Nick Kipling

Small adjustments as per feedback

Removed $nextTick in test
Added test for checking if versions don't exist
parent c3e32c8c
......@@ -178,11 +178,10 @@ describe('PackagesApp', () => {
it('makes api request on first click of tab', () => {
const apiMethodSpy = jest.spyOn(wrapper.vm, 'fetchPackageVersions');
versionsTab().trigger('click');
return wrapper.vm.$nextTick(() => {
expect(apiMethodSpy).toHaveBeenCalled();
});
expect(apiMethodSpy).toHaveBeenCalled();
});
});
......
......@@ -34,6 +34,25 @@ describe('Actions Package details store', () => {
);
});
it("does not set the versions if they don't exist", done => {
Api.projectPackage = jest.fn().mockResolvedValue({ data: { packageEntity, versions: null } });
testAction(
actions.fetchPackageVersions,
undefined,
{ packageEntity },
[{ type: types.SET_LOADING, payload: true }, { type: types.SET_LOADING, payload: false }],
[],
() => {
expect(Api.projectPackage).toHaveBeenCalledWith(
packageEntity.project_id,
packageEntity.id,
);
done();
},
);
});
it('should create flash on API error', done => {
Api.projectPackage = jest.fn().mockRejectedValue();
......@@ -44,6 +63,10 @@ describe('Actions Package details store', () => {
[{ type: types.SET_LOADING, payload: true }, { type: types.SET_LOADING, payload: false }],
[],
() => {
expect(Api.projectPackage).toHaveBeenCalledWith(
packageEntity.project_id,
packageEntity.id,
);
expect(createFlash).toHaveBeenCalledWith(FETCH_PACKAGE_VERSIONS_ERROR);
done();
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment