Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-21 02:50:22 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-21 02:50:22 +0300
commit9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch)
tree70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/frontend/api_spec.js
parent4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff)
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/frontend/api_spec.js')
-rw-r--r--spec/frontend/api_spec.js68
1 files changed, 55 insertions, 13 deletions
diff --git a/spec/frontend/api_spec.js b/spec/frontend/api_spec.js
index d6e1b170dd3..cb29dab86bf 100644
--- a/spec/frontend/api_spec.js
+++ b/spec/frontend/api_spec.js
@@ -264,18 +264,18 @@ describe('Api', () => {
it('fetches group labels', (done) => {
const options = { params: { search: 'foo' } };
const expectedGroup = 'gitlab-org';
- const expectedUrl = `${dummyUrlRoot}/groups/${expectedGroup}/-/labels`;
+ const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/groups/${expectedGroup}/labels`;
mock.onGet(expectedUrl).reply(httpStatus.OK, [
{
id: 1,
- title: 'Foo Label',
+ name: 'Foo Label',
},
]);
Api.groupLabels(expectedGroup, options)
.then((res) => {
expect(res.length).toBe(1);
- expect(res[0].title).toBe('Foo Label');
+ expect(res[0].name).toBe('Foo Label');
})
.then(done)
.catch(done.fail);
@@ -593,7 +593,7 @@ describe('Api', () => {
});
describe('newLabel', () => {
- it('creates a new label', (done) => {
+ it('creates a new project label', (done) => {
const namespace = 'some namespace';
const project = 'some project';
const labelData = { some: 'data' };
@@ -618,26 +618,23 @@ describe('Api', () => {
});
});
- it('creates a group label', (done) => {
+ it('creates a new group label', (done) => {
const namespace = 'group/subgroup';
- const labelData = { some: 'data' };
+ const labelData = { name: 'Foo', color: '#000000' };
const expectedUrl = Api.buildUrl(Api.groupLabelsPath).replace(':namespace_path', namespace);
- const expectedData = {
- label: labelData,
- };
mock.onPost(expectedUrl).reply((config) => {
- expect(config.data).toBe(JSON.stringify(expectedData));
+ expect(config.data).toBe(JSON.stringify({ color: labelData.color }));
return [
httpStatus.OK,
{
- name: 'test',
+ ...labelData,
},
];
});
Api.newLabel(namespace, undefined, labelData, (response) => {
- expect(response.name).toBe('test');
+ expect(response.name).toBe('Foo');
done();
});
});
@@ -1225,13 +1222,26 @@ describe('Api', () => {
)}/repository/files/${encodeURIComponent(dummyFilePath)}/raw`;
describe('when the raw file is successfully fetched', () => {
- it('resolves the Promise', () => {
+ beforeEach(() => {
mock.onGet(expectedUrl).replyOnce(httpStatus.OK);
+ });
+ it('resolves the Promise', () => {
return Api.getRawFile(dummyProjectPath, dummyFilePath).then(() => {
expect(mock.history.get).toHaveLength(1);
});
});
+
+ describe('when the method is called with params', () => {
+ it('sets the params on the request', () => {
+ const params = { ref: 'main' };
+ jest.spyOn(axios, 'get');
+
+ Api.getRawFile(dummyProjectPath, dummyFilePath, params);
+
+ expect(axios.get).toHaveBeenCalledWith(expectedUrl, { params });
+ });
+ });
});
describe('when an error occurs while getting a raw file', () => {
@@ -1382,6 +1392,38 @@ describe('Api', () => {
});
});
+ describe('updateFreezePeriod', () => {
+ const options = {
+ id: 10,
+ freeze_start: '* * * * *',
+ freeze_end: '* * * * *',
+ cron_timezone: 'America/Juneau',
+ created_at: '2020-07-11T07:04:50.153Z',
+ updated_at: '2020-07-11T07:04:50.153Z',
+ };
+ const projectId = 8;
+ const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/${projectId}/freeze_periods/${options.id}`;
+
+ const expectedResult = {
+ id: 10,
+ freeze_start: '* * * * *',
+ freeze_end: '* * * * *',
+ cron_timezone: 'America/Juneau',
+ created_at: '2020-07-11T07:04:50.153Z',
+ updated_at: '2020-07-11T07:04:50.153Z',
+ };
+
+ describe('when the freeze period is successfully updated', () => {
+ it('resolves the Promise', () => {
+ mock.onPut(expectedUrl, options).replyOnce(httpStatus.OK, expectedResult);
+
+ return Api.updateFreezePeriod(projectId, options).then(({ data }) => {
+ expect(data).toStrictEqual(expectedResult);
+ });
+ });
+ });
+ });
+
describe('createPipeline', () => {
it('creates new pipeline', () => {
const redirectUrl = 'ci-project/-/pipelines/95';