mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
add tests for isTabNeedName
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user