Added testcases for AddReminder Component (#5538)

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Nitin Ramnani 2022-10-20 00:54:08 +05:30 committed by GitHub
parent 3de8f256cb
commit f740727177
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 1 deletions

View file

@ -0,0 +1,48 @@
import { shallowMount } from '@vue/test-utils';
import AddReminder from '../AddReminder.vue';
let wrapper;
describe('AddReminder', () => {
beforeEach(() => {
wrapper = shallowMount(AddReminder, {
mocks: {
$t: x => x,
$store: {
getters: {},
state: {},
},
},
});
});
it('tests resetValue', () => {
const resetValue = jest.spyOn(wrapper.vm, 'resetValue');
wrapper.vm.content = 'test';
wrapper.vm.date = '08/11/2022';
wrapper.vm.resetValue();
expect(wrapper.vm.content).toEqual('');
expect(wrapper.vm.date).toEqual('');
expect(resetValue).toHaveBeenCalled();
});
it('tests optionSelected', () => {
const optionSelected = jest.spyOn(wrapper.vm, 'optionSelected');
wrapper.vm.label = '';
wrapper.vm.optionSelected({ target: { value: 'test' } });
expect(wrapper.vm.label).toEqual('test');
expect(optionSelected).toHaveBeenCalled();
});
it('tests onAdd', () => {
const onAdd = jest.spyOn(wrapper.vm, 'onAdd');
wrapper.vm.label = 'label';
wrapper.vm.content = 'content';
wrapper.vm.date = '08/11/2022';
wrapper.vm.onAdd();
expect(onAdd).toHaveBeenCalled();
expect(wrapper.emitted().add[0]).toEqual([
{ content: 'content', date: '08/11/2022', label: 'label' },
]);
});
});

View file

@ -15,7 +15,7 @@ module.exports = {
cacheDirectory: '<rootDir>/.jest-cache',
collectCoverage: false,
coverageDirectory: 'buildreports',
collectCoverageFrom: ['**/app/javascript/**/*.js'],
collectCoverageFrom: ['**/app/javascript/**/*.{js,vue}'],
reporters: ['default'],
// setupTestFrameworkScriptFile: './tests/setup.ts',
transformIgnorePatterns: ['node_modules/*'],