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,13 +178,12 @@ describe('PackagesApp', () => { ...@@ -178,13 +178,12 @@ describe('PackagesApp', () => {
it('makes api request on first click of tab', () => { it('makes api request on first click of tab', () => {
const apiMethodSpy = jest.spyOn(wrapper.vm, 'fetchPackageVersions'); const apiMethodSpy = jest.spyOn(wrapper.vm, 'fetchPackageVersions');
versionsTab().trigger('click'); versionsTab().trigger('click');
return wrapper.vm.$nextTick(() => {
expect(apiMethodSpy).toHaveBeenCalled(); expect(apiMethodSpy).toHaveBeenCalled();
}); });
}); });
});
it('displays the loader when state is loading', () => { it('displays the loader when state is loading', () => {
createComponent({ isLoading: true }); createComponent({ isLoading: true });
......
...@@ -34,6 +34,25 @@ describe('Actions Package details store', () => { ...@@ -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 => { it('should create flash on API error', done => {
Api.projectPackage = jest.fn().mockRejectedValue(); Api.projectPackage = jest.fn().mockRejectedValue();
...@@ -44,6 +63,10 @@ describe('Actions Package details store', () => { ...@@ -44,6 +63,10 @@ describe('Actions Package details store', () => {
[{ type: types.SET_LOADING, payload: true }, { type: types.SET_LOADING, payload: false }], [{ 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); expect(createFlash).toHaveBeenCalledWith(FETCH_PACKAGE_VERSIONS_ERROR);
done(); 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