|
| 1 | +import Vue from 'vue' |
| 2 | +import CsvOption from '@/components/CsvOption' |
| 3 | +import * as td from 'testdouble' |
| 4 | + |
| 5 | +function getRendered (Component, propsData) { |
| 6 | + const Constructor = Vue.extend(Component) |
| 7 | + const vm = new Constructor({ propsData: propsData }).$mount() |
| 8 | + return vm |
| 9 | +} |
| 10 | + |
| 11 | +const propsData = { |
| 12 | + quotes: true, |
| 13 | + quoteChar: "'", |
| 14 | + delimiter: '|', |
| 15 | + header: false, |
| 16 | + newlineId: 'nlid1', |
| 17 | + timestamp: true, |
| 18 | + comp: true |
| 19 | +} |
| 20 | + |
| 21 | +describe('CsvOption.vue', () => { |
| 22 | + it('should render CsvOption Component', () => { |
| 23 | + const vm = getRendered(CsvOption, {}) |
| 24 | + expect(vm.$el.className).to.equal('csvoption') |
| 25 | + }) |
| 26 | + it('should render with props', () => { |
| 27 | + const vm = getRendered(CsvOption, propsData) |
| 28 | + expect(vm.quotes).to.equal(true) |
| 29 | + expect(vm.quoteChar).to.equal("'") |
| 30 | + expect(vm.delimiter).to.equal('|') |
| 31 | + expect(vm.header).to.equal(false) |
| 32 | + expect(vm.newlineId).to.equal('nlid1') |
| 33 | + expect(vm.timestamp).to.equal(true) |
| 34 | + expect(vm.comp).to.equal(true) |
| 35 | + }) |
| 36 | + it('should have public functions', () => { |
| 37 | + expect(typeof CsvOption.methods.showModal).to.equal('function') |
| 38 | + expect(typeof CsvOption.methods.submit).to.equal('function') |
| 39 | + expect(typeof CsvOption.methods.download).to.equal('function') |
| 40 | + }) |
| 41 | + it('should invoke functions', () => { |
| 42 | + const vm = getRendered(CsvOption, propsData) |
| 43 | + |
| 44 | + var showModel = td.function('vm.showModel') |
| 45 | + showModel() |
| 46 | + td.verify(showModel()) |
| 47 | + var submit = td.function('vm.submit') |
| 48 | + submit() |
| 49 | + td.verify(submit()) |
| 50 | + var download = td.function('vm.download') |
| 51 | + download() |
| 52 | + td.verify(download()) |
| 53 | + }) |
| 54 | +}) |
0 commit comments