Last active
December 1, 2015 21:51
-
-
Save joefiorini/73f395aaf3f844009e4d to your computer and use it in GitHub Desktop.
A proof of concept I created in Sept of 2012 showing how unit testing of SCSS code could work. This code was runnable, or close to it, with a runner I wrote, but is not in good enough shape to post.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "../base/functions"; | |
$base-size: 10px; | |
@function to-equal($actual, $expected){ | |
@if $expected == $actual { | |
@return true; | |
} @else { | |
@return $actual; | |
} | |
} | |
@function to-almost-equal($actual, $expected, $variance: .5){ | |
@if $actual - $expected <= $variance { | |
@return true; | |
} @else { | |
@return $actual; | |
} | |
} | |
strip-units { | |
remove-from-em { | |
expect: to-equal(strip-units(1em), 1); | |
} | |
} | |
to-px { | |
basic-conversion { | |
expect: to-equal(to-px(1em), 10px); | |
} | |
} | |
to-em { | |
basic-conversion { | |
expect: to-equal(to-em(10px), 1em); | |
} | |
convert-with-em-context { | |
expect: to-equal(to-em(10px, 2em), .5em); | |
} | |
convert-with-em-context-messy { | |
expect: to-almost-equal(to-em(14px, 3em), .46667em); | |
} | |
convert-with-px-context { | |
expect: to-equal(to-em(10px, 20px), .5em); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment