1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-07 02:28:54 +08:00

add tests for isTabNeedName

This commit is contained in:
lana-k
2021-01-13 21:12:16 +01:00
parent 33a9b261bf
commit 3168c77c17
2 changed files with 26 additions and 3 deletions

View File

@@ -17,7 +17,7 @@ export default {
isTabNeedName (queryTab) {
const isFromScratch = !queryTab.initName
return isFromScratch || queryTab.isPredefined
return queryTab.isPredefined || isFromScratch
},
save (queryTab, newName) {
@@ -74,7 +74,7 @@ export default {
// Create downloader
const downloader = document.createElement('a')
downloader.hidden = true
document.body.appendChild(downloader)
document.body.append(downloader)
// Prepare data
const name = data.name || 'My sqlitevis queries'
@@ -137,7 +137,7 @@ export default {
reader.readAsText(file)
})
document.body.appendChild(uploader)
document.body.append(uploader)
}
uploader.click()
}

View File

@@ -41,4 +41,27 @@ describe('storedQueries.js', () => {
expect(copy).to.have.property('createdAt').which.within(now, nowPlusMinute)
expect(copy).to.not.have.property('isPredefined')
})
it('isTabNeedName returns false when the query has a name and is not predefined', () => {
let tab = {
initName: 'foo'
}
expect(storedQueries.isTabNeedName(tab)).to.be.false
})
it('isTabNeedName returns true when the query has no name and is not predefined', () => {
let tab = {
initName: null,
tempName: 'Untitled'
}
expect(storedQueries.isTabNeedName(tab)).to.be.true
})
it('isTabNeedName returns true when the qiery is predefined', () => {
let tab = {
initName: 'foo',
isPredefined: true
}
expect(storedQueries.isTabNeedName(tab)).to.be.true
})
})