Skip to content

Commit

Permalink
added a some basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed May 27, 2012
1 parent 10305ee commit 106fb0f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
@@ -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.