diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /spec/frontend/releases/util_spec.js | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/frontend/releases/util_spec.js')
-rw-r--r-- | spec/frontend/releases/util_spec.js | 68 |
1 files changed, 44 insertions, 24 deletions
diff --git a/spec/frontend/releases/util_spec.js b/spec/frontend/releases/util_spec.js index f40e5729188..e7b7766c0d0 100644 --- a/spec/frontend/releases/util_spec.js +++ b/spec/frontend/releases/util_spec.js @@ -1,6 +1,19 @@ import { cloneDeep } from 'lodash'; -import { releaseToApiJson, apiJsonToRelease, convertGraphQLResponse } from '~/releases/util'; -import { graphqlReleasesResponse as originalGraphqlReleasesResponse } from './mock_data'; +import { getJSONFixture } from 'helpers/fixtures'; +import { + releaseToApiJson, + apiJsonToRelease, + convertGraphQLRelease, + convertAllReleasesGraphQLResponse, + convertOneReleaseGraphQLResponse, +} from '~/releases/util'; + +const originalAllReleasesQueryResponse = getJSONFixture( + 'graphql/releases/queries/all_releases.query.graphql.json', +); +const originalOneReleaseQueryResponse = getJSONFixture( + 'graphql/releases/queries/one_release.query.graphql.json', +); describe('releases/util.js', () => { describe('releaseToApiJson', () => { @@ -103,54 +116,61 @@ describe('releases/util.js', () => { }); }); - describe('convertGraphQLResponse', () => { - let graphqlReleasesResponse; - let converted; + describe('convertGraphQLRelease', () => { + let releaseFromResponse; + let convertedRelease; beforeEach(() => { - graphqlReleasesResponse = cloneDeep(originalGraphqlReleasesResponse); - converted = convertGraphQLResponse(graphqlReleasesResponse); - }); - - it('matches snapshot', () => { - expect(converted).toMatchSnapshot(); + releaseFromResponse = cloneDeep(originalOneReleaseQueryResponse).data.project.release; + convertedRelease = convertGraphQLRelease(releaseFromResponse); }); describe('assets', () => { it("handles asset links that don't have a linkType", () => { - expect(converted.data[0].assets.links[0].linkType).not.toBeUndefined(); + expect(convertedRelease.assets.links[0].linkType).not.toBeUndefined(); - delete graphqlReleasesResponse.data.project.releases.nodes[0].assets.links.nodes[0] - .linkType; + delete releaseFromResponse.assets.links.nodes[0].linkType; - converted = convertGraphQLResponse(graphqlReleasesResponse); + convertedRelease = convertGraphQLRelease(releaseFromResponse); - expect(converted.data[0].assets.links[0].linkType).toBeUndefined(); + expect(convertedRelease.assets.links[0].linkType).toBeUndefined(); }); }); describe('_links', () => { it("handles releases that don't have any links", () => { - expect(converted.data[0]._links.selfUrl).not.toBeUndefined(); + expect(convertedRelease._links.selfUrl).not.toBeUndefined(); - delete graphqlReleasesResponse.data.project.releases.nodes[0].links; + delete releaseFromResponse.links; - converted = convertGraphQLResponse(graphqlReleasesResponse); + convertedRelease = convertGraphQLRelease(releaseFromResponse); - expect(converted.data[0]._links.selfUrl).toBeUndefined(); + expect(convertedRelease._links.selfUrl).toBeUndefined(); }); }); describe('commit', () => { it("handles releases that don't have any commit info", () => { - expect(converted.data[0].commit).not.toBeUndefined(); + expect(convertedRelease.commit).not.toBeUndefined(); - delete graphqlReleasesResponse.data.project.releases.nodes[0].commit; + delete releaseFromResponse.commit; - converted = convertGraphQLResponse(graphqlReleasesResponse); + convertedRelease = convertGraphQLRelease(releaseFromResponse); - expect(converted.data[0].commit).toBeUndefined(); + expect(convertedRelease.commit).toBeUndefined(); }); }); }); + + describe('convertAllReleasesGraphQLResponse', () => { + it('matches snapshot', () => { + expect(convertAllReleasesGraphQLResponse(originalAllReleasesQueryResponse)).toMatchSnapshot(); + }); + }); + + describe('convertOneReleaseGraphQLResponse', () => { + it('matches snapshot', () => { + expect(convertOneReleaseGraphQLResponse(originalOneReleaseQueryResponse)).toMatchSnapshot(); + }); + }); }); |