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

2 Commits

Author SHA1 Message Date
lana-k
8aac7af481 update package.json 2023-07-03 23:33:52 +02:00
lana-k
6982204e68 Update currentTab when close tabs #112 2023-07-03 23:13:09 +02:00
3 changed files with 16 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "sqliteviz",
"version": "0.23.1",
"version": "0.23.2",
"license": "Apache-2.0",
"private": true,
"scripts": {

View File

@@ -36,9 +36,11 @@ export default {
state.currentTabId = state.tabs[index - 1].id
} else {
state.currentTabId = null
state.currentTab = null
state.untitledLastIndex = 0
}
state.currentTab = state.currentTabId
? state.tabs.find(tab => tab.id === state.currentTabId)
: null
}
state.tabs.splice(index, 1)
},

View File

@@ -176,13 +176,15 @@ describe('mutations', () => {
const state = {
tabs: [tab1, tab2],
currentTabId: 1
currentTabId: 1,
currentTab: tab1
}
deleteTab(state, tab1)
expect(state.tabs).to.have.lengthOf(1)
expect(state.tabs[0].id).to.equal(2)
expect(state.currentTabId).to.equal(2)
expect(state.currentTab).to.eql(tab2)
})
it('deleteTab - opened, last', () => {
@@ -208,13 +210,15 @@ describe('mutations', () => {
const state = {
tabs: [tab1, tab2],
currentTabId: 2
currentTabId: 2,
currentTab: tab2
}
deleteTab(state, tab2)
expect(state.tabs).to.have.lengthOf(1)
expect(state.tabs[0].id).to.equal(1)
expect(state.currentTabId).to.equal(1)
expect(state.currentTab).to.eql(tab1)
})
it('deleteTab - opened, in the middle', () => {
@@ -250,7 +254,8 @@ describe('mutations', () => {
const state = {
tabs: [tab1, tab2, tab3],
currentTabId: 2
currentTabId: 2,
currentTab: tab2
}
deleteTab(state, tab2)
@@ -258,6 +263,7 @@ describe('mutations', () => {
expect(state.tabs[0].id).to.equal(1)
expect(state.tabs[1].id).to.equal(3)
expect(state.currentTabId).to.equal(3)
expect(state.currentTab).to.eql(tab3)
})
it('deleteTab - opened, single', () => {
@@ -273,12 +279,14 @@ describe('mutations', () => {
const state = {
tabs: [tab1],
currentTabId: 1
currentTabId: 1,
currentTab: tab1
}
deleteTab(state, tab1)
expect(state.tabs).to.have.lengthOf(0)
expect(state.currentTabId).to.equal(null)
expect(state.currentTab).to.equal(null)
})
it('setCurrentTabId', () => {