Skip to content

Commit fc5970e

Browse files
committed
update CsvDownload.spec.js support option
1 parent 97d27a5 commit fc5970e

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

test/unit/specs/CsvDownload.spec.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ function getRendered (Component, propsData) {
99
}
1010

1111
const testHeader = {
12-
'a': 'headerA',
13-
'b': 'headerB'
14-
}
12+
'a': 'headerA',
13+
'b': 'headerB'
14+
}
1515

1616
const testDataJson = [
1717
{
@@ -24,6 +24,11 @@ const testDataJson = [
2424
}
2525
]
2626

27+
const testOptions = {
28+
delimiter: ',',
29+
timestamp: false
30+
}
31+
2732
describe('CsvDownload.vue', () => {
2833
it('should render CsvDownload Component', () => {
2934
const vm = getRendered(CsvDownload, {})
@@ -32,33 +37,36 @@ describe('CsvDownload.vue', () => {
3237
it('should render with props', () => {
3338
const propsData = {
3439
title: 'testTitle',
35-
filename: 'testFile.csv',
36-
convOption: { opt1: 'testOpt' },
40+
filename: 'testFile',
41+
options: testOptions,
3742
dataJson: testDataJson
3843
}
3944
const vm = getRendered(CsvDownload, propsData)
4045
expect(vm.title).to.equal('testTitle')
41-
expect(vm.filename).to.equal('testFile.csv')
42-
expect(vm.convOption.opt1).to.equal('testOpt')
46+
expect(vm.filename).to.equal('testFile')
47+
expect(vm.options.delimiter).to.equal(',')
4348
expect(vm.dataJson).to.equal(testDataJson)
4449
})
4550
it('should convert csv', () => {
4651
const vm = getRendered(CsvDownload, { dataJson: testDataJson })
47-
vm.convert()
52+
const dataCSV = vm.convert()
4853
const expected = 'a,b\r\n1,2\r\n3,4'
49-
expect(expected).to.equal(vm.dataCSV)
54+
expect(expected).to.equal(dataCSV)
5055
})
5156
it('should convert csv with header', () => {
5257
const vm = getRendered(CsvDownload, { header: testHeader, dataJson: testDataJson })
53-
vm.convert()
58+
const dataCSV = vm.convert()
5459
const expected = 'headerA,headerB\r\n1,2\r\n3,4'
55-
expect(expected).to.equal(vm.dataCSV)
60+
expect(expected).to.equal(dataCSV)
5661
})
5762
it('should called download', () => {
5863
const vm = getRendered(CsvDownload, {})
5964

6065
var download = td.function('vm.download')
6166
download()
6267
td.verify(download())
68+
var emitDownload = td.function('vm.emitDownload')
69+
emitDownload()
70+
td.verify(emitDownload())
6371
})
6472
})

0 commit comments

Comments
 (0)