class CSS2SassTest

def css2sass(string, opts={})

def css2sass(string, opts={})
  Sass::CSS.new(string, opts).render
end

def test_bad_formatting

def test_bad_formatting
  assert_equal(<<SASS, css2sass(<<CSS))
llo
parent: true
there
  parent: false
who
  hoo: false
why
  y: true
when
  wen: nao
wn_here
yeah: true
SS
llo {
parent: true;
llo  there {
parent: false;
llo who  {
hoo: false;
llo why {
 y: true;
llo when {
wen:  nao;
wn_here { yeah: true; }
S
end

def test_basic

def test_basic
  css = <<CSS
 {
color: red;
S
  assert_equal(<<SASS, css2sass(css))

color: red
SS
  assert_equal(<<SASS, css2sass(css, :old => true))

:color red
SS
end

def test_comments_in_selectors

def test_comments_in_selectors
  assert_equal(<<SASS, css2sass(<<CSS))
s
#location-navigation-form .form-submit, #business-listing-form .form-submit, #detailTabs ul, #detailsEnhanced #addTags, #locationSearchList, #moreHoods
  display: none
avListLeft
display: none
SS
s #location-navigation-form .form-submit,
s #business-listing-form .form-submit,
s #detailTabs ul,
 .js #addReview, */
 .js #addTags, */
s #detailsEnhanced #addTags,
s #locationSearchList,
s #moreHoods,
avListLeft
{ display: none; }
S
end

def test_comments_multiline

def test_comments_multiline
  css = <<CSS
 comment */
ephant.rawr {
rampages: excessively;
 actual multiline
comment */
an.turkey {
isdinner: true;
urducken {
/* Sounds funny
   doesn't it */
chimera: not_really;
verhere {
bored: sorta; /* it's for a good
cause */
better_than: thread_pools;
ne_more {
finally: srsly;
/* just a line here */
S
  sass = <<SASS
ephant.rawr
rampages: excessively
an.turkey
isdinner: true
urducken
chimera: not_really
verhere
bored: sorta
better_than: thread_pools
ne_more
finally: srsly
SS
  assert_equal(css2sass(css), sass)
end

def test_fold_commas

def test_fold_commas
  assert_equal(<<SASS, css2sass(<<CSS))

.one, .two
  color: red
SS
 .one {
color: red;
 .two {
color: red;
S
  assert_equal(<<SASS, css2sass(<<CSS))
ne
color: green
wo
color: green
color: red
hree
color: red
SS
ne, .two {
color: green;
wo, .three {
color: red;
S
end

def test_nesting

def test_nesting
  assert_equal(<<SASS, css2sass(<<CSS))

display: none
a
  text-decoration: none
  span
    color: yellow
  &:hover
    text-decoration: underline
SS
 {
display: none;
 a {
text-decoration: none;
 a span {
color: yellow;
 a:hover {
text-decoration: underline;
S
end

def test_no_nesting_around_rules

def test_no_nesting_around_rules
  assert_equal(<<SASS, css2sass(<<CSS))
v .warning
color: #d21a19
an .debug
cursor: crosshair
v .debug
cursor: default
SS
v .warning {
color: #d21a19; }
an .debug { 
cursor: crosshair;}
v .debug {
cursor: default; }
S
end

def test_pseudo_classes_are_escaped

def test_pseudo_classes_are_escaped
  assert_equal(<<SASS, css2sass(<<CSS))
:focus
a: b
\\:foo
  bar: baz
SS
ocus {a: b;}
ocus :foo {bar: baz;}
S
end