1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-04 13:00:04 +08:00
SpaceVim/bundle/splitjoin.vim/spec/plugin/scss_spec.rb

146 lines
2.1 KiB
Ruby
Raw Normal View History

2024-06-27 18:10:36 +08:00
require 'spec_helper'
describe "scss" do
let(:filename) { 'test.scss' }
before :each do
vim.set(:expandtab)
vim.set(:shiftwidth, 2)
end
specify "definition joining" do
set_file_contents <<~EOF
ul li {
a {
padding: 10px;
}
}
EOF
vim.search 'a'
join
assert_file_contents <<~EOF
ul li {
a { padding: 10px; }
}
EOF
split
assert_file_contents <<~EOF
ul li {
a {
padding: 10px;
}
}
EOF
end
specify "nested definitions" do
set_file_contents <<~EOF
ul li {
a.class-name {
padding: 10px;
}
}
EOF
vim.search 'li'
join
assert_file_contents <<~EOF
ul li a.class-name {
padding: 10px;
}
EOF
vim.search 'a'
split
assert_file_contents <<~EOF
ul li {
a.class-name {
padding: 10px;
}
}
EOF
end
specify "single-line style definitions" do
set_file_contents <<~EOF
a { color: #0000FF; text-decoration: underline; }
EOF
split
assert_file_contents <<~EOF
a {
color: #0000FF;
text-decoration: underline;
}
EOF
join
assert_file_contents <<~EOF
a { color: #0000FF; text-decoration: underline; }
EOF
end
specify "empty single-line style definitions (regression)" do
set_file_contents <<~EOF
body {
}
EOF
join
assert_file_contents 'body {}'
split
assert_file_contents <<~EOF
body {
}
EOF
set_file_contents <<~EOF
body {
}
EOF
join
assert_file_contents 'body {}'
end
specify "multiline selectors" do
set_file_contents <<~EOF
h1, h2, h3 {
font-size: 18px;
font-weight: bold;
}
EOF
split
assert_file_contents <<~EOF
h1,
h2,
h3 {
font-size: 18px;
font-weight: bold;
}
EOF
join
assert_file_contents <<~EOF
h1, h2, h3 {
font-size: 18px;
font-weight: bold;
}
EOF
end
end