Skip to content

Commit

Permalink
test: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangc110033 committed Jul 4, 2024
1 parent 4fd830d commit 5bc960f
Showing 1 changed file with 45 additions and 39 deletions.
84 changes: 45 additions & 39 deletions packages/extensions/sql-parser/src/test/statement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('test getSqlStatements', () => {
})
})

test('test getNearbyStatement', () => {
describe('test getNearbyStatement', () => {
let editorView: EditorView = new EditorView()

beforeAll(() => {
Expand All @@ -75,42 +75,48 @@ test('test getNearbyStatement', () => {
editorView.dispatch({ selection: { anchor: 0, head: 0 } })
})

expect(getNearbyStatement(editorView.state, 0)?.content).toBe(LINE_1)

expect(getNearbyStatement(editorView.state, 10)?.content).toBe(LINE_1)

// 18
expect(getNearbyStatement(editorView.state, 1 + LINE_1.length)?.content).toBe(
LINE_1
)

// 19
expect(
getNearbyStatement(editorView.state, 1 + LINE_1.length + 1)?.content
).toBe(LINE_1)

// 28
expect(
getNearbyStatement(editorView.state, 1 + LINE_1.length + 10)?.content
).toBe(LINE_1)

// 241
expect(
getNearbyStatement(editorView.state, 1 + LINE_1.length + 2 + LINE_2.length)
?.content
).toBe(LINE_2)

// 241
expect(
getNearbyStatement(editorView.state, 1 + LINE_1.length + 2 + LINE_2.length)
?.content
).toBe(LINE_2)

// 243
expect(
getNearbyStatement(
editorView.state,
1 + LINE_1.length + 2 + LINE_2.length + 2
)?.content
).toBe(LINE_2)
test('getNearbyStatement works well', () => {
expect(getNearbyStatement(editorView.state, 0)?.content).toBe(LINE_1)

expect(getNearbyStatement(editorView.state, 10)?.content).toBe(LINE_1)

// 18
expect(
getNearbyStatement(editorView.state, 1 + LINE_1.length)?.content
).toBe(LINE_1)

// 19
expect(
getNearbyStatement(editorView.state, 1 + LINE_1.length + 1)?.content
).toBe(LINE_1)

// 28
expect(
getNearbyStatement(editorView.state, 1 + LINE_1.length + 10)?.content
).toBe(LINE_1)

// 241
expect(
getNearbyStatement(
editorView.state,
1 + LINE_1.length + 2 + LINE_2.length
)?.content
).toBe(LINE_2)

// 241
expect(
getNearbyStatement(
editorView.state,
1 + LINE_1.length + 2 + LINE_2.length
)?.content
).toBe(LINE_2)

// 243
expect(
getNearbyStatement(
editorView.state,
1 + LINE_1.length + 2 + LINE_2.length + 2
)?.content
).toBe(LINE_2)
})
})

0 comments on commit 5bc960f

Please sign in to comment.