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/jira_connect/subscriptions/index_spec.js')
-rw-r--r--spec/frontend/jira_connect/subscriptions/index_spec.js36
1 files changed, 24 insertions, 12 deletions
diff --git a/spec/frontend/jira_connect/subscriptions/index_spec.js b/spec/frontend/jira_connect/subscriptions/index_spec.js
index 786f3b4a7d3..b97918a198e 100644
--- a/spec/frontend/jira_connect/subscriptions/index_spec.js
+++ b/spec/frontend/jira_connect/subscriptions/index_spec.js
@@ -1,24 +1,36 @@
import { initJiraConnect } from '~/jira_connect/subscriptions';
+import { getGitlabSignInURL } from '~/jira_connect/subscriptions/utils';
-jest.mock('~/jira_connect/subscriptions/utils', () => ({
- getLocation: jest.fn().mockResolvedValue('test/location'),
-}));
+jest.mock('~/jira_connect/subscriptions/utils');
describe('initJiraConnect', () => {
- beforeEach(async () => {
+ const mockInitialHref = 'https://gitlab.com';
+
+ beforeEach(() => {
setFixtures(`
- <a class="js-jira-connect-sign-in" href="https://gitlab.com">Sign In</a>
- <a class="js-jira-connect-sign-in" href="https://gitlab.com">Another Sign In</a>
+ <a class="js-jira-connect-sign-in" href="${mockInitialHref}">Sign In</a>
+ <a class="js-jira-connect-sign-in" href="${mockInitialHref}">Another Sign In</a>
`);
-
- await initJiraConnect();
});
+ const assertSignInLinks = (expectedLink) => {
+ Array.from(document.querySelectorAll('.js-jira-connect-sign-in')).forEach((el) => {
+ expect(el.getAttribute('href')).toBe(expectedLink);
+ });
+ };
+
describe('Sign in links', () => {
- it('have `return_to` query parameter', () => {
- Array.from(document.querySelectorAll('.js-jira-connect-sign-in')).forEach((el) => {
- expect(el.href).toContain('return_to=test/location');
- });
+ it('are updated on initialization', async () => {
+ const mockSignInLink = `https://gitlab.com?return_to=${encodeURIComponent('/test/location')}`;
+ getGitlabSignInURL.mockResolvedValue(mockSignInLink);
+
+ // assert the initial state
+ assertSignInLinks(mockInitialHref);
+
+ await initJiraConnect();
+
+ // assert the update has occurred
+ assertSignInLinks(mockSignInLink);
});
});
});