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:
@@ -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/"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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)')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user