Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
213 lines
4.1 KiB
Ruby
213 lines
4.1 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe "JSX" do
|
|
let(:filename) { 'test.jsx' }
|
|
|
|
def setup_filetype
|
|
vim.set(:filetype, 'javascriptreact')
|
|
vim.set(:expandtab)
|
|
vim.set(:shiftwidth, 2)
|
|
end
|
|
|
|
after :each do
|
|
vim.command('silent! unlet g:splitjoin_html_attributes_bracket_on_new_line')
|
|
end
|
|
|
|
describe "self-closing tags" do
|
|
specify "basic" do
|
|
set_file_contents '<Button />;'
|
|
setup_filetype
|
|
|
|
vim.search 'Button'
|
|
split
|
|
remove_indentation
|
|
|
|
assert_file_contents <<~EOF
|
|
<Button>
|
|
</Button>;
|
|
EOF
|
|
|
|
join
|
|
|
|
assert_file_contents '<Button />;'
|
|
end
|
|
|
|
specify "joining on a single line" do
|
|
set_file_contents 'let button = <Button prop="value"></Button>;'
|
|
setup_filetype
|
|
|
|
vim.search 'Button'
|
|
join
|
|
remove_indentation
|
|
|
|
assert_file_contents <<~EOF
|
|
let button = <Button prop="value" />;
|
|
EOF
|
|
end
|
|
|
|
specify "with attributes" do
|
|
set_file_contents '<Button foo="bar" bar="baz" />;'
|
|
setup_filetype
|
|
|
|
vim.search 'Button'
|
|
split
|
|
remove_indentation
|
|
|
|
assert_file_contents <<~EOF
|
|
<Button
|
|
foo="bar"
|
|
bar="baz" />;
|
|
EOF
|
|
|
|
split
|
|
remove_indentation
|
|
|
|
assert_file_contents <<~EOF
|
|
<Button
|
|
foo="bar"
|
|
bar="baz">
|
|
</Button>;
|
|
EOF
|
|
|
|
vim.search '<Button'
|
|
join
|
|
remove_indentation
|
|
|
|
assert_file_contents <<~EOF
|
|
<Button foo="bar" bar="baz">
|
|
</Button>;
|
|
EOF
|
|
|
|
join
|
|
remove_indentation
|
|
|
|
assert_file_contents '<Button foo="bar" bar="baz" />;'
|
|
end
|
|
end
|
|
|
|
describe "JSX expressions" do
|
|
specify "self-closing tag with a let statement" do
|
|
set_file_contents 'let button = <Button />;'
|
|
setup_filetype
|
|
|
|
vim.search 'Button'
|
|
split
|
|
remove_indentation
|
|
|
|
assert_file_contents <<~EOF
|
|
let button = (
|
|
<Button />
|
|
);
|
|
EOF
|
|
|
|
vim.search('button = \zs(')
|
|
join
|
|
|
|
assert_file_contents 'let button = <Button />;'
|
|
end
|
|
|
|
specify "simple tag with a return statement" do
|
|
set_file_contents <<~EOF
|
|
function button() {
|
|
return <Button></Button>;
|
|
}
|
|
EOF
|
|
setup_filetype
|
|
|
|
vim.search '<Button'
|
|
split
|
|
remove_indentation
|
|
|
|
assert_file_contents <<~EOF
|
|
function button() {
|
|
return (
|
|
<Button></Button>
|
|
);
|
|
}
|
|
EOF
|
|
|
|
vim.search('return \zs(')
|
|
join
|
|
|
|
assert_file_contents <<~EOF
|
|
function button() {
|
|
return <Button></Button>;
|
|
}
|
|
EOF
|
|
end
|
|
|
|
specify "tag with attributes in a lambda" do
|
|
set_file_contents '() => <Button foo="bar" />'
|
|
setup_filetype
|
|
|
|
vim.search '<Button'
|
|
split
|
|
remove_indentation
|
|
|
|
assert_file_contents <<~EOF
|
|
() => (
|
|
<Button foo="bar" />
|
|
)
|
|
EOF
|
|
|
|
vim.search('() => \zs(')
|
|
join
|
|
|
|
assert_file_contents '() => <Button foo="bar" />'
|
|
end
|
|
|
|
specify "variable assignment with a lambda" do
|
|
set_file_contents <<~EOF
|
|
const foo: Bar = (args) => {
|
|
return <Component prop={args.prop} />;
|
|
};
|
|
EOF
|
|
setup_filetype
|
|
|
|
vim.search 'args'
|
|
join
|
|
|
|
assert_file_contents <<~EOF
|
|
const foo: Bar = (args) => <Component prop={args.prop} />;
|
|
EOF
|
|
end
|
|
end
|
|
|
|
describe "Lambdas in tags" do
|
|
# Reference: https://github.com/AndrewRadev/splitjoin.vim/issues/182
|
|
specify "doesn't get confused by =>" do
|
|
vim.command('let g:splitjoin_html_attributes_bracket_on_new_line = 1')
|
|
|
|
set_file_contents <<~EOF
|
|
return (
|
|
<Tag category={ C } onClick={ () => toggleCategory(C) } />
|
|
);
|
|
EOF
|
|
setup_filetype
|
|
|
|
vim.search 'category'
|
|
split
|
|
remove_indentation
|
|
|
|
assert_file_contents <<~EOF
|
|
return (
|
|
<Tag
|
|
category={ C }
|
|
onClick={ () => toggleCategory(C) }
|
|
/>
|
|
);
|
|
EOF
|
|
|
|
vim.search 'Tag'
|
|
join
|
|
remove_indentation
|
|
|
|
assert_file_contents <<~EOF
|
|
return (
|
|
<Tag category={ C } onClick={ () => toggleCategory(C) } />
|
|
);
|
|
EOF
|
|
end
|
|
end
|
|
end
|