Commit 1109a128 authored by Mike Greiling's avatar Mike Greiling

Merge branch 'refactor/spec-javascripts-profile-to-jest' into 'master'

Migrate spec/javascripts/profile/ to Jest

Closes #194250

See merge request gitlab-org/gitlab!26736
parents e52da1e7 911e0c1e
import Vue from 'vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import { TEST_HOST } from 'helpers/test_constants';
import mountComponent from 'helpers/vue_mount_component_helper';
import deleteAccountModal from '~/profile/account/components/delete_account_modal.vue';
describe('DeleteAccountModal component', () => {
const actionUrl = `${gl.TEST_HOST}/delete/user`;
const actionUrl = `${TEST_HOST}/delete/user`;
const username = 'hasnoname';
let Component;
let vm;
......@@ -43,7 +44,7 @@ describe('DeleteAccountModal component', () => {
it('does not accept empty password', done => {
const { form, input, submitButton } = findElements();
spyOn(form, 'submit');
jest.spyOn(form, 'submit').mockImplementation(() => {});
input.value = '';
input.dispatchEvent(new Event('input'));
......@@ -61,7 +62,7 @@ describe('DeleteAccountModal component', () => {
it('submits form with password', done => {
const { form, input, submitButton } = findElements();
spyOn(form, 'submit');
jest.spyOn(form, 'submit').mockImplementation(() => {});
input.value = 'anything';
input.dispatchEvent(new Event('input'));
......@@ -95,7 +96,7 @@ describe('DeleteAccountModal component', () => {
it('does not accept wrong username', done => {
const { form, input, submitButton } = findElements();
spyOn(form, 'submit');
jest.spyOn(form, 'submit').mockImplementation(() => {});
input.value = 'this is wrong';
input.dispatchEvent(new Event('input'));
......@@ -113,7 +114,7 @@ describe('DeleteAccountModal component', () => {
it('submits form with correct username', done => {
const { form, input, submitButton } = findElements();
spyOn(form, 'submit');
jest.spyOn(form, 'submit').mockImplementation(() => {});
input.value = username;
input.dispatchEvent(new Event('input'));
......
import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import { TEST_HOST } from 'helpers/test_constants';
import mountComponent from 'helpers/vue_mount_component_helper';
import axios from '~/lib/utils/axios_utils';
import updateUsername from '~/profile/account/components/update_username.vue';
describe('UpdateUsername component', () => {
const rootUrl = gl.TEST_HOST;
const actionUrl = `${gl.TEST_HOST}/update/username`;
const rootUrl = TEST_HOST;
const actionUrl = `${TEST_HOST}/update/username`;
const username = 'hasnoname';
const newUsername = 'new_username';
let Component;
......@@ -106,7 +107,7 @@ describe('UpdateUsername component', () => {
const { confirmModalBtn } = findElements();
axiosMock.onPut(actionUrl).replyOnce(() => [200, { message: 'Username changed' }]);
spyOn(axios, 'put').and.callThrough();
jest.spyOn(axios, 'put');
vm.newUsername = newUsername;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment