2020-09-15 11:10:08 -04:00
|
|
|
import { cloneDeep } from 'lodash';
|
2021-10-07 14:11:28 -04:00
|
|
|
import originalAllReleasesQueryResponse from 'test_fixtures/graphql/releases/graphql/queries/all_releases.query.graphql.json';
|
|
|
|
import originalOneReleaseQueryResponse from 'test_fixtures/graphql/releases/graphql/queries/one_release.query.graphql.json';
|
|
|
|
import originalOneReleaseForEditingQueryResponse from 'test_fixtures/graphql/releases/graphql/queries/one_release_for_editing.query.graphql.json';
|
2020-10-15 05:08:41 -04:00
|
|
|
import {
|
|
|
|
convertGraphQLRelease,
|
|
|
|
convertAllReleasesGraphQLResponse,
|
|
|
|
convertOneReleaseGraphQLResponse,
|
|
|
|
} from '~/releases/util';
|
|
|
|
|
2020-08-10 11:09:49 -04:00
|
|
|
describe('releases/util.js', () => {
|
2020-10-15 05:08:41 -04:00
|
|
|
describe('convertGraphQLRelease', () => {
|
|
|
|
let releaseFromResponse;
|
|
|
|
let convertedRelease;
|
2020-09-15 11:10:08 -04:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2020-10-15 05:08:41 -04:00
|
|
|
releaseFromResponse = cloneDeep(originalOneReleaseQueryResponse).data.project.release;
|
|
|
|
convertedRelease = convertGraphQLRelease(releaseFromResponse);
|
2020-09-15 11:10:08 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('assets', () => {
|
|
|
|
it("handles asset links that don't have a linkType", () => {
|
2020-10-15 05:08:41 -04:00
|
|
|
expect(convertedRelease.assets.links[0].linkType).not.toBeUndefined();
|
2020-09-15 11:10:08 -04:00
|
|
|
|
2020-10-15 05:08:41 -04:00
|
|
|
delete releaseFromResponse.assets.links.nodes[0].linkType;
|
2020-09-15 11:10:08 -04:00
|
|
|
|
2020-10-15 05:08:41 -04:00
|
|
|
convertedRelease = convertGraphQLRelease(releaseFromResponse);
|
2020-09-15 11:10:08 -04:00
|
|
|
|
2020-10-15 05:08:41 -04:00
|
|
|
expect(convertedRelease.assets.links[0].linkType).toBeUndefined();
|
2020-09-15 11:10:08 -04:00
|
|
|
});
|
2021-04-26 14:09:45 -04:00
|
|
|
|
|
|
|
it('handles assets that have no links', () => {
|
|
|
|
expect(convertedRelease.assets.links[0]).not.toBeUndefined();
|
|
|
|
|
|
|
|
delete releaseFromResponse.assets.links;
|
|
|
|
|
|
|
|
convertedRelease = convertGraphQLRelease(releaseFromResponse);
|
|
|
|
|
|
|
|
expect(convertedRelease.assets.links).toEqual([]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('handles assets that have no sources', () => {
|
|
|
|
expect(convertedRelease.assets.sources[0]).not.toBeUndefined();
|
|
|
|
|
|
|
|
delete releaseFromResponse.assets.sources;
|
|
|
|
|
|
|
|
convertedRelease = convertGraphQLRelease(releaseFromResponse);
|
|
|
|
|
|
|
|
expect(convertedRelease.assets.sources).toEqual([]);
|
|
|
|
});
|
2020-09-15 11:10:08 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('_links', () => {
|
|
|
|
it("handles releases that don't have any links", () => {
|
2020-10-15 05:08:41 -04:00
|
|
|
expect(convertedRelease._links.selfUrl).not.toBeUndefined();
|
2020-09-15 11:10:08 -04:00
|
|
|
|
2020-10-15 05:08:41 -04:00
|
|
|
delete releaseFromResponse.links;
|
2020-09-15 11:10:08 -04:00
|
|
|
|
2020-10-15 05:08:41 -04:00
|
|
|
convertedRelease = convertGraphQLRelease(releaseFromResponse);
|
2020-09-15 11:10:08 -04:00
|
|
|
|
2020-10-15 05:08:41 -04:00
|
|
|
expect(convertedRelease._links.selfUrl).toBeUndefined();
|
2020-09-15 11:10:08 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('commit', () => {
|
|
|
|
it("handles releases that don't have any commit info", () => {
|
2020-10-15 05:08:41 -04:00
|
|
|
expect(convertedRelease.commit).not.toBeUndefined();
|
2020-09-15 11:10:08 -04:00
|
|
|
|
2020-10-15 05:08:41 -04:00
|
|
|
delete releaseFromResponse.commit;
|
2020-09-15 11:10:08 -04:00
|
|
|
|
2020-10-15 05:08:41 -04:00
|
|
|
convertedRelease = convertGraphQLRelease(releaseFromResponse);
|
2020-09-15 11:10:08 -04:00
|
|
|
|
2020-10-15 05:08:41 -04:00
|
|
|
expect(convertedRelease.commit).toBeUndefined();
|
2020-09-15 11:10:08 -04:00
|
|
|
});
|
|
|
|
});
|
2021-04-26 14:09:45 -04:00
|
|
|
|
|
|
|
describe('milestones', () => {
|
|
|
|
it("handles releases that don't have any milestone stats", () => {
|
|
|
|
expect(convertedRelease.milestones[0].issueStats).not.toBeUndefined();
|
|
|
|
|
|
|
|
releaseFromResponse.milestones.nodes = releaseFromResponse.milestones.nodes.map((n) => ({
|
|
|
|
...n,
|
|
|
|
stats: undefined,
|
|
|
|
}));
|
|
|
|
|
|
|
|
convertedRelease = convertGraphQLRelease(releaseFromResponse);
|
|
|
|
|
|
|
|
expect(convertedRelease.milestones[0].issueStats).toEqual({});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('evidences', () => {
|
|
|
|
it("handles releases that don't have any evidences", () => {
|
|
|
|
expect(convertedRelease.evidences).not.toBeUndefined();
|
|
|
|
|
|
|
|
delete releaseFromResponse.evidences;
|
|
|
|
|
|
|
|
convertedRelease = convertGraphQLRelease(releaseFromResponse);
|
|
|
|
|
|
|
|
expect(convertedRelease.evidences).toEqual([]);
|
|
|
|
});
|
|
|
|
});
|
2020-09-15 11:10:08 -04:00
|
|
|
});
|
2020-10-15 05:08:41 -04:00
|
|
|
|
|
|
|
describe('convertAllReleasesGraphQLResponse', () => {
|
|
|
|
it('matches snapshot', () => {
|
2021-11-30 10:14:19 -05:00
|
|
|
expect(convertAllReleasesGraphQLResponse(originalAllReleasesQueryResponse)).toMatchSnapshot({
|
|
|
|
data: [
|
|
|
|
{
|
|
|
|
author: {
|
|
|
|
id: expect.any(String),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
author: {
|
|
|
|
id: expect.any(String),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
2020-10-15 05:08:41 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('convertOneReleaseGraphQLResponse', () => {
|
|
|
|
it('matches snapshot', () => {
|
2021-11-30 10:14:19 -05:00
|
|
|
expect(convertOneReleaseGraphQLResponse(originalOneReleaseQueryResponse)).toMatchSnapshot({
|
|
|
|
data: {
|
|
|
|
author: {
|
|
|
|
id: expect.any(String),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2020-10-15 05:08:41 -04:00
|
|
|
});
|
|
|
|
});
|
2021-04-26 14:09:45 -04:00
|
|
|
|
|
|
|
describe('convertOneReleaseForEditingGraphQLResponse', () => {
|
|
|
|
it('matches snapshot', () => {
|
|
|
|
expect(
|
|
|
|
convertOneReleaseGraphQLResponse(originalOneReleaseForEditingQueryResponse),
|
|
|
|
).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2020-08-10 11:09:49 -04:00
|
|
|
});
|