diff options
Diffstat (limited to 'spec/frontend/admin')
4 files changed, 72 insertions, 2 deletions
diff --git a/spec/frontend/admin/applications/components/delete_application_spec.js b/spec/frontend/admin/applications/components/delete_application_spec.js index 20119b64952..1a400a101b5 100644 --- a/spec/frontend/admin/applications/components/delete_application_spec.js +++ b/spec/frontend/admin/applications/components/delete_application_spec.js @@ -1,5 +1,6 @@ import { GlModal, GlSprintf } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; +import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; import DeleteApplication from '~/admin/applications/components/delete_application.vue'; const path = 'application/path/1'; @@ -22,7 +23,7 @@ describe('DeleteApplication', () => { const findForm = () => wrapper.find('form'); beforeEach(() => { - setFixtures(` + setHTMLFixture(` <button class="js-application-delete-button" data-path="${path}" data-name="${name}">Destroy</button> `); @@ -31,6 +32,7 @@ describe('DeleteApplication', () => { afterEach(() => { wrapper.destroy(); + resetHTMLFixture(); }); describe('the modal component', () => { diff --git a/spec/frontend/admin/background_migrations/components/database_listbox_spec.js b/spec/frontend/admin/background_migrations/components/database_listbox_spec.js new file mode 100644 index 00000000000..3778943872e --- /dev/null +++ b/spec/frontend/admin/background_migrations/components/database_listbox_spec.js @@ -0,0 +1,57 @@ +import { GlListbox } from '@gitlab/ui'; +import { shallowMount } from '@vue/test-utils'; +import BackgroundMigrationsDatabaseListbox from '~/admin/background_migrations/components/database_listbox.vue'; +import { visitUrl, setUrlParams } from '~/lib/utils/url_utility'; +import { MOCK_DATABASES, MOCK_SELECTED_DATABASE } from '../mock_data'; + +jest.mock('~/lib/utils/url_utility', () => ({ + visitUrl: jest.fn(), + setUrlParams: jest.fn(), +})); + +describe('BackgroundMigrationsDatabaseListbox', () => { + let wrapper; + + const defaultProps = { + databases: MOCK_DATABASES, + selectedDatabase: MOCK_SELECTED_DATABASE, + }; + + const createComponent = (props = {}) => { + wrapper = shallowMount(BackgroundMigrationsDatabaseListbox, { + propsData: { + ...defaultProps, + ...props, + }, + }); + }; + + afterEach(() => { + wrapper.destroy(); + }); + + const findGlListbox = () => wrapper.findComponent(GlListbox); + + describe('template always', () => { + beforeEach(() => { + createComponent(); + }); + + it('renders GlListbox', () => { + expect(findGlListbox().exists()).toBe(true); + }); + }); + + describe('actions', () => { + beforeEach(() => { + createComponent(); + }); + + it('selecting a listbox item fires visitUrl with the database param', () => { + findGlListbox().vm.$emit('select', MOCK_DATABASES[1].value); + + expect(setUrlParams).toHaveBeenCalledWith({ database: MOCK_DATABASES[1].value }); + expect(visitUrl).toHaveBeenCalled(); + }); + }); +}); diff --git a/spec/frontend/admin/background_migrations/mock_data.js b/spec/frontend/admin/background_migrations/mock_data.js new file mode 100644 index 00000000000..fbb1718f6b8 --- /dev/null +++ b/spec/frontend/admin/background_migrations/mock_data.js @@ -0,0 +1,6 @@ +export const MOCK_DATABASES = [ + { value: 'main', text: 'main' }, + { value: 'ci', text: 'ci' }, +]; + +export const MOCK_SELECTED_DATABASE = 'main'; diff --git a/spec/frontend/admin/users/new_spec.js b/spec/frontend/admin/users/new_spec.js index 692c583dca8..5e5763822a8 100644 --- a/spec/frontend/admin/users/new_spec.js +++ b/spec/frontend/admin/users/new_spec.js @@ -4,6 +4,7 @@ import { ID_USER_EXTERNAL, ID_WARNING, } from '~/admin/users/new'; +import { loadHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; describe('admin/users/new', () => { const FIXTURE = 'admin/users/new_with_internal_user_regex.html'; @@ -13,7 +14,7 @@ describe('admin/users/new', () => { let elWarningMessage; beforeEach(() => { - loadFixtures(FIXTURE); + loadHTMLFixture(FIXTURE); setupInternalUserRegexHandler(); elExternal = document.getElementById(ID_USER_EXTERNAL); @@ -23,6 +24,10 @@ describe('admin/users/new', () => { elExternal.checked = true; }); + afterEach(() => { + resetHTMLFixture(); + }); + const changeEmail = (val) => { elUserEmail.value = val; elUserEmail.dispatchEvent(new Event('input')); |