I broke up with neovim....vim is my best friend now
This commit is contained in:
86
dot_vim/plugged/vim-lsp/test/lsp/utils/diff.vimspec
Normal file
86
dot_vim/plugged/vim-lsp/test/lsp/utils/diff.vimspec
Normal file
@@ -0,0 +1,86 @@
|
||||
Describe lsp#utils#diff
|
||||
|
||||
Describe lsp#utils#diff#compute
|
||||
It should return diff of one letter
|
||||
let lines1 = [
|
||||
\ 'foo',
|
||||
\ 'bar',
|
||||
\ 'baz',
|
||||
\]
|
||||
let lines2 = [
|
||||
\ 'foo',
|
||||
\ 'baR',
|
||||
\ 'baz',
|
||||
\]
|
||||
let want = {
|
||||
\ 'range': {
|
||||
\ 'start': { 'line': 1, 'character': 2 },
|
||||
\ 'end': { 'line': 1, 'character': 3 },
|
||||
\ },
|
||||
\ 'text': 'R',
|
||||
\ 'rangeLength': 1
|
||||
\}
|
||||
let got = lsp#utils#diff#compute(lines1, lines2)
|
||||
Assert Equals(got, want)
|
||||
End
|
||||
|
||||
It should return diff of multi-lines
|
||||
let lines1 = [
|
||||
\ 'foo',
|
||||
\ 'bar',
|
||||
\ 'baz',
|
||||
\]
|
||||
let lines2 = [
|
||||
\ 'Foo',
|
||||
\ 'baR',
|
||||
\ 'baz',
|
||||
\]
|
||||
let want = {
|
||||
\ 'range': {
|
||||
\ 'start': { 'line': 0, 'character': 0 },
|
||||
\ 'end': { 'line': 1, 'character': 3, }
|
||||
\ },
|
||||
\ 'text': "Foo\nbaR",
|
||||
\ "rangeLength": 7
|
||||
\}
|
||||
let got = lsp#utils#diff#compute(lines1, lines2)
|
||||
Assert Equals(got, want)
|
||||
End
|
||||
|
||||
It should return diff for empty list
|
||||
let lines1 = []
|
||||
let lines2 = [
|
||||
\ 'foo',
|
||||
\ 'bar',
|
||||
\ 'baz',
|
||||
\]
|
||||
let want = {
|
||||
\ 'range': {
|
||||
\ 'start': { 'line': 0, 'character': 0 },
|
||||
\ 'end': { 'line': 0, 'character': 0, }
|
||||
\ },
|
||||
\ 'text': "foo\nbar\nbaz\n",
|
||||
\ "rangeLength": 0
|
||||
\}
|
||||
let got = lsp#utils#diff#compute(lines1, lines2)
|
||||
Assert Equals(got, want)
|
||||
|
||||
let lines1 = [
|
||||
\ 'foo',
|
||||
\ 'bar',
|
||||
\ 'baz',
|
||||
\]
|
||||
let lines2 = []
|
||||
let want = {
|
||||
\ 'range': {
|
||||
\ 'start': { 'line': 0, 'character': 0 },
|
||||
\ 'end': { 'line': 3, 'character': 0, }
|
||||
\ },
|
||||
\ 'text': '',
|
||||
\ "rangeLength": 12
|
||||
\}
|
||||
let got = lsp#utils#diff#compute(lines1, lines2)
|
||||
Assert Equals(got, want)
|
||||
End
|
||||
End
|
||||
End
|
||||
Reference in New Issue
Block a user