Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Options.test.js with initial tests #523

Merged
merged 1 commit into from
Nov 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions client/test/src/views/Options.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex';

import Options from '../../../src/views/Options';

const localVue = createLocalVue();
localVue.use(Vuex);
localVue.directive('click-outside', { bind() {}, unbind() {} });
localVue.directive('wow', { bind() {}, unbind() {} });

const languageOptions = ['bangla', 'brazilian-portuguese'];

describe('Options', () => {
const store = new Vuex.Store({
state: {
languageOptions,
},
actions: {
getLanguageOptions: () => languageOptions,
},
});
const wrapper = shallowMount(Options, { store, localVue });

it('is a Vue instance', () => {
expect(wrapper.vm).toBeTruthy();
});

describe('`customLabel` method', () => {
it('returns an empty string for non-string inputs', () => {
expect(wrapper.vm.customLabel()).toBe('');
expect(wrapper.vm.customLabel(undefined)).toBe('');
expect(wrapper.vm.customLabel(null)).toBe('');
expect(wrapper.vm.customLabel({})).toBe('');
expect(wrapper.vm.customLabel([])).toBe('');
expect(wrapper.vm.customLabel(100)).toBe('');
expect(wrapper.vm.customLabel(true)).toBe('');
expect(wrapper.vm.customLabel(Symbol('foo'))).toBe('');
});
it('converts single-word values to Title Case', () => {
const result = wrapper.vm.customLabel(languageOptions[0]);
expect(result).toBe('Bangla');
});
it('converts multi-word values to Title Case and hyphens to spaces', () => {
const result = wrapper.vm.customLabel(languageOptions[1]);
expect(result).toBe('Brazilian Portuguese');
});
});
});