1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-07 02:28:54 +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

@@ -4,7 +4,6 @@ const path = require("path");
const VueLoaderPlugin = require("vue-loader/lib/plugin"); const VueLoaderPlugin = require("vue-loader/lib/plugin");
function resolve(dir) { function resolve(dir) {
console.log('HELLO!!!', path.join(__dirname, dir))
return path.join(__dirname, dir); return path.join(__dirname, dir);
} }
@@ -18,8 +17,21 @@ module.exports = function(config) {
frameworks: ["mocha", "sinon-chai"], frameworks: ["mocha", "sinon-chai"],
// list of files / patterns to load in the browser // list of files / patterns to load in the browser
files: ["tests/unit/*.spec.js"], files: [
// files: ["./karma.files.js"], "tests/unit/*.spec.js",
{ pattern: 'node_modules/sql.js/dist/sql-wasm.wasm',
watched: false,
included: false,
served: true,
nocache: false
},
{ pattern: 'node_modules/sql.js/dist/worker.sql-wasm.js',
watched: false,
included: false,
served: true,
nocache: false
}
],
// list of files / patterns to exclude // list of files / patterns to exclude
exclude: [], exclude: [],
@@ -28,7 +40,6 @@ module.exports = function(config) {
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: { preprocessors: {
"tests/unit/*.spec.js": ["webpack"] "tests/unit/*.spec.js": ["webpack"]
//"./karma.files.js": ["webpack"]
}, },
// test results reporter to use // test results reporter to use
@@ -150,7 +161,13 @@ module.exports = function(config) {
} }
] ]
}, },
plugins: [new VueLoaderPlugin()] plugins: [new VueLoaderPlugin()],
node: {
fs: 'empty'
}
},
proxies: {
"/js/": "/base/node_modules/sql.js/dist/"
} }
}); });
}; };

View File

@@ -1,4 +1,4 @@
import { expect } from 'chai' /* import { expect } from 'chai'
import { shallowMount } from '@vue/test-utils' import { shallowMount } from '@vue/test-utils'
import HelloWorld from '@/components/HelloWorld.vue' import HelloWorld from '@/components/HelloWorld.vue'
@@ -11,3 +11,29 @@ describe('HelloWorld.vue', () => {
expect(wrapper.text()).to.include(msg) 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)')
})
})
})