Clean up and separate tests

Tests are now placed in their own folders, and separated per unit.
This commit is contained in:
Alex Palaistras 2016-05-21 13:17:39 +01:00
parent b1f6c8ad4a
commit e05aabbadb
14 changed files with 146 additions and 110 deletions

View File

@ -16,7 +16,7 @@ DIFF = $(shell which colordiff || which diff)
TMPPID = $(shell echo $$PPID)
# Test files to execute.
TESTS ?= $(shell find tests/*.scss)
TESTS ?= $(shell find tests/*/*.scss)
# Color & style definitions.
BOLD = \033[1m
@ -80,7 +80,7 @@ $(TESTS):
@$(FAWKSS) $@.test.$(TMPPID) > $@.actual.$(TMPPID)
$(eval te = $(shell date +"%s%3N"))
@printf ">> $(BOLD)Testing file '$@'...$(RESET)\t"
@printf ">> $(BOLD)Testing file '$@'...$(RESET) "
# Generate diff between expected and actual results and print back to user.
@result=$$($(DIFF) -ud $@.expected.$(TMPPID) $@.actual.$(TMPPID) | tail -n +3); \

View File

@ -1,34 +0,0 @@
//
// Simple import tests for Fawkss.
//
--- TEST ---
// These should be passed down to the resulting CSS file verbatim.
@import "foo.css";
@import "foo" screen;
@import "http://foo.com/bar";
@import url(foo);
// These should be imported into the resulting CSS file.
@import "imports/partial" ;
@import "imports/full.scss";
--- EXPECTED ---
@import "foo.css";
@import "foo" screen;
@import "http://foo.com/bar";
@import url(foo);
.partial {
content: 'This is a partial';
}
.full {
content: 'This is a full import';
color: #fff;
background-color : #000;
}
--- END ---

View File

@ -1,72 +0,0 @@
//
// Simple mixin tests for Fawkss.
//
--- TEST ---
// Simple mixin with no parameters or parent selectors.
@mixin invisible-ink {
color: white;
background-color: white;
}
body {
@include invisible-ink;
}
// Nested mixin with additional rules.
@mixin invisible-box {
@include invisible-ink;
border: none;
}
#boxy-mcboxface {
@include invisible-box;
}
// Simple mixin with parameters.
@mixin paint-it($fg-color, $bg-color) {
color: $fg-color;
background-color: $bg-color;
}
#black-box {
@include paint-it(black, black);
}
// Mixin with default parameters and overrides.
$color-1: black;
$color-2: white;
$color-3: red;
@mixin gradient-me($color-1: purple, $color-2: black) {
linear-gradient(left, $color-1, $color-2, $color-3);
}
#rainbox-box {
@include gradient-me(green);
}
--- EXPECTED ---
body {
color: white;
background-color: white;
}
#boxy-mcboxface {
color: white;
background-color: white;
border: none;
}
#black-box {
color: black;
background-color: black;
}
#rainbox-box {
linear-gradient(left, green, black, red);
}
--- END ---

View File

@ -1,5 +1,5 @@
//
// Simple comment tests for Fawkss.
// Tests inline and multiline comments.
//
--- TEST ---

View File

@ -1,5 +1,5 @@
//
// Simple variable tests for Fawkss.
// Tests global variable declaractions and definitions.
//
--- TEST ---

View File

@ -0,0 +1,22 @@
//
// Tests integration of nested imports for full and partial SCSS files.
//
--- TEST ---
@import "common/partial" ;
@import "common/full.scss";
--- EXPECTED ---
.partial {
content: 'This is a partial';
}
.full {
content: 'This is a full import';
color: #fff;
background-color : #000;
}
--- END ---

19
tests/imports/legacy.scss Normal file
View File

@ -0,0 +1,19 @@
//
// Tests that "legacy" or CSS imports are not handled.
//
--- TEST ---
@import "foo.css";
@import "foo" screen;
@import "http://foo.com/bar";
@import url(foo);
--- EXPECTED ---
@import "foo.css";
@import "foo" screen;
@import "http://foo.com/bar";
@import url(foo);
--- END ---

23
tests/mixins/basic.scss Normal file
View File

@ -0,0 +1,23 @@
//
// Tests basic mixin functionality.
//
--- TEST ---
@mixin invisible-ink {
color: white;
background-color: white;
}
body {
@include invisible-ink;
}
--- EXPECTED ---
body {
color: white;
background-color: white;
}
--- END ---

29
tests/mixins/nested.scss Normal file
View File

@ -0,0 +1,29 @@
//
// Tests nested mixins.
//
--- TEST ---
@mixin invisible-ink {
color: white;
background-color: white;
}
@mixin invisible-box {
@include invisible-ink;
border: none;
}
#boxy-mcboxface {
@include invisible-box;
}
--- EXPECTED ---
#boxy-mcboxface {
color: white;
background-color: white;
border: none;
}
--- END ---

View File

@ -0,0 +1,25 @@
//
// Tests mixins with default parameters and overrides.
//
--- TEST ---
$color-1: black;
$color-2: white;
$color-3: red;
@mixin gradient-me($color-1: purple, $color-2: black) {
linear-gradient(left, $color-1, $color-2, $color-3);
}
#rainbox-box {
@include gradient-me(green);
}
--- EXPECTED ---
#rainbox-box {
linear-gradient(left, green, black, red);
}
--- END ---

24
tests/mixins/params.scss Normal file
View File

@ -0,0 +1,24 @@
//
// Tests simple mixin with parameters.
//
--- TEST ---
// Simple mixin with parameters.
@mixin paint-it($fg-color, $bg-color) {
color: $fg-color;
background-color: $bg-color;
}
#black-box {
@include paint-it(black, black);
}
--- EXPECTED ---
#black-box {
color: black;
background-color: black;
}
--- END ---