diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2018-02-09 14:14:48 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-02-09 14:14:48 +0300 |
commit | 71c948d63743c80f50cdd929728bb074d9deeace (patch) | |
tree | 65189d195e9a8c6c0a0f2f631da6e6885a46f632 /spec/javascripts/importer_status_spec.js | |
parent | d997fe135be7ec0be4aea974c556902303cf8bed (diff) |
Replace $.post in importer status with axios
Diffstat (limited to 'spec/javascripts/importer_status_spec.js')
-rw-r--r-- | spec/javascripts/importer_status_spec.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/javascripts/importer_status_spec.js b/spec/javascripts/importer_status_spec.js new file mode 100644 index 00000000000..bb49c576e91 --- /dev/null +++ b/spec/javascripts/importer_status_spec.js @@ -0,0 +1,47 @@ +import { ImporterStatus } from '~/importer_status'; +import axios from '~/lib/utils/axios_utils'; +import MockAdapter from 'axios-mock-adapter'; + +describe('Importer Status', () => { + describe('addToImport', () => { + let instance; + let mock; + const importUrl = '/import_url'; + + beforeEach(() => { + setFixtures(` + <tr id="repo_123"> + <td class="import-target"></td> + <td class="import-actions job-status"> + <button name="button" type="submit" class="btn btn-import js-add-to-import"> + </button> + </td> + </tr> + `); + spyOn(ImporterStatus.prototype, 'initStatusPage').and.callFake(() => {}); + spyOn(ImporterStatus.prototype, 'setAutoUpdate').and.callFake(() => {}); + instance = new ImporterStatus('', importUrl); + mock = new MockAdapter(axios); + }); + + afterEach(() => { + mock.restore(); + }); + + it('sets table row to active after post request', (done) => { + mock.onPost(importUrl).reply(200, { + id: 1, + full_path: '/full_path', + }); + + instance.addToImport({ + currentTarget: document.querySelector('.js-add-to-import'), + }) + .then(() => { + expect(document.querySelector('tr').classList.contains('active')).toEqual(true); + done(); + }) + .catch(done.fail); + }); + }); +}); |