Permalink
Browse files

added a some basic tests

  • Loading branch information...
fb55 committed May 27, 2012
1 parent 10305ee commit 106fb0f5f0857379a0fae1e405ca20a94cccc5d3
Showing with 32 additions and 0 deletions.
  1. +32 −0 tests/test.js
View
@@ -0,0 +1,32 @@
+var deepEquals = require("assert").deepEqual,
+ CSSwhat = require("../");
+
+var tests = [
+ ["div", [ [ { type: 'tag', name: 'div' } ] ], "simple tag"],
+ ["*", [ [ { type: 'universal' } ] ], "universal"],
+
+ //traversal
+ ["div div", [ [ { type: 'tag', name: 'div' },
+ { type: 'descendant' },
+ { type: 'tag', name: 'div' } ] ], "descendant"],
+ ["div\t \n \tdiv", [ [ { type: 'tag', name: 'div' },
+ { type: 'descendant' },
+ { type: 'tag', name: 'div' } ] ], "descendant /w whitespace"],
+ ["div + div", [ [ { type: 'tag', name: 'div' },
+ { type: 'adjacent' },
+ { type: 'tag', name: 'div' } ] ], "adjacent"],
+ ["div ~ div", [ [ { type: 'tag', name: 'div' },
+ { type: 'sibling' },
+ { type: 'tag', name: 'div' } ] ], "sibling"],
+
+ //attributes
+ [".foo", [ [ { type: 'class', value: 'foo' } ] ], "simple class"]
+
+ //TODO
+];
+
+tests.forEach(function(arr){
+ arr[0] = CSSwhat(arr[0]);
+ deepEquals.apply(null, arr);
+ console.log(arr[2], "passed");
+});

0 comments on commit 106fb0f

Please sign in to comment.