diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-18 00:10:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-18 00:10:25 +0300 |
commit | 104faef9725d678d5e4456108a5ee9c7a50a1281 (patch) | |
tree | 969ea4632b9afea52e1a6becc02d8e7bc52f9f7e /spec/frontend | |
parent | 6f79cf2bd654a018387313de70b9dd45a373ce72 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/gpg_badges_spec.js | 50 | ||||
-rw-r--r-- | spec/frontend/lib/utils/common_utils_spec.js | 12 |
2 files changed, 46 insertions, 16 deletions
diff --git a/spec/frontend/gpg_badges_spec.js b/spec/frontend/gpg_badges_spec.js index cd2cc88fa5a..44c70f1ad4d 100644 --- a/spec/frontend/gpg_badges_spec.js +++ b/spec/frontend/gpg_badges_spec.js @@ -17,19 +17,23 @@ describe('GpgBadges', () => { }; const dummyUrl = `${TEST_HOST}/dummy/signatures`; - beforeEach(() => { - mock = new MockAdapter(axios); + const setForm = ({ utf8 = '✓', search = '' } = {}) => { setFixtures(` <form class="commits-search-form js-signature-container" data-signatures-path="${dummyUrl}" action="${dummyUrl}" method="get"> - <input name="utf8" type="hidden" value="✓"> - <input type="search" name="search" id="commits-search"class="form-control search-text-input input-short"> + <input name="utf8" type="hidden" value="${utf8}"> + <input type="search" name="search" value="${search}" id="commits-search"class="form-control search-text-input input-short"> </form> <div class="parent-container"> <div class="js-loading-gpg-badge" data-commit-sha="${dummyCommitSha}"></div> </div> `); + }; + + beforeEach(() => { + mock = new MockAdapter(axios); + setForm(); }); afterEach(() => { @@ -62,6 +66,44 @@ describe('GpgBadges', () => { .catch(done.fail); }); + it('fetches commit signatures', async () => { + mock.onGet(dummyUrl).replyOnce(200); + + await GpgBadges.fetch(); + + expect(mock.history.get).toHaveLength(1); + expect(mock.history.get[0]).toMatchObject({ + params: { search: '', utf8: '✓' }, + url: dummyUrl, + }); + }); + + it('fetches commit signatures with search parameters with spaces', async () => { + mock.onGet(dummyUrl).replyOnce(200); + setForm({ search: 'my search' }); + + await GpgBadges.fetch(); + + expect(mock.history.get).toHaveLength(1); + expect(mock.history.get[0]).toMatchObject({ + params: { search: 'my search', utf8: '✓' }, + url: dummyUrl, + }); + }); + + it('fetches commit signatures with search parameters with plus symbols', async () => { + mock.onGet(dummyUrl).replyOnce(200); + setForm({ search: 'my+search' }); + + await GpgBadges.fetch(); + + expect(mock.history.get).toHaveLength(1); + expect(mock.history.get[0]).toMatchObject({ + params: { search: 'my+search', utf8: '✓' }, + url: dummyUrl, + }); + }); + it('displays a loading spinner', (done) => { mock.onGet(dummyUrl).replyOnce(200); diff --git a/spec/frontend/lib/utils/common_utils_spec.js b/spec/frontend/lib/utils/common_utils_spec.js index e03d1ef7295..554c4c4656a 100644 --- a/spec/frontend/lib/utils/common_utils_spec.js +++ b/spec/frontend/lib/utils/common_utils_spec.js @@ -175,18 +175,6 @@ describe('common_utils', () => { }); }); - describe('parseQueryStringIntoObject', () => { - it('should return object with query parameters', () => { - expect(commonUtils.parseQueryStringIntoObject('scope=all&page=2')).toEqual({ - scope: 'all', - page: '2', - }); - - expect(commonUtils.parseQueryStringIntoObject('scope=all')).toEqual({ scope: 'all' }); - expect(commonUtils.parseQueryStringIntoObject()).toEqual({}); - }); - }); - describe('objectToQueryString', () => { it('returns empty string when `param` is undefined, null or empty string', () => { expect(commonUtils.objectToQueryString()).toBe(''); |