blob: b97918a198e6df57fe542c3526e2a8a179cc0bea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import { initJiraConnect } from '~/jira_connect/subscriptions';
import { getGitlabSignInURL } from '~/jira_connect/subscriptions/utils';
jest.mock('~/jira_connect/subscriptions/utils');
describe('initJiraConnect', () => {
const mockInitialHref = 'https://gitlab.com';
beforeEach(() => {
setFixtures(`
<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>
`);
});
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('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);
});
});
});
|