Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/admin/signup_restrictions/components/signup_checkbox_spec.js')
-rw-r--r--spec/frontend/admin/signup_restrictions/components/signup_checkbox_spec.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/frontend/admin/signup_restrictions/components/signup_checkbox_spec.js b/spec/frontend/admin/signup_restrictions/components/signup_checkbox_spec.js
new file mode 100644
index 00000000000..ae9b6f57ee0
--- /dev/null
+++ b/spec/frontend/admin/signup_restrictions/components/signup_checkbox_spec.js
@@ -0,0 +1,66 @@
+import { GlFormCheckbox } from '@gitlab/ui';
+import { shallowMount } from '@vue/test-utils';
+import SignupCheckbox from '~/pages/admin/application_settings/general/components/signup_checkbox.vue';
+
+describe('Signup Form', () => {
+ let wrapper;
+
+ const props = {
+ name: 'name',
+ helpText: 'some help text',
+ label: 'a label',
+ value: true,
+ dataQaSelector: 'qa_selector',
+ };
+
+ const mountComponent = () => {
+ wrapper = shallowMount(SignupCheckbox, {
+ propsData: props,
+ stubs: {
+ GlFormCheckbox,
+ },
+ });
+ };
+
+ const findByTestId = (id) => wrapper.find(`[data-testid="${id}"]`);
+ const findHiddenInput = () => findByTestId('input');
+ const findCheckbox = () => wrapper.find(GlFormCheckbox);
+ const findCheckboxLabel = () => findByTestId('label');
+ const findHelpText = () => findByTestId('helpText');
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ describe('Signup Checkbox', () => {
+ beforeEach(() => {
+ mountComponent();
+ });
+
+ describe('hidden input element', () => {
+ it('gets passed correct values from props', () => {
+ expect(findHiddenInput().attributes('name')).toBe(props.name);
+
+ expect(findHiddenInput().attributes('value')).toBe('1');
+ });
+ });
+
+ describe('checkbox', () => {
+ it('gets passed correct checked value', () => {
+ expect(findCheckbox().attributes('checked')).toBe('true');
+ });
+
+ it('gets passed correct label', () => {
+ expect(findCheckboxLabel().text()).toBe(props.label);
+ });
+
+ it('gets passed correct help text', () => {
+ expect(findHelpText().text()).toBe(props.helpText);
+ });
+
+ it('gets passed data qa selector', () => {
+ expect(findCheckbox().attributes('data-qa-selector')).toBe(props.dataQaSelector);
+ });
+ });
+ });
+});