1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-06 18:18:53 +08:00

fix lint errors

This commit is contained in:
lana-k
2021-01-21 14:08:06 +01:00
parent 8652edc139
commit ba44a6dfc6
2 changed files with 24 additions and 24 deletions

View File

@@ -3,7 +3,7 @@ import fu from '@/fileUtils.js'
import sinon from 'sinon' import sinon from 'sinon'
describe('fileUtils.js', () => { describe('fileUtils.js', () => {
afterEach(()=> { afterEach(() => {
document.createElement.restore() document.createElement.restore()
URL.revokeObjectURL.restore() URL.revokeObjectURL.restore()
URL.createObjectURL.restore() URL.createObjectURL.restore()
@@ -18,16 +18,15 @@ describe('fileUtils.js', () => {
sinon.spy(URL, 'createObjectURL') sinon.spy(URL, 'createObjectURL')
sinon.spy(URL, 'revokeObjectURL') sinon.spy(URL, 'revokeObjectURL')
sinon.spy(window, 'Blob') sinon.spy(window, 'Blob')
const str = 'foo' fu.exportToFile('foo', 'foo.txt')
fu.exportToFile('foo','foo.txt')
expect(document.createElement.calledOnceWith('a')).to.equal(true) expect(document.createElement.calledOnceWith('a')).to.equal(true)
expect(window.Blob.calledOnceWith(['foo'], { type: 'octet/stream' })).to.equal(true) expect(window.Blob.calledOnceWith(['foo'], { type: 'octet/stream' })).to.equal(true)
const blob = window.Blob.returnValues[0] const blob = window.Blob.returnValues[0]
expect(URL.createObjectURL.calledOnceWith(blob)).to.equal(true) expect(URL.createObjectURL.calledOnceWith(blob)).to.equal(true)
const url = URL.createObjectURL.returnValues[0] const url = URL.createObjectURL.returnValues[0]
expect(spyAnchor.href).to.equal(url) expect(spyAnchor.href).to.equal(url)
@@ -37,7 +36,7 @@ describe('fileUtils.js', () => {
expect(spyAnchor.remove.calledOnce).to.equal(true) expect(spyAnchor.remove.calledOnce).to.equal(true)
expect(URL.revokeObjectURL.calledOnceWith(url)).to.equal(true) expect(URL.revokeObjectURL.calledOnceWith(url)).to.equal(true)
}), })
it('exportToFile', () => { it('exportToFile', () => {
const spyAnchor = document.createElement('a') const spyAnchor = document.createElement('a')
@@ -47,16 +46,15 @@ describe('fileUtils.js', () => {
sinon.spy(URL, 'createObjectURL') sinon.spy(URL, 'createObjectURL')
sinon.spy(URL, 'revokeObjectURL') sinon.spy(URL, 'revokeObjectURL')
sinon.spy(window, 'Blob') sinon.spy(window, 'Blob')
const str = 'foo' fu.exportToFile('foo', 'foo.html', 'text/html')
fu.exportToFile('foo','foo.html', 'text/html')
expect(document.createElement.calledOnceWith('a')).to.equal(true) expect(document.createElement.calledOnceWith('a')).to.equal(true)
expect(window.Blob.calledOnceWith(['foo'], { type: 'text/html' })).to.equal(true) expect(window.Blob.calledOnceWith(['foo'], { type: 'text/html' })).to.equal(true)
const blob = window.Blob.returnValues[0] const blob = window.Blob.returnValues[0]
expect(URL.createObjectURL.calledOnceWith(blob)).to.equal(true) expect(URL.createObjectURL.calledOnceWith(blob)).to.equal(true)
const url = URL.createObjectURL.returnValues[0] const url = URL.createObjectURL.returnValues[0]
expect(spyAnchor.href).to.equal(url) expect(spyAnchor.href).to.equal(url)

View File

@@ -66,26 +66,28 @@ describe('storedQueries.js', () => {
expect(storedQueries.isTabNeedName(tab)).to.equal(true) expect(storedQueries.isTabNeedName(tab)).to.equal(true)
}) })
it ('serialiseQueries', () => { it('serialiseQueries', () => {
let queryList = [ const queryList = [
{ id: 1, {
id: 1,
name: 'foo', name: 'foo',
query: 'SELECT from foo', query: 'SELECT from foo',
chart: [], chart: [],
createdAt:'2020-11-03T14:17:49.524Z', createdAt: '2020-11-03T14:17:49.524Z',
isPredefined: true isPredefined: true
}, },
{ id: 2, {
id: 2,
name: 'bar', name: 'bar',
query: 'SELECT from bar', query: 'SELECT from bar',
chart: [], chart: [],
createdAt:'2020-12-03T14:17:49.524Z' createdAt: '2020-12-03T14:17:49.524Z'
}, }
] ]
const str = storedQueries.serialiseQueries(queryList) const str = storedQueries.serialiseQueries(queryList)
const parsedJson = JSON.parse(str) const parsedJson = JSON.parse(str)
expect(parsedJson).to.have.lengthOf(2) expect(parsedJson).to.have.lengthOf(2)
expect(parsedJson[1]).to.eql(queryList[1]) expect(parsedJson[1]).to.eql(queryList[1])
expect(parsedJson[0].id).to.equal(queryList[0].id) expect(parsedJson[0].id).to.equal(queryList[0].id)