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:
Diffstat (limited to 'spec/frontend/api/groups_api_spec.js')
-rw-r--r--spec/frontend/api/groups_api_spec.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/frontend/api/groups_api_spec.js b/spec/frontend/api/groups_api_spec.js
new file mode 100644
index 00000000000..e14ead0b8eb
--- /dev/null
+++ b/spec/frontend/api/groups_api_spec.js
@@ -0,0 +1,46 @@
+import MockAdapter from 'axios-mock-adapter';
+import httpStatus from '~/lib/utils/http_status';
+import axios from '~/lib/utils/axios_utils';
+import { updateGroup } from '~/api/groups_api';
+
+const mockApiVersion = 'v4';
+const mockUrlRoot = '/gitlab';
+
+describe('GroupsApi', () => {
+ let originalGon;
+ let mock;
+
+ const dummyGon = {
+ api_version: mockApiVersion,
+ relative_url_root: mockUrlRoot,
+ };
+
+ beforeEach(() => {
+ mock = new MockAdapter(axios);
+ originalGon = window.gon;
+ window.gon = { ...dummyGon };
+ });
+
+ afterEach(() => {
+ mock.restore();
+ window.gon = originalGon;
+ });
+
+ describe('updateGroup', () => {
+ const mockGroupId = '99';
+ const mockData = { attr: 'value' };
+ const expectedUrl = `${mockUrlRoot}/api/${mockApiVersion}/groups/${mockGroupId}`;
+
+ beforeEach(() => {
+ mock.onPut(expectedUrl).reply(({ data }) => {
+ return [httpStatus.OK, { id: mockGroupId, ...JSON.parse(data) }];
+ });
+ });
+
+ it('updates group', async () => {
+ const res = await updateGroup(mockGroupId, mockData);
+
+ expect(res.data).toMatchObject({ id: mockGroupId, ...mockData });
+ });
+ });
+});