1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 09:00:06 +08:00
SpaceVim/bundle/splitjoin.vim/spec/plugin/handlebars_spec.rb
2024-06-27 18:10:36 +08:00

71 lines
1.6 KiB
Ruby

require 'spec_helper'
# Note: Handlebars is not a built-in filetype, so these specs work with no
# automatic indentation. It's still possible that bugs would creep in due when
# real indentation is factored in, though I've attempted to minimize the
# effects of that.
#
describe "handlebars" do
let(:filename) { 'test.hbs' }
# Coffee is not built-in, so let's set it up manually
def setup_handlebars_filetype
vim.set(:filetype, 'html.handlebars')
vim.set(:expandtab)
vim.set(:shiftwidth, 2)
end
specify "components" do
set_file_contents "{{some/component-name foo=bar bar=baz}}"
setup_handlebars_filetype
split
assert_file_contents <<~EOF
{{some/component-name
foo=bar
bar=baz
}}
EOF
join
assert_file_contents "{{some/component-name foo=bar bar=baz}}"
end
specify "components (bracket on the same line)" do
set_file_contents "{{some/component-name foo=bar bar=baz}}"
setup_handlebars_filetype
vim.command('let b:splitjoin_handlebars_closing_bracket_on_same_line = 1')
split
assert_file_contents <<~EOF
{{some/component-name
foo=bar
bar=baz}}
EOF
join
assert_file_contents "{{some/component-name foo=bar bar=baz}}"
end
specify "block components" do
set_file_contents "{{#some-component foo=bar}}Some content{{/some-component}}"
setup_handlebars_filetype
split
assert_file_contents <<~EOF
{{#some-component foo=bar}}
Some content
{{/some-component}}
EOF
join
assert_file_contents "{{#some-component foo=bar}}Some content{{/some-component}}"
end
end