Skip to content

Commit d36c96a

Browse files
committed
Merge pull request previm#36 from kannokanno/35-switch-vimtest-to-themis
previm#35 switch vimtest to themis
2 parents 6ad4348 + 86297a1 commit d36c96a

File tree

3 files changed

+50
-37
lines changed

3 files changed

+50
-37
lines changed

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: generic
2+
3+
before_script:
4+
- git clone https://github.com/thinca/vim-themis --quiet --branch v1.4.1 --single-branch --depth 1 /tmp/vim-themis
5+
6+
script:
7+
- vim --version
8+
- /tmp/vim-themis/bin/themis test/ -r --reporter dot
9+
10+
notifications:
11+
email: false

test/autoload/previm_test.vim

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,111 @@
11
let s:newline = "\\n"
2+
let s:assert = themis#helper('assert')
23

3-
let s:t = vimtest#new('convert_to_content') "{{{
4+
let s:t = themis#suite('convert_to_content') "{{{
45

56
function! s:t.empty_lines()
67
let arg = []
78
let expected = ''
8-
call self.assert.equals(expected, previm#convert_to_content(arg))
9+
call s:assert.equals(expected, previm#convert_to_content(arg))
910
endfunction
1011

1112
function! s:t.not_exists_escaped()
1213
let arg = ['aaabbb', 'あいうえお漢字']
1314
let expected =
1415
\ 'aaabbb' . s:newline
1516
\ . 'あいうえお漢字'
16-
call self.assert.equals(expected, previm#convert_to_content(arg))
17+
call s:assert.equals(expected, previm#convert_to_content(arg))
1718
endfunction
1819

1920
function! s:t.exists_backslash()
2021
let arg = ['\(x -> x + 2)', 'あいうえお漢字']
2122
let expected =
2223
\ '\\(x -> x + 2)' . s:newline
2324
\ . 'あいうえお漢字'
24-
call self.assert.equals(expected, previm#convert_to_content(arg))
25+
call s:assert.equals(expected, previm#convert_to_content(arg))
2526
endfunction
2627

2728
function! s:t.exists_double_quotes()
2829
let arg = ['he said. "Hello, john"', 'あいうえお漢字']
2930
let expected =
3031
\ 'he said. \"Hello, john\"' . s:newline
3132
\ . 'あいうえお漢字'
32-
call self.assert.equals(expected, previm#convert_to_content(arg))
33+
call s:assert.equals(expected, previm#convert_to_content(arg))
3334
endfunction
3435
"}}}
35-
let s:t = vimtest#new('relative_to_absolute') "{{{
36+
let s:t = themis#suite('relative_to_absolute') "{{{
3637

3738
function! s:t.nothing_when_empty()
3839
let arg_line = ''
3940
let expected = ''
40-
call self.assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, ''))
41+
call s:assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, ''))
4142
endfunction
4243

4344
function! s:t.nothing_when_not_href()
4445
let arg_line = 'previm.dummy.com/some/path/img.png'
4546
let expected = 'previm.dummy.com/some/path/img.png'
46-
call self.assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, ''))
47+
call s:assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, ''))
4748
endfunction
4849

4950
function! s:t.nothing_when_absolute_by_http()
5051
let arg_line = 'http://previm.dummy.com/some/path/img.png'
5152
let expected = 'http://previm.dummy.com/some/path/img.png'
52-
call self.assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, ''))
53+
call s:assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, ''))
5354
endfunction
5455

5556
function! s:t.nothing_when_absolute_by_https()
5657
let arg_line = 'https://previm.dummy.com/some/path/img.png'
5758
let expected = 'https://previm.dummy.com/some/path/img.png'
58-
call self.assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, ''))
59+
call s:assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, ''))
5960
endfunction
6061

6162
function! s:t.nothing_when_absolute_by_file()
6263
let arg_line = 'file://previm/some/path/img.png'
6364
let expected = 'file://previm/some/path/img.png'
64-
call self.assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, ''))
65+
call s:assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, ''))
6566
endfunction
6667

6768
function! s:t.replace_path_when_relative()
6869
let rel_path = 'previm/some/path/img.png'
6970
let arg_line = printf('![img](%s)', rel_path)
7071
let arg_dir = '/Users/foo/tmp'
7172
let expected = printf('![img](file://localhost%s/%s)', arg_dir, rel_path)
72-
call self.assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, arg_dir))
73+
call s:assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, arg_dir))
7374
endfunction
7475

