Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improved error handling in tests

  • Loading branch information...
commit 0143b8af806841391759be761f3d4e8df1a25808 1 parent 60b753e
@bmavity authored
Showing with 25 additions and 22 deletions.
  1. +5 −1 tests/grammarInvoker.js
  2. +20 −21 tests/test.js
View
6 tests/grammarInvoker.js
@@ -49,7 +49,11 @@ var parse = function(selector, callback) {
callback(err);
} else {
parser.parse(selector, 'selectors_group', function(err, css) {
- callback(null, css.toString());
+ if(err) {
+ callback(err);
+ } else {
+ callback(null, css.toString());
+ }
});
}
});
View
41 tests/test.js
@@ -12,7 +12,11 @@ var shouldParse = function() {
};
context['should parse selector'] = function(err, parsedSelector) {
- assert.equal(parsedSelector, selector);
+ if(err) {
+ assert.fail(err.inner.toString());
+ } else {
+ assert.equal(parsedSelector, selector);
+ }
};
return context;
@@ -27,7 +31,11 @@ var shouldParseTo = function(expectedSelector) {
};
context['should parse selector'] = function(err, parsedSelector) {
- assert.equal(parsedSelector, expectedSelector);
+ if(err) {
+ assert.fail(err.inner.toString());
+ } else {
+ assert.equal(parsedSelector, expectedSelector);
+ }
};
return context;
@@ -239,23 +247,14 @@ vows.describe('Functional Pseudo Selectors').addBatch({
':foo(-++--baz-"bar"12px)': shouldParse()
}).run();
-/*
- def test_selector_hacks
- assert_selector_parses('> E')
- assert_selector_parses('+ E')
- assert_selector_parses('~ E')
- assert_selector_parses('> > E')
- assert_equal <<CSS, render(<<SCSS)
-> > E {
-a: b; }
-CSS
->> E {
-a: b; }
-SCSS
-
- assert_selector_parses('E*')
- assert_selector_parses('E*.foo')
- assert_selector_parses('E*:hover')
- end
- */
+vows.describe('Functional Pseudo Selectors').addBatch({
+ '> E': shouldParse(),
+ '+ E': shouldParse(),
+ '~ E': shouldParse(),
+ '> > E': shouldParse(),
+ '> > E': shouldParseTo('>> E'),
+ 'E*': shouldParse(),
+ 'E*.foo': shouldParse(),
+ 'E*:hover': shouldParse()
+}).run();
Please sign in to comment.
Something went wrong with that request. Please try again.