mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-07 02:28:54 +08:00
add default table in hint options
This commit is contained in:
@@ -25,6 +25,10 @@ const hintOptions = {
|
|||||||
}
|
}
|
||||||
return tables
|
return tables
|
||||||
},
|
},
|
||||||
|
get defaultTable () {
|
||||||
|
const schema = store.state.schema
|
||||||
|
return schema.length === 1 ? schema[0].name : null
|
||||||
|
},
|
||||||
completeSingle: false,
|
completeSingle: false,
|
||||||
completeOnSingleClick: true,
|
completeOnSingleClick: true,
|
||||||
alignWithWord: false
|
alignWithWord: false
|
||||||
|
|||||||
@@ -49,6 +49,39 @@ describe('hint.js', () => {
|
|||||||
foo: ['fooId', 'name'],
|
foo: ['fooId', 'name'],
|
||||||
bar: ['barId']
|
bar: ['barId']
|
||||||
})
|
})
|
||||||
|
expect(CM.showHint.firstCall.args[2].defaultTable).to.equal(null)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Add default table if there is only one table in schema', () => {
|
||||||
|
// mock store state
|
||||||
|
const schema = [
|
||||||
|
{
|
||||||
|
name: 'foo',
|
||||||
|
columns: [
|
||||||
|
{ name: 'fooId', type: 'INTEGER' },
|
||||||
|
{ name: 'name', type: 'NVARCHAR(20)' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
sinon.stub(state, 'schema').value(schema)
|
||||||
|
|
||||||
|
// mock showHint and editor
|
||||||
|
sinon.stub(CM, 'showHint')
|
||||||
|
const editor = {
|
||||||
|
getTokenAt () {
|
||||||
|
return {
|
||||||
|
string: 'SELECT',
|
||||||
|
type: 'keyword'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getCursor: sinon.stub()
|
||||||
|
}
|
||||||
|
|
||||||
|
const clock = sinon.useFakeTimers()
|
||||||
|
hint.show(editor)
|
||||||
|
clock.tick(500)
|
||||||
|
|
||||||
|
expect(CM.showHint.firstCall.args[2].defaultTable).to.equal('foo')
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Doesn't show hint when in string or space, or ';'", () => {
|
it("Doesn't show hint when in string or space, or ';'", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user