diff --git a/.themisrc b/.themisrc index a3c8dd7..892e9e0 100644 --- a/.themisrc +++ b/.themisrc @@ -1 +1,13 @@ let &runtimepath .= ',' . fnamemodify(expand(''), ':h') . '/test' +call themis#helper('command').with(themis#helper('assert')) + +let s:emmet = themis#helper('emmet') +call s:emmet.setup() + +function! ExpandWord(query, type) abort + return s:emmet.expand_word(a:query, a:type) +endfunction + +function! ExpandInBuffer(query, type, result) abort + return s:emmet.expand_in_buffer(a:query, a:type, a:result) +endfunction diff --git a/test/autoload/themis/helper/emmet.vim b/test/autoload/themis/helper/emmet.vim index 7b84bef..c24d330 100644 --- a/test/autoload/themis/helper/emmet.vim +++ b/test/autoload/themis/helper/emmet.vim @@ -2,13 +2,7 @@ let s:helper = {} function! s:helper.setup() abort let g:user_emmet_settings = {'variables': {'indentation': "\t", 'use_selection': 1}} - for f in split(globpath(getcwd(), 'autoload/**/*.vim'), "\n") - if f =~# 'themis' - continue - endif - silent! exe 'so' f - endfor - silent! exe 'so' getcwd() . '/plugin/emmet.vim' + exe 'so' getcwd() . '/plugin/emmet.vim' endfunction function! s:helper.expand_word(query, type) abort diff --git a/test/css.vim b/test/css.vim deleted file mode 100644 index 80a2952..0000000 --- a/test/css.vim +++ /dev/null @@ -1,152 +0,0 @@ -let s:suite = themis#suite('css') -let s:assert = themis#helper('assert') - -let s:emmet = themis#helper('emmet') - -function! s:suite.__setup() abort - call s:emmet.setup() -endfunction - -function! s:suite.__expand_abbreviation() - let expand = themis#suite('expand abbreviation') - - function! expand.font_style_normal() abort - let res = s:emmet.expand_in_buffer('{fs:n$$$$}', 'css', '{font-style: normal;}') - call s:assert.equals(res, '{font-style: normal;}') - endfunction - - function! expand.float_left_fc() abort - let res = s:emmet.expand_in_buffer('{fl:l|fc$$$$}', 'css', '{float: left;}') - call s:assert.equals(res, '{float: left;}') - endfunction - - function! expand.background_plus() abort - let res = s:emmet.expand_in_buffer('{bg+$$$$}', 'css', '{background: $$$$#fff url() 0 0 no-repeat;}') - call s:assert.equals(res, '{background: $$$$#fff url() 0 0 no-repeat;}') - endfunction - - function! expand.background_plus_important() abort - let res = s:emmet.expand_in_buffer('{bg+!$$$$}', 'css', '{background: $$$$#fff url() 0 0 no-repeat !important;}') - call s:assert.equals(res, '{background: $$$$#fff url() 0 0 no-repeat !important;}') - endfunction - - function! expand.margin() abort - let res = s:emmet.expand_in_buffer('{m$$$$}', 'css', '{margin: $$$$;}') - call s:assert.equals(res, '{margin: $$$$;}') - endfunction - - function! expand.margin_percent() abort - let res = s:emmet.expand_in_buffer('{m0.1p$$$$}', 'css', '{margin: 0.1%;}') - call s:assert.equals(res, '{margin: 0.1%;}') - endfunction - - function! expand.margin_em() abort - let res = s:emmet.expand_in_buffer('{m1.0$$$$}', 'css', '{margin: 1.0em;}') - call s:assert.equals(res, '{margin: 1.0em;}') - endfunction - - function! expand.margin_px() abort - let res = s:emmet.expand_in_buffer('{m2$$$$}', 'css', '{margin: 2px;}') - call s:assert.equals(res, '{margin: 2px;}') - endfunction - - function! expand.border_radius() abort - let res = s:emmet.expand_in_buffer('{bdrs10$$$$}', 'css', '{border-radius: 10px;}') - call s:assert.equals(res, '{border-radius: 10px;}') - endfunction - - function! expand.vendor_prefix_border_radius() abort - let res = s:emmet.expand_in_buffer('{-bdrs20$$$$}', 'css', "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}") - call s:assert.equals(res, "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}") - endfunction - - function! expand.linear_gradient() abort - let res = s:emmet.expand_in_buffer('{lg(top,#fff,#000)$$$$}', 'css', "{background-image: -webkit-gradient(top, 0 0, 0 100, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}") - call s:assert.equals(res, "{background-image: -webkit-gradient(top, 0 0, 0 100, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}") - endfunction - - function! expand.margin_multi_value() abort - let res = s:emmet.expand_in_buffer('{m10-5-0$$$$}', 'css', '{margin: 10px 5px 0;}') - call s:assert.equals(res, '{margin: 10px 5px 0;}') - endfunction - - function! expand.margin_negative() abort - let res = s:emmet.expand_in_buffer('{m-10--5$$$$}', 'css', '{margin: -10px -5px;}') - call s:assert.equals(res, '{margin: -10px -5px;}') - endfunction - - function! expand.margin_auto() abort - let res = s:emmet.expand_in_buffer('{m10-auto$$$$}', 'css', '{margin: 10px auto;}') - call s:assert.equals(res, '{margin: 10px auto;}') - endfunction - - function! expand.width_percent() abort - let res = s:emmet.expand_in_buffer('{w100p$$$$}', 'css', '{width: 100%;}') - call s:assert.equals(res, '{width: 100%;}') - endfunction - - function! expand.height_em() abort - let res = s:emmet.expand_in_buffer('{h50e$$$$}', 'css', '{height: 50em;}') - call s:assert.equals(res, '{height: 50em;}') - endfunction - - function! expand.multi_property_group() abort - let res = s:emmet.expand_in_buffer('{(bg+)+c$$$$}', 'css', "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}") - call s:assert.equals(res, "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}") - endfunction - - function! expand.multi_property() abort - let res = s:emmet.expand_in_buffer('{m0+bgi+bg++p0$$$$}', 'css', "{margin: 0;\nbackground-image: url($$$$);\nbackground: #fff url() 0 0 no-repeat;\npadding: 0;}") - call s:assert.equals(res, "{margin: 0;\nbackground-image: url($$$$);\nbackground: #fff url() 0 0 no-repeat;\npadding: 0;}") - endfunction - - function! expand.fuzzy_border_left() abort - let res = s:emmet.expand_in_buffer('{borle$$$$}', 'css', '{border-left: $$$$;}') - call s:assert.equals(res, '{border-left: $$$$;}') - endfunction - - function! expand.color_shorthand() abort - let res = s:emmet.expand_in_buffer('{c#dba$$$$}', 'css', '{color: rgb(221, 187, 170);}') - call s:assert.equals(res, '{color: rgb(221, 187, 170);}') - endfunction - - function! expand.color_shorthand_alpha() abort - let res = s:emmet.expand_in_buffer('{c#dba.7$$$$}', 'css', '{color: rgb(221, 187, 170, 0.7);}') - call s:assert.equals(res, '{color: rgb(221, 187, 170, 0.7);}') - endfunction - - function! expand.display_none() abort - let res = s:emmet.expand_in_buffer('{dn$$$$}', 'css', '{display: none;}') - call s:assert.equals(res, '{display: none;}') - endfunction - - function! expand.padding_percent_sign() abort - let res = s:emmet.expand_in_buffer('{p10%$$$$}', 'css', '{padding: 10%;}') - call s:assert.equals(res, '{padding: 10%;}') - endfunction - - function! expand.padding_p_suffix() abort - let res = s:emmet.expand_in_buffer('{p10p$$$$}', 'css', '{padding: 10%;}') - call s:assert.equals(res, '{padding: 10%;}') - endfunction - - function! expand.padding_e_suffix() abort - let res = s:emmet.expand_in_buffer('{p10e$$$$}', 'css', '{padding: 10em;}') - call s:assert.equals(res, '{padding: 10em;}') - endfunction - - function! expand.padding_em_suffix() abort - let res = s:emmet.expand_in_buffer('{p10em$$$$}', 'css', '{padding: 10em;}') - call s:assert.equals(res, '{padding: 10em;}') - endfunction - - function! expand.padding_re_suffix() abort - let res = s:emmet.expand_in_buffer('{p10re$$$$}', 'css', '{padding: 10rem;}') - call s:assert.equals(res, '{padding: 10rem;}') - endfunction - - function! expand.padding_rem_suffix() abort - let res = s:emmet.expand_in_buffer('{p10rem$$$$}', 'css', '{padding: 10rem;}') - call s:assert.equals(res, '{padding: 10rem;}') - endfunction -endfunction diff --git a/test/css.vimspec b/test/css.vimspec new file mode 100644 index 0000000..93e5a09 --- /dev/null +++ b/test/css.vimspec @@ -0,0 +1,144 @@ +Describe css + + Describe expand abbreviation + It expands font-style normal + let res = ExpandInBuffer('{fs:n$$$$}', 'css', '{font-style: normal;}') + Assert Equals(res, '{font-style: normal;}') + End + + It expands float left with fc filter + let res = ExpandInBuffer('{fl:l|fc$$$$}', 'css', '{float: left;}') + Assert Equals(res, '{float: left;}') + End + + It expands background+ + let res = ExpandInBuffer('{bg+$$$$}', 'css', '{background: $$$$#fff url() 0 0 no-repeat;}') + Assert Equals(res, '{background: $$$$#fff url() 0 0 no-repeat;}') + End + + It expands background+ important + let res = ExpandInBuffer('{bg+!$$$$}', 'css', '{background: $$$$#fff url() 0 0 no-repeat !important;}') + Assert Equals(res, '{background: $$$$#fff url() 0 0 no-repeat !important;}') + End + + It expands margin + let res = ExpandInBuffer('{m$$$$}', 'css', '{margin: $$$$;}') + Assert Equals(res, '{margin: $$$$;}') + End + + It expands margin percent + let res = ExpandInBuffer('{m0.1p$$$$}', 'css', '{margin: 0.1%;}') + Assert Equals(res, '{margin: 0.1%;}') + End + + It expands margin em + let res = ExpandInBuffer('{m1.0$$$$}', 'css', '{margin: 1.0em;}') + Assert Equals(res, '{margin: 1.0em;}') + End + + It expands margin px + let res = ExpandInBuffer('{m2$$$$}', 'css', '{margin: 2px;}') + Assert Equals(res, '{margin: 2px;}') + End + + It expands border-radius + let res = ExpandInBuffer('{bdrs10$$$$}', 'css', '{border-radius: 10px;}') + Assert Equals(res, '{border-radius: 10px;}') + End + + It expands vendor prefix border-radius + let res = ExpandInBuffer('{-bdrs20$$$$}', 'css', "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}") + Assert Equals(res, "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}") + End + + It expands linear-gradient + let res = ExpandInBuffer('{lg(top,#fff,#000)$$$$}', 'css', "{background-image: -webkit-gradient(top, 0 0, 0 100%, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}") + Assert Equals(res, "{background-image: -webkit-gradient(top, 0 0, 0 100%, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}") + End + + It expands margin multi value + let res = ExpandInBuffer('{m10-5-0$$$$}', 'css', '{margin: 10px 5px 0;}') + Assert Equals(res, '{margin: 10px 5px 0;}') + End + + It expands margin negative + let res = ExpandInBuffer('{m-10--5$$$$}', 'css', '{margin: -10px -5px;}') + Assert Equals(res, '{margin: -10px -5px;}') + End + + It expands margin auto + let res = ExpandInBuffer('{m10-auto$$$$}', 'css', '{margin: 10px auto;}') + Assert Equals(res, '{margin: 10px auto;}') + End + + It expands width percent + let res = ExpandInBuffer('{w100p$$$$}', 'css', '{width: 100%;}') + Assert Equals(res, '{width: 100%;}') + End + + It expands height em + let res = ExpandInBuffer('{h50e$$$$}', 'css', '{height: 50em;}') + Assert Equals(res, '{height: 50em;}') + End + + It expands multi property group + let res = ExpandInBuffer('{(bg+)+c$$$$}', 'css', "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}") + Assert Equals(res, "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}") + End + + It expands multi property + let res = ExpandInBuffer('{m0+bgi+bg++p0$$$$}', 'css', "{margin: 0;\nbackground-image: url($$$$);\nbackground: #fff url() 0 0 no-repeat;\npadding: 0;}") + Assert Equals(res, "{margin: 0;\nbackground-image: url($$$$);\nbackground: #fff url() 0 0 no-repeat;\npadding: 0;}") + End + + It expands fuzzy border-left + let res = ExpandInBuffer('{borle$$$$}', 'css', '{border-left: $$$$;}') + Assert Equals(res, '{border-left: $$$$;}') + End + + It expands color shorthand + let res = ExpandInBuffer('{c#dba$$$$}', 'css', '{color: rgb(221, 187, 170);}') + Assert Equals(res, '{color: rgb(221, 187, 170);}') + End + + It expands color shorthand with alpha + let res = ExpandInBuffer('{c#dba.7$$$$}', 'css', '{color: rgb(221, 187, 170, 0.7);}') + Assert Equals(res, '{color: rgb(221, 187, 170, 0.7);}') + End + + It expands display none + let res = ExpandInBuffer('{dn$$$$}', 'css', '{display: none;}') + Assert Equals(res, '{display: none;}') + End + + It expands padding with percent sign + let res = ExpandInBuffer('{p10%$$$$}', 'css', '{padding: 10%;}') + Assert Equals(res, '{padding: 10%;}') + End + + It expands padding with p suffix + let res = ExpandInBuffer('{p10p$$$$}', 'css', '{padding: 10%;}') + Assert Equals(res, '{padding: 10%;}') + End + + It expands padding with e suffix + let res = ExpandInBuffer('{p10e$$$$}', 'css', '{padding: 10em;}') + Assert Equals(res, '{padding: 10em;}') + End + + It expands padding with em suffix + let res = ExpandInBuffer('{p10em$$$$}', 'css', '{padding: 10em;}') + Assert Equals(res, '{padding: 10em;}') + End + + It expands padding with re suffix + let res = ExpandInBuffer('{p10re$$$$}', 'css', '{padding: 10rem;}') + Assert Equals(res, '{padding: 10rem;}') + End + + It expands padding with rem suffix + let res = ExpandInBuffer('{p10rem$$$$}', 'css', '{padding: 10rem;}') + Assert Equals(res, '{padding: 10rem;}') + End + End +End diff --git a/test/haml.vim b/test/haml.vim deleted file mode 100644 index d629e5a..0000000 --- a/test/haml.vim +++ /dev/null @@ -1,60 +0,0 @@ -let s:suite = themis#suite('haml') -let s:assert = themis#helper('assert') - -let s:emmet = themis#helper('emmet') - -function! s:suite.__setup() abort - call s:emmet.setup() -endfunction - -function! s:suite.__expand_abbreviation() - let expand = themis#suite('expand abbreviation') - - function! expand.complex() abort - call s:assert.equals(s:emmet.expand_word('div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}', 'haml'), "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n") - endfunction - - function! expand.with_haml_filter() abort - call s:assert.equals(s:emmet.expand_word('div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|haml', 'haml'), "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n") - endfunction - - function! expand.a_multiplier() abort - call s:assert.equals(s:emmet.expand_word('a*3|haml', 'haml'), "%a{ :href => \"\" }\n%a{ :href => \"\" }\n%a{ :href => \"\" }\n") - endfunction - - function! expand.class_with_text() abort - call s:assert.equals(s:emmet.expand_word('.content{Hello!}|haml', 'haml'), "%div.content Hello!\n") - endfunction - - function! expand.title_dollar_hash() abort - call s:assert.equals(s:emmet.expand_word('a[title=$#]{foo}', 'haml'), "%a{ :href => \"\", :title => \"foo\" } foo\n") - endfunction -endfunction - -function! s:suite.__split_join() - let split_join = themis#suite('split join') - - function! split_join.join() abort - let res = s:emmet.expand_in_buffer("%a foo\n bar$$$$\\j$$$$", 'haml', '%a ') - call s:assert.equals(res, '%a ') - endfunction - - function! split_join.split() abort - let res = s:emmet.expand_in_buffer("$$$$\\j$$$$%a ", 'haml', '%a $$$$') - call s:assert.equals(res, '%a $$$$') - endfunction -endfunction - -function! s:suite.__toggle_comment() - let comment = themis#suite('toggle comment') - - function! comment.add() abort - let res = s:emmet.expand_in_buffer('%a{ :href => "http://www.google.com"$$$$\/$$$$ } hello', 'haml', '-# %a{ :href => "http://www.google.com" } hello') - call s:assert.equals(res, '-# %a{ :href => "http://www.google.com" } hello') - endfunction - - function! comment.remove() abort - let res = s:emmet.expand_in_buffer('-# %a{ :href => "http://www.google.com"$$$$\/$$$$ } hello', 'haml', '%a{ :href => "http://www.google.com" } hello') - call s:assert.equals(res, '%a{ :href => "http://www.google.com" } hello') - endfunction -endfunction diff --git a/test/haml.vimspec b/test/haml.vimspec new file mode 100644 index 0000000..cbe1133 --- /dev/null +++ b/test/haml.vimspec @@ -0,0 +1,48 @@ +Describe haml + + Describe expand abbreviation + It expands complex + Assert Equals(ExpandWord('div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}', 'haml'), "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n") + End + + It expands with haml filter + Assert Equals(ExpandWord('div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|haml', 'haml'), "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n") + End + + It expands a multiplier + Assert Equals(ExpandWord('a*3|haml', 'haml'), "%a{ :href => \"\" }\n%a{ :href => \"\" }\n%a{ :href => \"\" }\n") + End + + It expands class with text + Assert Equals(ExpandWord('.content{Hello!}|haml', 'haml'), "%div.content Hello!\n") + End + + It expands title dollar hash + Assert Equals(ExpandWord('a[title=$#]{foo}', 'haml'), "%a{ :href => \"\", :title => \"foo\" } foo\n") + End + End + + Describe split join + It joins + let res = ExpandInBuffer("%a foo\n bar$$$$\\j$$$$", 'haml', '%a ') + Assert Equals(res, '%a ') + End + + It splits + let res = ExpandInBuffer("$$$$\\j$$$$%a ", 'haml', '%a $$$$') + Assert Equals(res, '%a $$$$') + End + End + + Describe toggle comment + It adds comment + let res = ExpandInBuffer('%a{ :href => "http://www.google.com"$$$$\/$$$$ } hello', 'haml', '-# %a{ :href => "http://www.google.com" } hello') + Assert Equals(res, '-# %a{ :href => "http://www.google.com" } hello') + End + + It removes comment + let res = ExpandInBuffer('-# %a{ :href => "http://www.google.com"$$$$\/$$$$ } hello', 'haml', '%a{ :href => "http://www.google.com" } hello') + Assert Equals(res, '%a{ :href => "http://www.google.com" } hello') + End + End +End diff --git a/test/html.vim b/test/html.vim deleted file mode 100644 index 72a703d..0000000 --- a/test/html.vim +++ /dev/null @@ -1,513 +0,0 @@ -let s:suite = themis#suite('html') -let s:assert = themis#helper('assert') - -let s:emmet = themis#helper('emmet') - -function! s:suite.__setup() abort - call s:emmet.setup() -endfunction - -" expand abbreviation {{{ -function! s:suite.__expand_abbreviation() - let expand = themis#suite('expand abbreviation') - - function! expand.div() abort - call s:assert.equals(s:emmet.expand_word('div', 'html'), "
\n") - endfunction - - function! expand.div_id() abort - call s:assert.equals(s:emmet.expand_word('div#wrapper', 'html'), "
\n") - endfunction - - function! expand.div_class() abort - call s:assert.equals(s:emmet.expand_word('div.box', 'html'), "
\n") - endfunction - - function! expand.a_with_title() abort - call s:assert.equals(s:emmet.expand_word('a[title=TITLE]', 'html'), "\n") - endfunction - - function! expand.div_id_class() abort - call s:assert.equals(s:emmet.expand_word('div#wrapper.box', 'html'), "
\n") - endfunction - - function! expand.div_id_multi_class() abort - call s:assert.equals(s:emmet.expand_word('div#wrapper.box.current', 'html'), "
\n") - endfunction - - function! expand.div_id_multi_class_attrs() abort - call s:assert.equals(s:emmet.expand_word('div#wrapper.box.current[title=TITLE rel]', 'html'), "
\n") - endfunction - - function! expand.sibling() abort - call s:assert.equals(s:emmet.expand_word('div#main+div#sub', 'html'), "
\n
\n") - endfunction - - function! expand.child() abort - call s:assert.equals(s:emmet.expand_word('div#main>div#sub', 'html'), "
\n\t
\n
\n") - endfunction - - function! expand.html_xt_complex() abort - call s:assert.equals(s:emmet.expand_word('html:xt>div#header>div#logo+ul#nav>li.item-$*5>a', 'html'), "\n\n\n\t\n\t\n\n\n\t
\n\t\t
\n\t\t
    \n\t\t\t
  • \n\t\t\t
  • \n\t\t\t
  • \n\t\t\t
  • \n\t\t\t
  • \n\t\t
