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

add proxy and test

This commit is contained in:
lana-k
2020-12-16 19:05:05 +01:00
parent 2aac74fba2
commit 0c777b9f30
2 changed files with 50 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
import { expect } from 'chai'
/* import { expect } from 'chai'
import { shallowMount } from '@vue/test-utils'
import HelloWorld from '@/components/HelloWorld.vue'
@@ -11,3 +11,29 @@ describe('HelloWorld.vue', () => {
expect(wrapper.text()).to.include(msg)
})
})
*/
import { expect } from 'chai'
import initSqlJs from 'sql.js'
import db from '@/dataBase.js'
describe('dataBase.js', () => {
it('creates schema', () => {
const config = {
locateFile: filename => `js/sql-wasm.wasm`
}
return initSqlJs(config)
.then(SQL => {
const dataBase = new SQL.Database()
dataBase.run("CREATE TABLE test (col1, col2);")
const data = dataBase.export()
const buffer = new Blob([data])
return db.loadDb(buffer)
})
.then(schema => {
expect(schema.length).to.equal(1)
expect(schema[0][0]).to.equal('test')
expect(schema[0][1]).to.equal('CREATE TABLE test (col1, col2)')
})
})
})