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

storedQueries module is covered by tests

This commit is contained in:
lana-k
2021-01-27 21:00:22 +01:00
parent f640727d96
commit d45212733d
5 changed files with 118 additions and 13 deletions

View File

@@ -77,7 +77,7 @@ export default {
this.state = { data, layout, frames }
this.$emit('update')
},
getChartSatateForSave () {
getChartStateForSave () {
// we don't need to save the data, only settings
// so we modify state.data using dereference
const stateCopy = JSON.parse(JSON.stringify(this.state))

View File

@@ -134,8 +134,8 @@ export default {
const freeSpace = bottomPane.offsetHeight - 88 - 42 - 30 - 5 - 40
this.tableViewHeight = freeSpace - (freeSpace % 40)
},
getChartSatateForSave () {
return this.$refs.chart.getChartSatateForSave()
getChartStateForSave () {
return this.$refs.chart.getChartStateForSave()
}
}
}

View File

@@ -25,17 +25,15 @@ export default {
const value = {
id: queryTab.isPredefined ? nanoid() : queryTab.id,
query: queryTab.query,
chart: queryTab.getChartSatateForSave(),
chart: queryTab.getChartStateForSave(),
name: newName || queryTab.initName
}
const isNeedName = this.isTabNeedName(queryTab)
// Get queries from local storage
let myQueries = this.getStoredQueries()
// Set createdAt
if (isNeedName) {
if (newName) {
value.createdAt = new Date()
} else {
var queryIndex = myQueries.findIndex(oldQuery => oldQuery.id === queryTab.id)
@@ -43,9 +41,7 @@ export default {
}
// Insert in queries list
if (!myQueries) {
myQueries = [value]
} else if (isNeedName) {
if (newName) {
myQueries.push(value)
} else {
myQueries[queryIndex] = value