1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
# frozen_string_literal: true
require_relative "test_helper"
module SassC
class OutputStyleTest < Minitest::Test
def input_scss
input_scss = <<-CSS
$color: #fff;
#main {
color: $color;
background-color: #000;
p {
width: 10em;
}
}
.huge {
font-size: 10em;
font-weight: bold;
text-decoration: underline;
}
CSS
end
def expected_nested_output
<<-CSS
#main {
color: #fff;
background-color: #000; }
#main p {
width: 10em; }
.huge {
font-size: 10em;
font-weight: bold;
text-decoration: underline; }
CSS
end
def test_nested_output_is_default
engine = Engine.new(input_scss)
assert_equal expected_nested_output, engine.render
end
def test_output_style_accepts_strings
engine = Engine.new(input_scss, style: 'sass_style_nested')
assert_equal expected_nested_output, engine.render
end
def test_invalid_output_style
engine = Engine.new(input_scss, style: 'totally_wrong')
assert_raises(InvalidStyleError) { engine.render }
end
def test_nested_output
engine = Engine.new(input_scss, style: :sass_style_nested)
assert_equal expected_nested_output, engine.render
end
def test_expanded_output
engine = Engine.new(input_scss, style: :sass_style_expanded)
assert_equal <<-CSS, engine.render
#main {
color: #fff;
background-color: #000;
}
#main p {
width: 10em;
}
.huge {
font-size: 10em;
font-weight: bold;
text-decoration: underline;
}
CSS
end
def test_compact_output
engine = Engine.new(input_scss, style: :sass_style_compact)
assert_equal <<-CSS, engine.render
#main { color: #fff; background-color: #000; }
#main p { width: 10em; }
.huge { font-size: 10em; font-weight: bold; text-decoration: underline; }
CSS
end
def test_compressed_output
engine = Engine.new(input_scss, style: :sass_style_compressed)
assert_equal <<-CSS, engine.render
#main{color:#fff;background-color:#000}#main p{width:10em}.huge{font-size:10em;font-weight:bold;text-decoration:underline}
CSS
end
def test_short_output_style_names
engine = Engine.new(input_scss, style: :compressed)
assert_equal <<-CSS, engine.render
#main{color:#fff;background-color:#000}#main p{width:10em}.huge{font-size:10em;font-weight:bold;text-decoration:underline}
CSS
end
end
end
|