#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../test_helper' class ExtendTest < Test::Unit::TestCase def test_basic assert_equal < :sass) .foo, .bar { a: b; } CSS .foo a: b .bar @extend .foo SASS assert_equal < :sass) .foo, .bar { a: b; } CSS .foo a: b .bar @extend \#{".foo"} SASS end def test_multiple_targets assert_equal < bar { a: b; } CSS .baz .foo {a: b} foo > bar {@extend .foo} SCSS end def test_nested_extender_with_descendant_and_child_selector assert_equal < bar, bang.baz foo > bar, bang .baz foo > bar { a: b; } CSS .baz .foo {a: b} bang foo > bar {@extend .foo} SCSS end def test_nested_extender_with_child_selector_unifies assert_equal < bar.baz { a: b; } CSS .baz.foo {a: b} foo > bar {@extend .foo} SCSS end def test_nested_extender_with_child_selector_and_more assert_equal < bar baz, foo > bar.foo baz, foo > bar .foo baz { a: b; } CSS .foo .bar {a: b} foo > bar baz {@extend .bar} SCSS end def test_nested_extender_with_trailing_child_selector assert_raise(Sass::SyntaxError, "bar > can't extend: invalid selector") do render("bar > {@extend .baz}") end end def test_nested_extender_with_sibling_selector assert_equal < > + bar { a: b; } CSS .baz .foo {a: b} foo + > > + bar {@extend .foo} SCSS assert_equal < > bar { a: b; } CSS .baz .foo {a: b} > > bar {@extend .foo} SCSS end def test_nested_extender_merges_with_same_selector assert_equal < .bar .baz, .foo > .bar .bang { a: b; } CSS .foo > .bar .baz {a: b} .foo > .bar .bang {@extend .baz} SCSS end # Loops def test_extend_self_loop assert_equal < :scss}.merge(options)).render end end