debian-mirror-gitlab/spec/frontend/admin/users/index_spec.js

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-02-22 17:27:13 +05:30
import { createWrapper } from '@vue/test-utils';
2021-09-30 23:02:18 +05:30
import { initAdminUsersApp, initAdminUserActions } from '~/admin/users';
2021-02-22 17:27:13 +05:30
import AdminUsersApp from '~/admin/users/components/app.vue';
2021-09-30 23:02:18 +05:30
import UserActions from '~/admin/users/components/user_actions.vue';
import { users, user, paths } from './mock_data';
2021-02-22 17:27:13 +05:30
describe('initAdminUsersApp', () => {
let wrapper;
let el;
2022-08-27 11:52:29 +05:30
const findApp = () => wrapper.findComponent(AdminUsersApp);
2021-02-22 17:27:13 +05:30
beforeEach(() => {
el = document.createElement('div');
2022-07-23 23:45:48 +05:30
el.dataset.users = JSON.stringify(users);
el.dataset.paths = JSON.stringify(paths);
2021-02-22 17:27:13 +05:30
2021-03-11 19:13:27 +05:30
wrapper = createWrapper(initAdminUsersApp(el));
2021-02-22 17:27:13 +05:30
});
afterEach(() => {
el = null;
});
it('parses and passes props', () => {
expect(findApp().props()).toMatchObject({
users,
paths,
});
});
});
2021-09-30 23:02:18 +05:30
describe('initAdminUserActions', () => {
let wrapper;
let el;
2022-08-27 11:52:29 +05:30
const findUserActions = () => wrapper.findComponent(UserActions);
2021-09-30 23:02:18 +05:30
beforeEach(() => {
el = document.createElement('div');
2022-07-23 23:45:48 +05:30
el.dataset.user = JSON.stringify(user);
el.dataset.paths = JSON.stringify(paths);
2021-09-30 23:02:18 +05:30
wrapper = createWrapper(initAdminUserActions(el));
});
afterEach(() => {
el = null;
});
it('parses and passes props', () => {
expect(findUserActions().props()).toMatchObject({
user,
paths,
});
});
});