Skip to content
Browse files

regex tests for #2 also

  • Loading branch information...
1 parent fc259aa commit ba97a97c78f3891a7f351856ad610f427bc48996 @hughsk hughsk committed
Showing with 12 additions and 1 deletion.
  1. +1 −1 lib/kss_styleguide.js
  2. +11 −0 test/kss_styleguide.js
View
2 lib/kss_styleguide.js
@@ -61,7 +61,7 @@ KssStyleguide.prototype.section = function(query) {
return false;
}
- // Sorts results based on regex number.
+ // Sorts results based on reference number.
return sections.sort(function(a, b) {
var refsA = a.data.reference.split('.'),
refsB = b.data.reference.split('.'),
View
11 test/kss_styleguide.js
@@ -152,12 +152,23 @@ suite('KssStyleguide', function() {
assert.deepEqual(references.sort(), expectedReferences.sort());
});
+
sectionQuery('/4/ only returns section 4', /4/, options, function(styleguide, sections) {
assert.ok(sections);
assert.equal(sections.length, 1);
assert.equal(sections[0].data.reference, '4');
assert.equal(sections[0].data.header, 'DEPTH OF 1');
});
+
+ sectionQuery('Sections should be returned in order', /9.*/, { mask: 'sections-order.less' }, function(styleguide, sections) {
+ var i, l = sections.length;
+
+ assert.equal(5, sections.length);
+
+ for (i = 0; i < l; i += 1) {
+ assert.equal( i+1, sections[i].data.reference.match(/[0-9]+$/g)[0] );
+ }
+ });
});
});
});

0 comments on commit ba97a97

Please sign in to comment.
Something went wrong with that request. Please try again.