\n\t
\n\t\n\n") - endfunction - - function! expand.ol_li_multiplier() abort - call s:assert.equals(s:emmet.expand_word('ol>li*2', 'html'), "
    \n\t
  1. \n\t
  2. \n
\n") - endfunction - - function! expand.a_default_attr() abort - call s:assert.equals(s:emmet.expand_word('a', 'html'), "\n") - endfunction - - function! expand.obj_alias() abort - call s:assert.equals(s:emmet.expand_word('obj', 'html'), "\n") - endfunction - - function! expand.cc_ie6_complex() abort - call s:assert.equals(s:emmet.expand_word('cc:ie6>p+blockquote#sample$.so.many.classes*2', 'html'), "") - endfunction - - function! expand.html_4t_complex() abort - call s:assert.equals(s:emmet.expand_word('html:4t>div#wrapper>div#header+div#contents+div#footer', 'html'), "\n\n\n\t\n\t\n\n\n\t
\n\t\t
\n\t\t
\n\t\t
\n\t
\n\t\n\n") - endfunction - - function! expand.a_href_class_id() abort - call s:assert.equals(s:emmet.expand_word('a[href=http://www.google.com/].foo#hoge', 'html'), "\n") - endfunction - - function! expand.a_href_text() abort - call s:assert.equals(s:emmet.expand_word('a[href=http://www.google.com/]{Google}', 'html'), "Google\n") - endfunction - - function! expand.text_only() abort - call s:assert.equals(s:emmet.expand_word('{Emmet}', 'html'), 'Emmet') - endfunction - - function! expand.a_plus_b() abort - call s:assert.equals(s:emmet.expand_word('a+b', 'html'), "\n\n") - endfunction - - function! expand.climb_up_lt() abort - call s:assert.equals(s:emmet.expand_word('a>b>i\n") - endfunction - - function! expand.climb_up_caret() abort - call s:assert.equals(s:emmet.expand_word('a>b>i^b', 'html'), "\n") - endfunction - - function! expand.climb_up_double_lt() abort - call s:assert.equals(s:emmet.expand_word('a>b>i<\n\n") - endfunction - - function! expand.climb_up_double_caret() abort - call s:assert.equals(s:emmet.expand_word('a>b>i^^b', 'html'), "\n\n") - endfunction - - function! expand.blockquote_climb_up_lt() abort - call s:assert.equals(s:emmet.expand_word('blockquote>b>i<\n\t\n\n\n") - endfunction - - function! expand.blockquote_climb_up_caret() abort - call s:assert.equals(s:emmet.expand_word('blockquote>b>i^^b', 'html'), "
\n\t\n
\n\n") - endfunction - - function! expand.multi_attr() abort - call s:assert.equals(s:emmet.expand_word('a[href=foo][class=bar]', 'html'), "\n") - endfunction - - function! expand.complex_attrs_multiplier() abort - call s:assert.equals(s:emmet.expand_word('a[a=b][b=c=d][e]{foo}*2', 'html'), "foo\nfoo\n") - endfunction - - function! expand.attrs_multiplier_text_after() abort - call s:assert.equals(s:emmet.expand_word('a[a=b][b=c=d][e]*2{foo}', 'html'), "\n\nfoo") - endfunction - - function! expand.multiplier_text_tag() abort - call s:assert.equals(s:emmet.expand_word('a*2{foo}a', 'html'), "\n\nfoo\n") - endfunction - - function! expand.text_multiplier_child() abort - call s:assert.equals(s:emmet.expand_word('a{foo}*2>b', 'html'), "foo\nfoo\n") - endfunction - - function! expand.multiplier_text_child() abort - call s:assert.equals(s:emmet.expand_word('a*2{foo}>b', 'html'), "\n\nfoo") - endfunction - - function! expand.table_complex() abort - call s:assert.equals(s:emmet.expand_word('table>tr>td.name#foo+td*3', 'html'), "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n
\n") - endfunction - - function! expand.sibling_ids() abort - call s:assert.equals(s:emmet.expand_word('div#header+div#footer', 'html'), "
\n
\n") - endfunction - - function! expand.implicit_div_sibling() abort - call s:assert.equals(s:emmet.expand_word('#header+div#footer', 'html'), "
\n
\n") - endfunction - - function! expand.climb_up_with_text_lt() abort - call s:assert.equals(s:emmet.expand_word('#header>ul>li\n\t
    \n\t\t
  • \n\t
\n\t

Footer

\n\n") - endfunction - - function! expand.climb_up_with_text_caret() abort - call s:assert.equals(s:emmet.expand_word('#header>ul>li^p{Footer}', 'html'), "
\n\t
    \n\t\t
  • \n\t
\n\t

Footer

\n
\n") - endfunction - - function! expand.dollar_padding() abort - call s:assert.equals(s:emmet.expand_word('a#foo$$$*3', 'html'), "\n\n\n") - endfunction - - function! expand.ul_expando() abort - call s:assert.equals(s:emmet.expand_word('ul+', 'html'), "
    \n\t
  • \n
\n") - endfunction - - function! expand.table_expando() abort - call s:assert.equals(s:emmet.expand_word('table+', 'html'), "\n\t\n\t\t\n\t\n
\n") - endfunction - - function! expand.header_climb_content_lt() abort - call s:assert.equals(s:emmet.expand_word('#header>li<#content', 'html'), "
\n\t
  • \n
    \n
    \n") - endfunction - - function! expand.header_climb_content_caret() abort - call s:assert.equals(s:emmet.expand_word('#header>li^#content', 'html'), "
    \n\t
  • \n
    \n
    \n") - endfunction - - function! expand.group_climb_lt() abort - call s:assert.equals(s:emmet.expand_word('(#header>li)<#content', 'html'), "
    \n\t
  • \n
    \n
    \n") - endfunction - - function! expand.group_climb_caret() abort - call s:assert.equals(s:emmet.expand_word('(#header>li)^#content', 'html'), "
    \n\t
  • \n
    \n
    \n") - endfunction - - function! expand.double_climb_lt() abort - call s:assert.equals(s:emmet.expand_word('a>b>i<\n
    \n") - endfunction - - function! expand.double_climb_caret() abort - call s:assert.equals(s:emmet.expand_word('a>b>i^^div', 'html'), "\n
    \n") - endfunction - - function! expand.group_sibling() abort - call s:assert.equals(s:emmet.expand_word('(#header>h1)+#content+#footer', 'html'), "
    \n\t

    \n
    \n
    \n
    \n") - endfunction - - function! expand.complex_nested_groups() abort - call s:assert.equals(s:emmet.expand_word('(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)', 'html'), "
    \n\t

    \n
    \n
    \n\t
    \n\t\t

    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t
    \n\t
    \n
    \n
    \n\t
    \n
    \n") - endfunction - - function! expand.nested_multiplier_groups() abort - call s:assert.equals(s:emmet.expand_word('(div>(ul*2)*2)+(#utilities)', 'html'), "
    \n\t
      \n\t
        \n\t
          \n\t
            \n
            \n
            \n") - endfunction - - function! expand.table_multiplier_group() abort - call s:assert.equals(s:emmet.expand_word('table>(tr>td*3)*4', 'html'), "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n
            \n") - endfunction - - function! expand.nested_multiplier_groups_deep() abort - call s:assert.equals(s:emmet.expand_word('(((a#foo+a#bar)*2)*3)', 'html'), "\n\n\n\n\n\n\n\n\n\n\n\n") - endfunction - - function! expand.multiplier_with_child() abort - call s:assert.equals(s:emmet.expand_word('div#box$*3>h3+p*2', 'html'), "
            \n\t

            \n\t

            \n\t

            \n
            \n
            \n\t

            \n\t

            \n\t

            \n
            \n
            \n\t

            \n\t

            \n\t

            \n
            \n") - endfunction - - function! expand.dollar_multi_class() abort - call s:assert.equals(s:emmet.expand_word('div#box.foo$$$.bar$$$*3', 'html'), "
            \n
            \n
            \n") - endfunction - - function! expand.escape_filter() abort - call s:assert.equals(s:emmet.expand_word('div#box$*3>h3+p.bar*2|e', 'html'), "<div id=\"box1\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n<div id=\"box2\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n<div id=\"box3\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n") - endfunction - - function! expand.comment_filter() abort - call s:assert.equals(s:emmet.expand_word('div>div#page>p.title+p|c', 'html'), "
            \n\t\n\t
            \n\t\t\n\t\t

            \n\t\t\n\t\t

            \n\t
            \n\t\n
            \n") - endfunction - - function! expand.single_line_filter() abort - call s:assert.equals(s:emmet.expand_word('kbd*2|s', 'html'), '') - endfunction - - function! expand.link_css() abort - call s:assert.equals(s:emmet.expand_word('link:css', 'html'), "\n") - endfunction - - function! expand.attr_with_quote() abort - call s:assert.equals(s:emmet.expand_word("a[title=\"Hello', world\" rel]", 'html'), "\n") - endfunction - - function! expand.child_with_text() abort - call s:assert.equals(s:emmet.expand_word('div>a#foo{bar}', 'html'), "\n") - endfunction - - function! expand.class_with_text() abort - call s:assert.equals(s:emmet.expand_word('.content{Hello!}', 'html'), "
            Hello!
            \n") - endfunction - - function! expand.logo_group_siblings() abort - call s:assert.equals(s:emmet.expand_word('div.logo+(div#navigation)+(div#links)', 'html'), "
            \n
            \n
            \n") - endfunction - - function! expand.mixed_text_and_tags() abort - call s:assert.equals(s:emmet.expand_word('h1{header}+{Text}+a[href=http://link.org]{linktext}+{again some text}+a[href=http://anoterlink.org]{click me!}+{some final text}', 'html'), "

            header

            \nTextlinktext\nagain some textclick me!\nsome final text") - endfunction - - function! expand.ampersand_text() abort - call s:assert.equals(s:emmet.expand_word('a{&}+div{&&}', 'html'), "&\n
            &&
            \n") - endfunction - - function! expand.span_after_tag() abort - let res = s:emmet.expand_in_buffer('span$$$$\,$$$$', 'html', '') - call s:assert.equals(res, '') - endfunction - - function! expand.span_after_text() abort - let res = s:emmet.expand_in_buffer('foo span$$$$\,$$$$', 'html', 'foo ') - call s:assert.equals(res, 'foo ') - endfunction - - function! expand.span_after_text_before_text() abort - let res = s:emmet.expand_in_buffer('foo span$$$$\,$$$$ bar', 'html', 'foo bar') - call s:assert.equals(res, 'foo bar') - endfunction - - function! expand.visual_word_wrap() abort - let res = s:emmet.expand_in_buffer("foo $$$$\\ve\\,p\\$$$$bar baz", 'html', 'foo

            bar

            baz') - call s:assert.equals(res, 'foo

            bar

            baz') - endfunction - - function! expand.visual_multi_word_wrap() abort - let res = s:emmet.expand_in_buffer("foo $$$$\\vee\\,p\\$$$$bar baz", 'html', 'foo

            bar baz

            ') - call s:assert.equals(res, 'foo

            bar baz

            ') - endfunction - - function! expand.complex_nested() abort - let res = s:emmet.expand_in_buffer("f div.boxes>article.box2>header>(hgroup>h2{aaa}+h3{bbb})+p{ccc}$$$$", 'html', "f
            \n\t
            \n\t\t
            \n\t\t\t
            \n\t\t\t\t

            aaa

            \n\t\t\t\t

            bbb

            \n\t\t\t
            \n\t\t\t

            ccc

            \n\t\t
            \n\t
            \n
            ") - call s:assert.equals(res, "f
            \n\t
            \n\t\t
            \n\t\t\t
            \n\t\t\t\t

            aaa

            \n\t\t\t\t

            bbb

            \n\t\t\t
            \n\t\t\t

            ccc

            \n\t\t
            \n\t
            \n
            ") - endfunction - - function! expand.complex_boxes() abort - call s:assert.equals(s:emmet.expand_word("div.boxes>(div.box2>section>h2{a}+p{b})+(div.box1>section>h2{c}+p{d}+p{e}+(bq>h2{f}+h3{g})+p{h})", 'html'), "
            \n\t
            \n\t\t
            \n\t\t\t

            a

            \n\t\t\t

            b

            \n\t\t
            \n\t
            \n\t
            \n\t\t
            \n\t\t\t

            c

            \n\t\t\t

            d

            \n\t\t\t

            e

            \n\t\t\t
            \n\t\t\t\t

            f

            \n\t\t\t\t

            g

            \n\t\t\t
            \n\t\t\t

            h

            \n\t\t
            \n\t
            \n
            \n") - endfunction - - function! expand.label_input_group() abort - call s:assert.equals(s:emmet.expand_word('(div>(label+input))+div', 'html'), "
            \n\t\n\t\n
            \n
            \n") - endfunction - - function! expand.visual_wrap_multiplier() abort - let res = s:emmet.expand_in_buffer("test1\ntest2\ntest3$$$$\\ggVG\\,ul>li>span*>a\\$$$$", 'html', "") - call s:assert.equals(res, "") - endfunction - - function! expand.visual_wrap_input() abort - let res = s:emmet.expand_in_buffer("test1\ntest2\ntest3$$$$\\ggVG\\,input[type=input value=$#]*\\$$$$", 'html', "\n\n") - call s:assert.equals(res, "\n\n") - endfunction - - function! expand.visual_wrap_div_id() abort - let res = s:emmet.expand_in_buffer("test1\ntest2\ntest3$$$$\\ggVG\\,div[id=$#]*\\$$$$", 'html', "
            \n
            \n
            ") - call s:assert.equals(res, "
            \n
            \n
            ") - endfunction - - function! expand.nested_id_dollar() abort - call s:assert.equals(s:emmet.expand_word('div#id-$*5>div#id2-$', 'html'), "
            \n\t
            \n
            \n
            \n\t
            \n
            \n
            \n\t
            \n
            \n
            \n\t
            \n
            \n
            \n\t
            \n
            \n") - endfunction - - function! expand.implicit_child_attr() abort - call s:assert.equals(s:emmet.expand_word('.foo>[bar=2]>.baz', 'html'), "
            \n\t
            \n\t\t
            \n\t
            \n
            \n") - endfunction - - function! expand.text_dollar() abort - call s:assert.equals(s:emmet.expand_word('{test case $ }*3', 'html'), 'test case 1 test case 2 test case 3 ') - endfunction - - function! expand.text_dollar_newline() abort - call s:assert.equals(s:emmet.expand_word('{test case $${nr}}*3', 'html'), "test case 1\ntest case 2\ntest case 3\n") - endfunction - - function! expand.text_escaped_dollar() abort - call s:assert.equals(s:emmet.expand_word('{test case \$ }*3', 'html'), 'test case $ test case $ test case $ ') - endfunction - - function! expand.text_dollar_padding() abort - call s:assert.equals(s:emmet.expand_word('{test case $$$ }*3', 'html'), 'test case 001 test case 002 test case 003 ') - endfunction - - function! expand.title_dollar_hash() abort - call s:assert.equals(s:emmet.expand_word('a[title=$#]{foo}', 'html'), "foo\n") - endfunction - - function! expand.span_item_dollar_text() abort - call s:assert.equals(s:emmet.expand_word('span.item$*2>{item $}', 'html'), "item 1\nitem 2\n") - endfunction - - function! expand.visual_wrap_indented() abort - let res = s:emmet.expand_in_buffer("\t
            \n\t\tnav link\n\t
            $$$$\\ggVG\\,div\\$$$$", 'html', "\t
            \n\t\t
            \n\t\t\tnav link\n\t\t
            \n\t
            ") - call s:assert.equals(res, "\t
            \n\t\t
            \n\t\t\tnav link\n\t\t
            \n\t
            ") - endfunction - - function! expand.expand_inside_tag() abort - let res = s:emmet.expand_in_buffer('a$$$$', 'html', '') - call s:assert.equals(res, '') - endfunction - - function! expand.bem_filter() abort - call s:assert.equals(s:emmet.expand_word('form.search-form._wide>input.-query-string+input:s.-btn_large|bem', 'html'), "
            \n\t\n\t\n
            \n") - endfunction - - function! expand.fieldset_legend_label() abort - call s:assert.equals(s:emmet.expand_word('form>fieldset>legend+(label>input[type="checkbox"])*3', 'html'), "
            \n\t
            \n\t\t\n\t\t\n\t\t\n\t\t\n\t
            \n
            \n") - endfunction -endfunction -" }}} - -" split join tag {{{ -function! s:suite.__split_join_tag() - let split_join = themis#suite('split join tag') - - function! split_join.join_tag() abort - let res = s:emmet.expand_in_buffer("
            \n\t$$$$\\j$$$$\n
            ", 'html', "
            \n\t\n
            ") - call s:assert.equals(res, "
            \n\t\n
            ") - endfunction - - function! split_join.split_tag() abort - let res = s:emmet.expand_in_buffer("
            \n\tj$$$$/>\n
            ", 'html', "
            \n\t\n
            ") - call s:assert.equals(res, "
            \n\t\n
            ") - endfunction - - function! split_join.join_with_complex_attr() abort - let res = s:emmet.expand_in_buffer("
            500)\">test$$$$\\j$$$$/>\n
            ", 'html', '
            ') - call s:assert.equals(res, '
            ') - endfunction - - function! split_join.split_custom_tag() abort - let res = s:emmet.expand_in_buffer("
            \n\tj$$$$/>\n
            ", 'html', "
            \n\t\n
            ") - call s:assert.equals(res, "
            \n\t\n
            ") - endfunction -endfunction -" }}} - -" toggle comment {{{ -function! s:suite.__toggle_comment() - let comment = themis#suite('toggle comment') - - function! comment.add_comment() abort - let res = s:emmet.expand_in_buffer("
            \n\t$$$$\\/$$$$\n
            ", 'html', "
            \n\t\n
            ") - call s:assert.equals(res, "
            \n\t\n
            ") - endfunction - - function! comment.remove_comment() abort - let res = s:emmet.expand_in_buffer("
            \n\t\n
            ", 'html', "
            \n\t\n
            ") - call s:assert.equals(res, "
            \n\t\n
            ") - endfunction -endfunction -" }}} - -" image size {{{ -function! s:suite.__image_size() - let imgsize = themis#suite('image size') - - function! imgsize.remote_png() abort - let res = s:emmet.expand_in_buffer("img[src=http://mattn.kaoriya.net/images/logo.png]$$$$\\,\\i$$$$", 'html', '') - call s:assert.equals(res, '') - endfunction - - function! imgsize.local_missing() abort - let res = s:emmet.expand_in_buffer("img[src=/logo.png]$$$$\\,\\i$$$$", 'html', '') - call s:assert.equals(res, '') - endfunction - - function! imgsize.overwrite_existing() abort - let res = s:emmet.expand_in_buffer("img[src=http://mattn.kaoriya.net/images/logo.png width=foo height=bar]$$$$\\,\\i$$$$", 'html', '') - call s:assert.equals(res, '') - endfunction -endfunction -" }}} - -" move next prev {{{ -function! s:suite.__move_next_prev() - let move = themis#suite('move next prev') - - function! move.move_to_third_attr() abort - let res = s:emmet.expand_in_buffer("foo+bar+baz[dankogai=\"\"]$$$$\\,\\gg0\\n\\n\\n\\Byw:%d _\\p$$$$", 'html', 'dankogai') - call s:assert.equals(res, 'dankogai') - endfunction -endfunction -" }}} - -" contains dash in attributes {{{ -function! s:suite.__dash_in_attributes() - let dash = themis#suite('contains dash in attributes') - - function! dash.foo_bar_attr() abort - call s:assert.equals(s:emmet.expand_word('div[foo-bar="baz"]', 'html'), "
            \n") - endfunction -endfunction -" }}} - -" default attributes {{{ -function! s:suite.__default_attributes() - let defattr = themis#suite('default attributes') - - function! defattr.a_href_shorthand() abort - call s:assert.equals(s:emmet.expand_word('p.title>a[/hoge/]', 'html'), "

            \n") - endfunction - - function! defattr.script_src() abort - call s:assert.equals(s:emmet.expand_word('script[jquery.js]', 'html'), "\n") - endfunction -endfunction -" }}} - -" multiple group {{{ -function! s:suite.__multiple_group() - let group = themis#suite('multiple group') - - function! group.outer_inner() abort - call s:assert.equals(s:emmet.expand_word('.outer$*3>.inner$*2', 'html'), "
            \n\t
            \n\t
            \n
            \n
            \n\t
            \n\t
            \n
            \n
            \n\t
            \n\t
            \n
            \n") - endfunction -endfunction -" }}} - -" group itemno {{{ -function! s:suite.__group_itemno() - let itemno = themis#suite('group itemno') - - function! itemno.dl_dt_dd() abort - call s:assert.equals(s:emmet.expand_word('dl>(dt{$}+dd)*3', 'html'), "
            \n\t
            1
            \n\t
            \n\t
            2
            \n\t
            \n\t
            3
            \n\t
            \n
            \n") - endfunction - - function! itemno.nested_multiplier() abort - call s:assert.equals(s:emmet.expand_word('(div[attr=$]*3)*3', 'html'), "
            \n
            \n
            \n
            \n
            \n
            \n
            \n
            \n
            \n") - endfunction -endfunction -" }}} - -" update tag {{{ -function! s:suite.__update_tag() - let update = themis#suite('update tag') - - function! update.add_class() abort - let res = s:emmet.expand_in_buffer("u.global\\$$$$3>", 'html', '

            ') - call s:assert.equals(res, '

            ') - endfunction - - function! update.add_class_preserve_attr() abort - let res = s:emmet.expand_in_buffer("u.btn\\$$$$ disabled>", 'html', '') - call s:assert.equals(res, '') - endfunction -endfunction -" }}} - -" base value {{{ -function! s:suite.__base_value() - let base = themis#suite('base value') - - function! base.base_zero() abort - call s:assert.equals(s:emmet.expand_word('ul>li#id$@0*3', 'html'), "
              \n\t
            • \n\t
            • \n\t
            • \n
            \n") - endfunction -endfunction -" }}} diff --git a/test/html.vimspec b/test/html.vimspec new file mode 100644 index 0000000..fd1b3ff --- /dev/null +++ b/test/html.vimspec @@ -0,0 +1,463 @@ +Describe html + + Describe expand abbreviation + It expands div + Assert Equals(ExpandWord('div', 'html'), "
            \n") + End + + It expands div with id + Assert Equals(ExpandWord('div#wrapper', 'html'), "
            \n") + End + + It expands div with class + Assert Equals(ExpandWord('div.box', 'html'), "
            \n") + End + + It expands a with title attribute + Assert Equals(ExpandWord('a[title=TITLE]', 'html'), "\n") + End + + It expands div with id and class + Assert Equals(ExpandWord('div#wrapper.box', 'html'), "
            \n") + End + + It expands div with id and multiple classes + Assert Equals(ExpandWord('div#wrapper.box.current', 'html'), "
            \n") + End + + It expands div with id, classes and attributes + Assert Equals(ExpandWord('div#wrapper.box.current[title=TITLE rel]', 'html'), "
            \n") + End + + It expands sibling divs + Assert Equals(ExpandWord('div#main+div#sub', 'html'), "
            \n
            \n") + End + + It expands child div + Assert Equals(ExpandWord('div#main>div#sub', 'html'), "
            \n\t
            \n
            \n") + End + + It expands html:xt complex + Assert Equals(ExpandWord('html:xt>div#header>div#logo+ul#nav>li.item-$*5>a', 'html'), "\n\n\n\t\n\t\n\n\n\t
            \n\t\t
            \n\t\t
              \n\t\t\t
            • \n\t\t\t
            • \n\t\t\t
            • \n\t\t\t
            • \n\t\t\t
            • \n\t\t
            \n\t
            \n\t\n\n") + End + + It expands ol with li multiplier + Assert Equals(ExpandWord('ol>li*2', 'html'), "
              \n\t
            1. \n\t
            2. \n
            \n") + End + + It expands a with default attribute + Assert Equals(ExpandWord('a', 'html'), "\n") + End + + It expands obj alias + Assert Equals(ExpandWord('obj', 'html'), "\n") + End + + It expands cc:ie6 complex + Assert Equals(ExpandWord('cc:ie6>p+blockquote#sample$.so.many.classes*2', 'html'), "") + End + + It expands html:4t complex + Assert Equals(ExpandWord('html:4t>div#wrapper>div#header+div#contents+div#footer', 'html'), "\n\n\n\t\n\t\n\n\n\t
            \n\t\t
            \n\t\t
            \n\t\t
            \n\t
            \n\t\n\n") + End + + It expands a with href, class and id + Assert Equals(ExpandWord('a[href=http://www.google.com/].foo#hoge', 'html'), "\n") + End + + It expands a with href and text + Assert Equals(ExpandWord('a[href=http://www.google.com/]{Google}', 'html'), "Google\n") + End + + It expands text only + Assert Equals(ExpandWord('{Emmet}', 'html'), 'Emmet') + End + + It expands a+b + Assert Equals(ExpandWord('a+b', 'html'), "\n\n") + End + + It climbs up with < + Assert Equals(ExpandWord('a>b>i\n") + End + + It climbs up with ^ + Assert Equals(ExpandWord('a>b>i^b', 'html'), "\n") + End + + It climbs up double with << + Assert Equals(ExpandWord('a>b>i<\n\n") + End + + It climbs up double with ^^ + Assert Equals(ExpandWord('a>b>i^^b', 'html'), "\n\n") + End + + It climbs up blockquote with << + Assert Equals(ExpandWord('blockquote>b>i<\n\t\n\n\n") + End + + It climbs up blockquote with ^^ + Assert Equals(ExpandWord('blockquote>b>i^^b', 'html'), "
            \n\t\n
            \n\n") + End + + It expands multiple attributes + Assert Equals(ExpandWord('a[href=foo][class=bar]', 'html'), "\n") + End + + It expands complex attrs with multiplier + Assert Equals(ExpandWord('a[a=b][b=c=d][e]{foo}*2', 'html'), "foo\nfoo\n") + End + + It expands attrs multiplier text after + Assert Equals(ExpandWord('a[a=b][b=c=d][e]*2{foo}', 'html'), "\n\nfoo") + End + + It expands multiplier text tag + Assert Equals(ExpandWord('a*2{foo}a', 'html'), "\n\nfoo\n") + End + + It expands text multiplier child + Assert Equals(ExpandWord('a{foo}*2>b', 'html'), "foo\nfoo\n") + End + + It expands multiplier text child + Assert Equals(ExpandWord('a*2{foo}>b', 'html'), "\n\nfoo") + End + + It expands table complex + Assert Equals(ExpandWord('table>tr>td.name#foo+td*3', 'html'), "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n
            \n") + End + + It expands sibling ids + Assert Equals(ExpandWord('div#header+div#footer', 'html'), "
            \n
            \n") + End + + It expands implicit div sibling + Assert Equals(ExpandWord('#header+div#footer', 'html'), "
            \n
            \n") + End + + It climbs up with text using < + Assert Equals(ExpandWord('#header>ul>li\n\t
              \n\t\t
            • \n\t
            \n\t

            Footer

            \n
            \n") + End + + It climbs up with text using ^ + Assert Equals(ExpandWord('#header>ul>li^p{Footer}', 'html'), "
            \n\t
              \n\t\t
            • \n\t
            \n\t

            Footer

            \n
            \n") + End + + It expands dollar padding + Assert Equals(ExpandWord('a#foo$$$*3', 'html'), "\n\n\n") + End + + It expands ul expando + Assert Equals(ExpandWord('ul+', 'html'), "
              \n\t
            • \n
            \n") + End + + It expands table expando + Assert Equals(ExpandWord('table+', 'html'), "\n\t\n\t\t\n\t\n
            \n") + End + + It climbs header to content with < + Assert Equals(ExpandWord('#header>li<#content', 'html'), "
            \n\t
          • \n
            \n
            \n") + End + + It climbs header to content with ^ + Assert Equals(ExpandWord('#header>li^#content', 'html'), "
            \n\t
          • \n
            \n
            \n") + End + + It climbs group with < + Assert Equals(ExpandWord('(#header>li)<#content', 'html'), "
            \n\t
          • \n
            \n
            \n") + End + + It climbs group with ^ + Assert Equals(ExpandWord('(#header>li)^#content', 'html'), "
            \n\t
          • \n
            \n
            \n") + End + + It climbs double to div with << + Assert Equals(ExpandWord('a>b>i<\n
            \n") + End + + It climbs double to div with ^^ + Assert Equals(ExpandWord('a>b>i^^div', 'html'), "\n
            \n") + End + + It expands group siblings + Assert Equals(ExpandWord('(#header>h1)+#content+#footer', 'html'), "
            \n\t

            \n
            \n
            \n
            \n") + End + + It expands complex nested groups + Assert Equals(ExpandWord('(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)', 'html'), "
            \n\t

            \n
            \n
            \n\t
            \n\t\t

            \n\t\t
            \n\t\t\t

            \n\t\t\t
            \n\t\t\t\t

            \n\t\t\t\t

            \n\t\t\t\t

            \n\t\t\t\t
              \n\t\t\t\t\t
            • \n\t\t\t\t
            \n\t\t\t
            \n\t\t
            \n\t\t
            \n\t\t\t

            \n\t\t\t
            \n\t\t\t\t

            \n\t\t\t\t

            \n\t\t\t\t

            \n\t\t\t\t
              \n\t\t\t\t\t
            • \n\t\t\t\t
            \n\t\t\t
            \n\t\t
            \n\t\t
            \n\t\t\t

            \n\t\t\t
            \n\t\t\t\t

            \n\t\t\t\t

            \n\t\t\t\t

            \n\t\t\t\t
              \n\t\t\t\t\t
            • \n\t\t\t\t
            \n\t\t\t
            \n\t\t
            \n\t\t
            \n\t\t\t

            \n\t\t\t
            \n\t\t\t\t

            \n\t\t\t\t

            \n\t\t\t\t

            \n\t\t\t\t
              \n\t\t\t\t\t
            • \n\t\t\t\t
            \n\t\t\t
            \n\t\t
            \n\t\t
            \n\t\t\t

            \n\t\t\t
            \n\t\t\t\t

            \n\t\t\t\t

            \n\t\t\t\t

            \n\t\t\t\t
              \n\t\t\t\t\t
            • \n\t\t\t\t
            \n\t\t\t
            \n\t\t
            \n\t
            \n\t
            \n
            \n
            \n\t
            \n
            \n") + End + + It expands nested multiplier groups + Assert Equals(ExpandWord('(div>(ul*2)*2)+(#utilities)', 'html'), "
            \n\t
              \n\t
                \n\t
                  \n\t
                    \n
                    \n
                    \n") + End + + It expands table multiplier group + Assert Equals(ExpandWord('table>(tr>td*3)*4', 'html'), "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n
                    \n") + End + + It expands deep nested multiplier groups + Assert Equals(ExpandWord('(((a#foo+a#bar)*2)*3)', 'html'), "\n\n\n\n\n\n\n\n\n\n\n\n") + End + + It expands multiplier with child + Assert Equals(ExpandWord('div#box$*3>h3+p*2', 'html'), "
                    \n\t

                    \n\t

                    \n\t

                    \n
                    \n
                    \n\t

                    \n\t

                    \n\t

                    \n
                    \n
                    \n\t

                    \n\t

                    \n\t

                    \n
                    \n") + End + + It expands dollar multi class + Assert Equals(ExpandWord('div#box.foo$$$.bar$$$*3', 'html'), "
                    \n
                    \n
                    \n") + End + + It applies escape filter + Assert Equals(ExpandWord('div#box$*3>h3+p.bar*2|e', 'html'), "<div id=\"box1\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n<div id=\"box2\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n<div id=\"box3\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n") + End + + It applies comment filter + Assert Equals(ExpandWord('div>div#page>p.title+p|c', 'html'), "
                    \n\t\n\t
                    \n\t\t\n\t\t

                    \n\t\t\n\t\t

                    \n\t
                    \n\t\n
                    \n") + End + + It applies single line filter + Assert Equals(ExpandWord('kbd*2|s', 'html'), '') + End + + It expands link:css + Assert Equals(ExpandWord('link:css', 'html'), "\n") + End + + It expands attribute with quote + Assert Equals(ExpandWord("a[title=\"Hello', world\" rel]", 'html'), "\n") + End + + It expands child with text + Assert Equals(ExpandWord('div>a#foo{bar}', 'html'), "\n") + End + + It expands class with text + Assert Equals(ExpandWord('.content{Hello!}', 'html'), "
                    Hello!
                    \n") + End + + It expands logo group siblings + Assert Equals(ExpandWord('div.logo+(div#navigation)+(div#links)', 'html'), "
                    \n
                    \n
                    \n") + End + + It expands mixed text and tags + Assert Equals(ExpandWord('h1{header}+{Text}+a[href=http://link.org]{linktext}+{again some text}+a[href=http://anoterlink.org]{click me!}+{some final text}', 'html'), "

                    header

                    \nTextlinktext\nagain some textclick me!\nsome final text") + End + + It expands ampersand text + Assert Equals(ExpandWord('a{&}+div{&&}', 'html'), "&\n
                    &&
                    \n") + End + + It expands span after tag in buffer + let res = ExpandInBuffer('span$$$$\,$$$$', 'html', '') + Assert Equals(res, '') + End + + It expands span after text in buffer + let res = ExpandInBuffer('foo span$$$$\,$$$$', 'html', 'foo ') + Assert Equals(res, 'foo ') + End + + It expands span between text in buffer + let res = ExpandInBuffer('foo span$$$$\,$$$$ bar', 'html', 'foo bar') + Assert Equals(res, 'foo bar') + End + + It wraps visual word + let res = ExpandInBuffer("foo $$$$\\ve\\,p\\$$$$bar baz", 'html', 'foo

                    bar

                    baz') + Assert Equals(res, 'foo

                    bar

                    baz') + End + + It wraps visual multi word + let res = ExpandInBuffer("foo $$$$\\vee\\,p\\$$$$bar baz", 'html', 'foo

                    bar baz

                    ') + Assert Equals(res, 'foo

                    bar baz

                    ') + End + + It expands complex nested in buffer + let res = ExpandInBuffer("f div.boxes>article.box2>header>(hgroup>h2{aaa}+h3{bbb})+p{ccc}$$$$", 'html', "f
                    \n\t
                    \n\t\t
                    \n\t\t\t
                    \n\t\t\t\t

                    aaa

                    \n\t\t\t\t

                    bbb

                    \n\t\t\t
                    \n\t\t\t

                    ccc

                    \n\t\t
                    \n\t
                    \n
                    ") + Assert Equals(res, "f
                    \n\t
                    \n\t\t
                    \n\t\t\t
                    \n\t\t\t\t

                    aaa

                    \n\t\t\t\t

                    bbb

                    \n\t\t\t
                    \n\t\t\t

                    ccc

                    \n\t\t
                    \n\t
                    \n
                    ") + End + + It expands complex boxes + Assert Equals(ExpandWord("div.boxes>(div.box2>section>h2{a}+p{b})+(div.box1>section>h2{c}+p{d}+p{e}+(bq>h2{f}+h3{g})+p{h})", 'html'), "
                    \n\t
                    \n\t\t
                    \n\t\t\t

                    a

                    \n\t\t\t

                    b

                    \n\t\t
                    \n\t
                    \n\t
                    \n\t\t
                    \n\t\t\t

                    c

                    \n\t\t\t

                    d

                    \n\t\t\t

                    e

                    \n\t\t\t
                    \n\t\t\t\t

                    f

                    \n\t\t\t\t

                    g

                    \n\t\t\t
                    \n\t\t\t

                    h

                    \n\t\t
                    \n\t
                    \n
                    \n") + End + + It expands label input group + Assert Equals(ExpandWord('(div>(label+input))+div', 'html'), "
                    \n\t\n\t\n
                    \n
                    \n") + End + + It wraps visual lines with multiplier + let res = ExpandInBuffer("test1\ntest2\ntest3$$$$\\ggVG\\,ul>li>span*>a\\$$$$", 'html', "") + Assert Equals(res, "") + End + + It wraps visual lines with input + let res = ExpandInBuffer("test1\ntest2\ntest3$$$$\\ggVG\\,input[type=input value=$#]*\\$$$$", 'html', "\n\n") + Assert Equals(res, "\n\n") + End + + It wraps visual lines with div id + let res = ExpandInBuffer("test1\ntest2\ntest3$$$$\\ggVG\\,div[id=$#]*\\$$$$", 'html', "
                    \n
                    \n
                    ") + Assert Equals(res, "
                    \n
                    \n
                    ") + End + + It expands nested id dollar + Assert Equals(ExpandWord('div#id-$*5>div#id2-$', 'html'), "
                    \n\t
                    \n
                    \n
                    \n\t
                    \n
                    \n
                    \n\t
                    \n
                    \n
                    \n\t
                    \n
                    \n
                    \n\t
                    \n
                    \n") + End + + It expands implicit child attr + Assert Equals(ExpandWord('.foo>[bar=2]>.baz', 'html'), "
                    \n\t
                    \n\t\t
                    \n\t
                    \n
                    \n") + End + + It expands text dollar + Assert Equals(ExpandWord('{test case $ }*3', 'html'), 'test case 1 test case 2 test case 3 ') + End + + It expands text dollar newline + Assert Equals(ExpandWord('{test case $${nr}}*3', 'html'), "test case 1\ntest case 2\ntest case 3\n") + End + + It expands text escaped dollar + Assert Equals(ExpandWord('{test case \$ }*3', 'html'), 'test case $ test case $ test case $ ') + End + + It expands text dollar padding + Assert Equals(ExpandWord('{test case $$$ }*3', 'html'), 'test case 001 test case 002 test case 003 ') + End + + It expands title dollar hash + Assert Equals(ExpandWord('a[title=$#]{foo}', 'html'), "foo\n") + End + + It expands span item dollar text + Assert Equals(ExpandWord('span.item$*2>{item $}', 'html'), "item 1\nitem 2\n") + End + + It wraps visual indented block + let res = ExpandInBuffer("\t
                    \n\t\tnav link\n\t
                    $$$$\\ggVG\\,div\\$$$$", 'html', "\t
                    \n\t\t
                    \n\t\t\tnav link\n\t\t
                    \n\t
                    ") + Assert Equals(res, "\t
                    \n\t\t
                    \n\t\t\tnav link\n\t\t
                    \n\t
                    ") + End + + It expands inside tag + let res = ExpandInBuffer('a$$$$', 'html', '') + Assert Equals(res, '') + End + + It applies BEM filter + Assert Equals(ExpandWord('form.search-form._wide>input.-query-string+input:s.-btn_large|bem', 'html'), "
                    \n\t\n\t\n
                    \n") + End + + It expands fieldset legend label + Assert Equals(ExpandWord('form>fieldset>legend+(label>input[type="checkbox"])*3', 'html'), "
                    \n\t
                    \n\t\t\n\t\t\n\t\t\n\t\t\n\t
                    \n
                    \n") + End + End + + Describe split join tag + It joins tag + let res = ExpandInBuffer("
                    \n\t$$$$\\j$$$$\n
                    ", 'html', "
                    \n\t\n
                    ") + Assert Equals(res, "
                    \n\t\n
                    ") + End + + It splits tag + let res = ExpandInBuffer("
                    \n\tj$$$$/>\n
                    ", 'html', "
                    \n\t\n
                    ") + Assert Equals(res, "
                    \n\t\n
                    ") + End + + It joins with complex attribute + let res = ExpandInBuffer("
                    500)\">test$$$$\\j$$$$/>\n
                    ", 'html', '
                    ') + Assert Equals(res, '
                    ') + End + + It splits custom tag + let res = ExpandInBuffer("
                    \n\tj$$$$/>\n
                    ", 'html', "
                    \n\t\n
                    ") + Assert Equals(res, "
                    \n\t\n
                    ") + End + End + + Describe toggle comment + It adds comment + let res = ExpandInBuffer("
                    \n\t$$$$\\/$$$$\n
                    ", 'html', "
                    \n\t\n
                    ") + Assert Equals(res, "
                    \n\t\n
                    ") + End + + It removes comment + let res = ExpandInBuffer("
                    \n\t\n
                    ", 'html', "
                    \n\t\n
                    ") + Assert Equals(res, "
                    \n\t\n
                    ") + End + End + + Describe image size + It gets remote png size + let res = ExpandInBuffer("img[src=http://mattn.kaoriya.net/images/logo.png]$$$$\\,\\i$$$$", 'html', '') + Assert Equals(res, '') + End + + It handles missing local image + let res = ExpandInBuffer("img[src=/logo.png]$$$$\\,\\i$$$$", 'html', '') + Assert Equals(res, '') + End + + It overwrites existing size + let res = ExpandInBuffer("img[src=http://mattn.kaoriya.net/images/logo.png width=foo height=bar]$$$$\\,\\i$$$$", 'html', '') + Assert Equals(res, '') + End + End + + Describe move next prev + It moves to third attribute + let res = ExpandInBuffer("foo+bar+baz[dankogai=\"\"]$$$$\\,\\gg0\\n\\n\\n\\Byw:%d _\\p$$$$", 'html', 'dankogai') + Assert Equals(res, 'dankogai') + End + End + + Describe contains dash in attributes + It expands foo-bar attribute + Assert Equals(ExpandWord('div[foo-bar="baz"]', 'html'), "
                    \n") + End + End + + Describe default attributes + It expands a href shorthand + Assert Equals(ExpandWord('p.title>a[/hoge/]', 'html'), "

                    \n") + End + + It expands script src + Assert Equals(ExpandWord('script[jquery.js]', 'html'), "\n") + End + End + + Describe multiple group + It expands outer inner + Assert Equals(ExpandWord('.outer$*3>.inner$*2', 'html'), "
                    \n\t
                    \n\t
                    \n
                    \n
                    \n\t
                    \n\t
                    \n
                    \n
                    \n\t
                    \n\t
                    \n
                    \n") + End + End + + Describe group itemno + It expands dl dt dd + Assert Equals(ExpandWord('dl>(dt{$}+dd)*3', 'html'), "
                    \n\t
                    1
                    \n\t
                    \n\t
                    2
                    \n\t
                    \n\t
                    3
                    \n\t
                    \n
                    \n") + End + + It expands nested multiplier + Assert Equals(ExpandWord('(div[attr=$]*3)*3', 'html'), "
                    \n
                    \n
                    \n
                    \n
                    \n
                    \n
                    \n
                    \n
                    \n") + End + End + + Describe update tag + It adds class + let res = ExpandInBuffer("u.global\\$$$$3>", 'html', '

                    ') + Assert Equals(res, '

                    ') + End + + It adds class preserving attribute + let res = ExpandInBuffer("u.btn\\$$$$ disabled>", 'html', '') + Assert Equals(res, '') + End + End + + Describe base value + It starts from zero + Assert Equals(ExpandWord('ul>li#id$@0*3', 'html'), "
                      \n\t
                    • \n\t
                    • \n\t
                    • \n
                    \n") + End + End +End diff --git a/test/others.vim b/test/others.vim deleted file mode 100644 index 8a2a892..0000000 --- a/test/others.vim +++ /dev/null @@ -1,205 +0,0 @@ -let s:suite = themis#suite('others') -let s:assert = themis#helper('assert') - -let s:emmet = themis#helper('emmet') - -function! s:suite.__setup() abort - call s:emmet.setup() -endfunction - -" xsl {{{ -function! s:suite.__xsl() - let xsl = themis#suite('xsl') - - function! xsl.vari() abort - call s:assert.equals(s:emmet.expand_word('vari', 'xsl'), "\n") - endfunction - - function! xsl.ap_wp() abort - call s:assert.equals(s:emmet.expand_word('ap>wp', 'xsl'), "\n\t\n\n") - endfunction -endfunction -" }}} - -" xsd {{{ -function! s:suite.__xsd() - let xsd = themis#suite('xsd') - - function! xsd.w3c() abort - call s:assert.equals(s:emmet.expand_word('xsd:w3c', 'xsd'), "\n\n\t\n\n") - endfunction -endfunction -" }}} - -" mustache {{{ -function! s:suite.__mustache() - let mustache = themis#suite('mustache') - - function! mustache.id() abort - call s:assert.equals(s:emmet.expand_word('div#{{foo}}', 'mustache'), "
                    \n") - endfunction - - function! mustache.class() abort - call s:assert.equals(s:emmet.expand_word('div.{{foo}}', 'mustache'), "
                    \n") - endfunction -endfunction -" }}} - -" scss {{{ -function! s:suite.__scss() - let scss = themis#suite('scss') - - function! scss.import() abort - let res = s:emmet.expand_in_buffer('@i$$$$', 'scss', '@import url();') - call s:assert.equals(res, '@import url();') - endfunction - - function! scss.font_style() abort - let res = s:emmet.expand_in_buffer('{fs:n$$$$}', 'scss', '{font-style: normal;}') - call s:assert.equals(res, '{font-style: normal;}') - endfunction - - function! scss.float_left() abort - let res = s:emmet.expand_in_buffer('{fl:l|fc$$$$}', 'scss', '{float: left;}') - call s:assert.equals(res, '{float: left;}') - endfunction - - function! scss.background_plus() abort - let res = s:emmet.expand_in_buffer('{bg+$$$$}', 'scss', '{background: $$$$#fff url() 0 0 no-repeat;}') - call s:assert.equals(res, '{background: $$$$#fff url() 0 0 no-repeat;}') - endfunction - - function! scss.background_plus_important() abort - let res = s:emmet.expand_in_buffer('{bg+!$$$$}', 'scss', '{background: $$$$#fff url() 0 0 no-repeat !important;}') - call s:assert.equals(res, '{background: $$$$#fff url() 0 0 no-repeat !important;}') - endfunction - - function! scss.margin() abort - let res = s:emmet.expand_in_buffer('{m$$$$}', 'scss', '{margin: $$$$;}') - call s:assert.equals(res, '{margin: $$$$;}') - endfunction - - function! scss.margin_percent() abort - let res = s:emmet.expand_in_buffer('{m0.1p$$$$}', 'scss', '{margin: 0.1%;}') - call s:assert.equals(res, '{margin: 0.1%;}') - endfunction - - function! scss.margin_em() abort - let res = s:emmet.expand_in_buffer('{m1.0$$$$}', 'scss', '{margin: 1.0em;}') - call s:assert.equals(res, '{margin: 1.0em;}') - endfunction - - function! scss.margin_px() abort - let res = s:emmet.expand_in_buffer('{m2$$$$}', 'scss', '{margin: 2px;}') - call s:assert.equals(res, '{margin: 2px;}') - endfunction - - function! scss.border_radius() abort - let res = s:emmet.expand_in_buffer('{bdrs10$$$$}', 'scss', '{border-radius: 10px;}') - call s:assert.equals(res, '{border-radius: 10px;}') - endfunction - - function! scss.vendor_prefix() abort - let res = s:emmet.expand_in_buffer('{-bdrs20$$$$}', 'scss', "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}") - call s:assert.equals(res, "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}") - endfunction - - function! scss.linear_gradient() abort - let res = s:emmet.expand_in_buffer('{lg(top,#fff,#000)$$$$}', 'scss', "{background-image: -webkit-gradient(top, 0 0, 0 100, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}") - call s:assert.equals(res, "{background-image: -webkit-gradient(top, 0 0, 0 100, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}") - endfunction - - function! scss.margin_multi() abort - let res = s:emmet.expand_in_buffer('{m10-5-0$$$$}', 'scss', '{margin: 10px 5px 0;}') - call s:assert.equals(res, '{margin: 10px 5px 0;}') - endfunction - - function! scss.margin_negative() abort - let res = s:emmet.expand_in_buffer('{m-10--5$$$$}', 'scss', '{margin: -10px -5px;}') - call s:assert.equals(res, '{margin: -10px -5px;}') - endfunction - - function! scss.margin_auto() abort - let res = s:emmet.expand_in_buffer('{m10-auto$$$$}', 'scss', '{margin: 10px auto;}') - call s:assert.equals(res, '{margin: 10px auto;}') - endfunction - - function! scss.width_percent() abort - let res = s:emmet.expand_in_buffer('{w100p$$$$}', 'scss', '{width: 100%;}') - call s:assert.equals(res, '{width: 100%;}') - endfunction - - function! scss.height_em() abort - let res = s:emmet.expand_in_buffer('{h50e$$$$}', 'scss', '{height: 50em;}') - call s:assert.equals(res, '{height: 50em;}') - endfunction - - function! scss.multi_property_group() abort - let res = s:emmet.expand_in_buffer('{(bg+)+c$$$$}', 'scss', "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}") - call s:assert.equals(res, "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}") - endfunction -endfunction -" }}} - -" jade {{{ -function! s:suite.__jade() - let jade = themis#suite('jade') - - function! jade.doctype() abort - let res = s:emmet.expand_in_buffer("!!!$$$$\\,$$$$", 'jade', "doctype html\n\n") - call s:assert.equals(res, "doctype html\n\n") - endfunction - - function! jade.span_class() abort - let res = s:emmet.expand_in_buffer("span.my-span$$$$\\,$$$$", 'jade', 'span.my-span') - call s:assert.equals(res, 'span.my-span') - endfunction - - function! jade.input() abort - let res = s:emmet.expand_in_buffer("input$$$$\\,text$$$$", 'jade', 'input(type="text")') - call s:assert.equals(res, 'input(type="text")') - endfunction -endfunction -" }}} - -" pug {{{ -function! s:suite.__pug() - let pug = themis#suite('pug') - - function! pug.doctype() abort - let res = s:emmet.expand_in_buffer("!!!$$$$\\,$$$$", 'pug', "doctype html\n\n") - call s:assert.equals(res, "doctype html\n\n") - endfunction - - function! pug.span_class() abort - let res = s:emmet.expand_in_buffer("span.my-span$$$$\\,$$$$", 'pug', 'span.my-span') - call s:assert.equals(res, 'span.my-span') - endfunction - - function! pug.input() abort - let res = s:emmet.expand_in_buffer("input$$$$\\,text$$$$", 'pug', 'input(type="text")') - call s:assert.equals(res, 'input(type="text")') - endfunction -endfunction -" }}} - -" jsx {{{ -function! s:suite.__jsx() - let jsx = themis#suite('jsx') - - function! jsx.img() abort - let res = s:emmet.expand_in_buffer("img$$$$\\,$$$$", 'javascript.jsx', '') - call s:assert.equals(res, '') - endfunction - - function! jsx.span_class() abort - let res = s:emmet.expand_in_buffer("span.my-span$$$$\\,$$$$", 'javascript.jsx', '') - call s:assert.equals(res, '') - endfunction - - function! jsx.in_function() abort - let res = s:emmet.expand_in_buffer("function() { return span.my-span$$$$\\,$$$$; }", 'javascript.jsx', 'function() { return ; }') - call s:assert.equals(res, 'function() { return ; }') - endfunction -endfunction -" }}} diff --git a/test/others.vimspec b/test/others.vimspec new file mode 100644 index 0000000..5f6444f --- /dev/null +++ b/test/others.vimspec @@ -0,0 +1,171 @@ +Describe others + + Describe xsl + It expands vari + Assert Equals(ExpandWord('vari', 'xsl'), "\n") + End + + It expands ap>wp + Assert Equals(ExpandWord('ap>wp', 'xsl'), "\n\t\n\n") + End + End + + Describe xsd + It expands xsd:w3c + Assert Equals(ExpandWord('xsd:w3c', 'xsd'), "\n\n\t\n\n") + End + End + + Describe mustache + It expands id with mustache syntax + Assert Equals(ExpandWord('div#{{foo}}', 'mustache'), "
                    \n") + End + + It expands class with mustache syntax + Assert Equals(ExpandWord('div.{{foo}}', 'mustache'), "
                    \n") + End + End + + Describe scss + It expands import + let res = ExpandInBuffer('@i$$$$', 'scss', '@import url();') + Assert Equals(res, '@import url();') + End + + It expands font-style + let res = ExpandInBuffer('{fs:n$$$$}', 'scss', '{font-style: normal;}') + Assert Equals(res, '{font-style: normal;}') + End + + It expands float left + let res = ExpandInBuffer('{fl:l|fc$$$$}', 'scss', '{float: left;}') + Assert Equals(res, '{float: left;}') + End + + It expands background+ + let res = ExpandInBuffer('{bg+$$$$}', 'scss', '{background: $$$$#fff url() 0 0 no-repeat;}') + Assert Equals(res, '{background: $$$$#fff url() 0 0 no-repeat;}') + End + + It expands background+ important + let res = ExpandInBuffer('{bg+!$$$$}', 'scss', '{background: $$$$#fff url() 0 0 no-repeat !important;}') + Assert Equals(res, '{background: $$$$#fff url() 0 0 no-repeat !important;}') + End + + It expands margin + let res = ExpandInBuffer('{m$$$$}', 'scss', '{margin: $$$$;}') + Assert Equals(res, '{margin: $$$$;}') + End + + It expands margin percent + let res = ExpandInBuffer('{m0.1p$$$$}', 'scss', '{margin: 0.1%;}') + Assert Equals(res, '{margin: 0.1%;}') + End + + It expands margin em + let res = ExpandInBuffer('{m1.0$$$$}', 'scss', '{margin: 1.0em;}') + Assert Equals(res, '{margin: 1.0em;}') + End + + It expands margin px + let res = ExpandInBuffer('{m2$$$$}', 'scss', '{margin: 2px;}') + Assert Equals(res, '{margin: 2px;}') + End + + It expands border-radius + let res = ExpandInBuffer('{bdrs10$$$$}', 'scss', '{border-radius: 10px;}') + Assert Equals(res, '{border-radius: 10px;}') + End + + It expands vendor prefix + let res = ExpandInBuffer('{-bdrs20$$$$}', 'scss', "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}") + Assert Equals(res, "{-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\n-o-border-radius: 20px;\n-ms-border-radius: 20px;\nborder-radius: 20px;}") + End + + It expands linear-gradient + let res = ExpandInBuffer('{lg(top,#fff,#000)$$$$}', 'scss', "{background-image: -webkit-gradient(top, 0 0, 0 100%, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}") + Assert Equals(res, "{background-image: -webkit-gradient(top, 0 0, 0 100%, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n}") + End + + It expands margin multi + let res = ExpandInBuffer('{m10-5-0$$$$}', 'scss', '{margin: 10px 5px 0;}') + Assert Equals(res, '{margin: 10px 5px 0;}') + End + + It expands margin negative + let res = ExpandInBuffer('{m-10--5$$$$}', 'scss', '{margin: -10px -5px;}') + Assert Equals(res, '{margin: -10px -5px;}') + End + + It expands margin auto + let res = ExpandInBuffer('{m10-auto$$$$}', 'scss', '{margin: 10px auto;}') + Assert Equals(res, '{margin: 10px auto;}') + End + + It expands width percent + let res = ExpandInBuffer('{w100p$$$$}', 'scss', '{width: 100%;}') + Assert Equals(res, '{width: 100%;}') + End + + It expands height em + let res = ExpandInBuffer('{h50e$$$$}', 'scss', '{height: 50em;}') + Assert Equals(res, '{height: 50em;}') + End + + It expands multi property group + let res = ExpandInBuffer('{(bg+)+c$$$$}', 'scss', "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}") + Assert Equals(res, "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}") + End + End + + Describe jade + It expands doctype + let res = ExpandInBuffer("!!!$$$$\\,$$$$", 'jade', "doctype html\n\n") + Assert Equals(res, "doctype html\n\n") + End + + It expands span class + let res = ExpandInBuffer("span.my-span$$$$\\,$$$$", 'jade', 'span.my-span') + Assert Equals(res, 'span.my-span') + End + + It expands input + let res = ExpandInBuffer("input$$$$\\,text$$$$", 'jade', 'input(type="text")') + Assert Equals(res, 'input(type="text")') + End + End + + Describe pug + It expands doctype + let res = ExpandInBuffer("!!!$$$$\\,$$$$", 'pug', "doctype html\n\n") + Assert Equals(res, "doctype html\n\n") + End + + It expands span class + let res = ExpandInBuffer("span.my-span$$$$\\,$$$$", 'pug', 'span.my-span') + Assert Equals(res, 'span.my-span') + End + + It expands input + let res = ExpandInBuffer("input$$$$\\,text$$$$", 'pug', 'input(type="text")') + Assert Equals(res, 'input(type="text")') + End + End + + Describe jsx + It expands img + let res = ExpandInBuffer("img$$$$\\,$$$$", 'javascript.jsx', '') + Assert Equals(res, '') + End + + It expands span class + let res = ExpandInBuffer("span.my-span$$$$\\,$$$$", 'javascript.jsx', '') + Assert Equals(res, '') + End + + It expands in function + let res = ExpandInBuffer("function() { return span.my-span$$$$\\,$$$$; }", 'javascript.jsx', 'function() { return ; }') + Assert Equals(res, 'function() { return ; }') + End + End +End diff --git a/test/slim.vim b/test/slim.vim deleted file mode 100644 index b818fcd..0000000 --- a/test/slim.vim +++ /dev/null @@ -1,60 +0,0 @@ -let s:suite = themis#suite('slim') -let s:assert = themis#helper('assert') - -let s:emmet = themis#helper('emmet') - -function! s:suite.__setup() abort - call s:emmet.setup() -endfunction - -function! s:suite.__expand_abbreviation() - let expand = themis#suite('expand abbreviation') - - function! expand.complex() abort - call s:assert.equals(s:emmet.expand_word('div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}', 'slim'), "div\n p\n ul id=\"foo\"\n li class=\"bar1\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar2\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar3\" foo=\"bar\" bar=\"baz\"\n | baz\n") - endfunction - - function! expand.with_slim_filter() abort - call s:assert.equals(s:emmet.expand_word('div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|slim', 'slim'), "div\n p\n ul id=\"foo\"\n li class=\"bar1\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar2\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar3\" foo=\"bar\" bar=\"baz\"\n | baz\n") - endfunction - - function! expand.a_multiplier() abort - call s:assert.equals(s:emmet.expand_word('a*3|slim', 'slim'), "a href=\"\"\na href=\"\"\na href=\"\"\n") - endfunction - - function! expand.class_with_text() abort - call s:assert.equals(s:emmet.expand_word('.content{Hello!}|slim', 'slim'), "div class=\"content\"\n | Hello!\n") - endfunction - - function! expand.title_dollar_hash() abort - call s:assert.equals(s:emmet.expand_word('a[title=$#]{foo}', 'slim'), "a href=\"\" title=\"foo\"\n | foo\n") - endfunction -endfunction - -function! s:suite.__split_join_tag() - let split_join = themis#suite('split join tag') - - function! split_join.join() abort - let res = s:emmet.expand_in_buffer("a\n | foo$$$$\\j$$$$", 'slim', 'a') - call s:assert.equals(res, 'a') - endfunction - - function! split_join.split() abort - let res = s:emmet.expand_in_buffer("a$$$$\\j$$$$", 'slim', "a\n | $$$$") - call s:assert.equals(res, "a\n | $$$$") - endfunction -endfunction - -function! s:suite.__toggle_comment() - let comment = themis#suite('toggle comment') - - function! comment.add() abort - let res = s:emmet.expand_in_buffer("a href=\"http://www.google.com\"$$$$\\/$$$$\n | hello", 'slim', "/a href=\"http://www.google.com\"\n | hello") - call s:assert.equals(res, "/a href=\"http://www.google.com\"\n | hello") - endfunction - - function! comment.remove() abort - let res = s:emmet.expand_in_buffer("/a href=\"http://www.google.com\"$$$$\\/$$$$\n | hello", 'slim', "a href=\"http://www.google.com\"\n | hello") - call s:assert.equals(res, "a href=\"http://www.google.com\"\n | hello") - endfunction -endfunction diff --git a/test/slim.vimspec b/test/slim.vimspec new file mode 100644 index 0000000..364b692 --- /dev/null +++ b/test/slim.vimspec @@ -0,0 +1,48 @@ +Describe slim + + Describe expand abbreviation + It expands complex + Assert Equals(ExpandWord('div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}', 'slim'), "div\n p\n ul id=\"foo\"\n li class=\"bar1\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar2\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar3\" foo=\"bar\" bar=\"baz\"\n | baz\n") + End + + It expands with slim filter + Assert Equals(ExpandWord('div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|slim', 'slim'), "div\n p\n ul id=\"foo\"\n li class=\"bar1\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar2\" foo=\"bar\" bar=\"baz\"\n | baz\n li class=\"bar3\" foo=\"bar\" bar=\"baz\"\n | baz\n") + End + + It expands a multiplier + Assert Equals(ExpandWord('a*3|slim', 'slim'), "a href=\"\"\na href=\"\"\na href=\"\"\n") + End + + It expands class with text + Assert Equals(ExpandWord('.content{Hello!}|slim', 'slim'), "div class=\"content\"\n | Hello!\n") + End + + It expands title dollar hash + Assert Equals(ExpandWord('a[title=$#]{foo}', 'slim'), "a href=\"\" title=\"foo\"\n | foo\n") + End + End + + Describe split join tag + It joins + let res = ExpandInBuffer("a\n | foo$$$$\\j$$$$", 'slim', 'a') + Assert Equals(res, 'a') + End + + It splits + let res = ExpandInBuffer("a$$$$\\j$$$$", 'slim', "a\n | $$$$") + Assert Equals(res, "a\n | $$$$") + End + End + + Describe toggle comment + It adds comment + let res = ExpandInBuffer("a href=\"http://www.google.com\"$$$$\\/$$$$\n | hello", 'slim', "/a href=\"http://www.google.com\"\n | hello") + Assert Equals(res, "/a href=\"http://www.google.com\"\n | hello") + End + + It removes comment + let res = ExpandInBuffer("/a href=\"http://www.google.com\"$$$$\\/$$$$\n | hello", 'slim', "a href=\"http://www.google.com\"\n | hello") + Assert Equals(res, "a href=\"http://www.google.com\"\n | hello") + End + End +End