summaryrefslogtreecommitdiff
path: root/spec/frontend/gpg_badges_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
commit3cccd102ba543e02725d247893729e5c73b38295 (patch)
treef36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/frontend/gpg_badges_spec.js
parent205943281328046ef7b4528031b90fbda70c75ac (diff)
downloadgitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/frontend/gpg_badges_spec.js')
-rw-r--r--spec/frontend/gpg_badges_spec.js52
1 files changed, 18 insertions, 34 deletions
diff --git a/spec/frontend/gpg_badges_spec.js b/spec/frontend/gpg_badges_spec.js
index 44c70f1ad4d..0bb50fc3e6f 100644
--- a/spec/frontend/gpg_badges_spec.js
+++ b/spec/frontend/gpg_badges_spec.js
@@ -40,30 +40,22 @@ describe('GpgBadges', () => {
mock.restore();
});
- it('does not make a request if there is no container element', (done) => {
+ it('does not make a request if there is no container element', async () => {
setFixtures('');
jest.spyOn(axios, 'get').mockImplementation(() => {});
- GpgBadges.fetch()
- .then(() => {
- expect(axios.get).not.toHaveBeenCalled();
- })
- .then(done)
- .catch(done.fail);
+ await GpgBadges.fetch();
+ expect(axios.get).not.toHaveBeenCalled();
});
- it('throws an error if the endpoint is missing', (done) => {
+ it('throws an error if the endpoint is missing', async () => {
setFixtures('<div class="js-signature-container"></div>');
jest.spyOn(axios, 'get').mockImplementation(() => {});
- GpgBadges.fetch()
- .then(() => done.fail('Expected error to be thrown'))
- .catch((error) => {
- expect(error.message).toBe('Missing commit signatures endpoint!');
- expect(axios.get).not.toHaveBeenCalled();
- })
- .then(done)
- .catch(done.fail);
+ await expect(GpgBadges.fetch()).rejects.toEqual(
+ new Error('Missing commit signatures endpoint!'),
+ );
+ expect(axios.get).not.toHaveBeenCalled();
});
it('fetches commit signatures', async () => {
@@ -104,31 +96,23 @@ describe('GpgBadges', () => {
});
});
- it('displays a loading spinner', (done) => {
+ it('displays a loading spinner', async () => {
mock.onGet(dummyUrl).replyOnce(200);
- GpgBadges.fetch()
- .then(() => {
- expect(document.querySelector('.js-loading-gpg-badge:empty')).toBe(null);
- const spinners = document.querySelectorAll('.js-loading-gpg-badge span.gl-spinner');
+ await GpgBadges.fetch();
+ expect(document.querySelector('.js-loading-gpg-badge:empty')).toBe(null);
+ const spinners = document.querySelectorAll('.js-loading-gpg-badge span.gl-spinner');
- expect(spinners.length).toBe(1);
- done();
- })
- .catch(done.fail);
+ expect(spinners.length).toBe(1);
});
- it('replaces the loading spinner', (done) => {
+ it('replaces the loading spinner', async () => {
mock.onGet(dummyUrl).replyOnce(200, dummyResponse);
- GpgBadges.fetch()
- .then(() => {
- expect(document.querySelector('.js-loading-gpg-badge')).toBe(null);
- const parentContainer = document.querySelector('.parent-container');
+ await GpgBadges.fetch();
+ expect(document.querySelector('.js-loading-gpg-badge')).toBe(null);
+ const parentContainer = document.querySelector('.parent-container');
- expect(parentContainer.innerHTML.trim()).toEqual(dummyBadgeHtml);
- done();
- })
- .catch(done.fail);
+ expect(parentContainer.innerHTML.trim()).toEqual(dummyBadgeHtml);
});
});