7576
function! s:t.urlencoded_path()
7677
let rel_path = 'previm\some\path\img.png'
7778
let arg_line = printf('![img](%s)', rel_path)
7879
let arg_dir = 'C:\Documents and Settings\folder'
7980
let expected = '![img](file://localhost/C:\Documents%20and%20Settings\folder/previm\some\path\img.png)'
80-
call self.assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, arg_dir))
81+
call s:assert.equals(expected, previm#relative_to_absolute_imgpath(arg_line, arg_dir))
8182
endfunction
8283
"}}}
83-
let s:t = vimtest#new('fetch_imgpath_elements') "{{{
84+
let s:t = themis#suite('fetch_imgpath_elements') "{{{
8485

8586
function! s:t.nothing_when_empty()
8687
let arg = ''
8788
let expected = s:empty_img_elements()
88-
call self.assert.equals(expected, previm#fetch_imgpath_elements(arg))
89+
call s:assert.equals(expected, previm#fetch_imgpath_elements(arg))
8990
endfunction
9091

9192
function! s:t.nothing_when_not_img_statement()
9293
let arg = '## hogeほげ'
9394
let expected = s:empty_img_elements()
94-
call self.assert.equals(expected, previm#fetch_imgpath_elements(arg))
95+
call s:assert.equals(expected, previm#fetch_imgpath_elements(arg))
9596
endfunction
9697

9798
function! s:t.get_title_and_path()
9899
let arg = '![IMG](path/img.png)'
99100
let expected = {'title': 'IMG', 'path': 'path/img.png'}
100-
call self.assert.equals(expected, previm#fetch_imgpath_elements(arg))
101+
call s:assert.equals(expected, previm#fetch_imgpath_elements(arg))
101102
endfunction
102103

103104
function! s:empty_img_elements()
104105
return {'title': '', 'path': ''}
105106
endfunction
106107
"}}}
107-
let s:t = vimtest#new('refresh_css') "{{{
108+
let s:t = themis#suite('refresh_css') "{{{
108109
function! s:t.setup()
109110
let self.exist_previm_disable_default_css = 0
110111
if exists('g:previm_disable_default_css')
@@ -136,7 +137,7 @@ endfunction
136137
function! s:t.default_content_if_not_exists_setting()
137138
call previm#refresh_css()
138139
let actual = readfile(previm#make_preview_file_path('css/previm.css'))
139-
call self.assert.equals([
140+
call s:assert.equals([
140141
\ "@import url('origin.css');",
141142
\ "@import url('lib/github.css');",
142143
\ ], actual)
@@ -146,7 +147,7 @@ function! s:t.default_content_if_invalid_setting()
146147
let g:previm_disable_default_css = 2
147148
call previm#refresh_css()
148149
let actual = readfile(previm#make_preview_file_path('css/previm.css'))
149-
call self.assert.equals([
150+
call s:assert.equals([
150151
\ "@import url('origin.css');",
151152
\ "@import url('lib/github.css');",
152153
\ ], actual)
@@ -159,7 +160,7 @@ function! s:t.custom_content_if_exists_file()
159160
call previm#refresh_css()
160161

161162
let actual = readfile(previm#make_preview_file_path('css/previm.css'))
162-
call self.assert.equals(["@import url('user_custom.css');"], actual)
163+
call s:assert.equals(["@import url('user_custom.css');"], actual)
163164
endfunction
164165

165166
function! s:t.empty_if_not_exists_file()
@@ -168,6 +169,6 @@ function! s:t.empty_if_not_exists_file()
168169
call previm#refresh_css()
169170

170171
let actual = readfile(previm#make_preview_file_path('css/previm.css'))
171-
call self.assert.equals([], actual)
172+
call s:assert.equals([], actual)
172173
endfunction
173174
"}}}

test/plugin/previm_test.vim

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,46 @@
1-
let s:t = vimtest#new('valid filetype for using :PrevimOpen')
1+
let s:t = themis#suite('valid filetype for using :PrevimOpen')
2+
let s:assert = themis#helper('assert')
23

3-
function! s:t.setup()
4+
function! s:t.before()
45
let self._ft = &filetype
56
endfunction
67

7-
function! s:t.teardown()
8+
function! s:t.after()
89
let &filetype = self._ft
9-
call self._clean_command()
10+
call s:_clean_command()
1011
endfunction
1112

12-
function! s:t._clean_command()
13+
function! s:_clean_command()
1314
if exists(':PrevimOpen') == 2
1415
delcommand PrevimOpen
1516
endif
1617
endfunction
1718

1819
" helper
19-
function! s:t._assert_filetype(ft, expected)
20+
function! s:_assert_filetype(ft, expected)
2021
let &filetype = a:ft
2122
let actual = exists(':PrevimOpen')
22-
if actual ==# a:expected
23-
call self.assert.success()
24-
else
25-
call self.assert.fail(printf("'%s': expected %d but actual %d", a:ft, a:expected, actual))
23+
if actual !=# a:expected
24+
call s:assert.fail(printf("'%s': expected %d but actual %d", a:ft, a:expected, actual))
2625
endif
2726
endfunction
2827
"""
2928

3029
function! s:t.invalid_filetype()
31-
call self._assert_filetype('', 0)
32-
call self._assert_filetype('rb', 0)
33-
call self._assert_filetype('php', 0)
30+
let not_exist_command = 0
31+
for type in ['', 'rb', 'php']
32+
call s:_assert_filetype(type, not_exist_command)
33+
endfor
3434
endfunction
3535

3636
function! s:t.valid_filetype()
37+
let exist_command = 2
3738
for type in [
3839
\ 'markdown', 'mkd', 'rst', 'textile',
3940
\ 'aaa.markdown', 'mkd.foo', 'bb.rst.cc', 'a.b.c.textile',
4041
\]
41-
call self._assert_filetype(type, 2)
42-
call self._clean_command()
42+
call s:_assert_filetype(type, exist_command)
43+
call s:_clean_command()
4344
endfor
4445
endfunction
4546

0 commit comments

Comments
 (0)