-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #523 from mtsknn/options-test
Create `Options.test.js` with initial tests
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); | ||
}); |