Skip to content

Commit

Permalink
Merge pull request #8 from Nakira/patch-1
Browse files Browse the repository at this point in the history
Update dropdowns.pug
  • Loading branch information
mike-goodwin authored Nov 29, 2016
2 parents 96d2949 + 4662d9f commit d575f6a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/dropdowns.pug
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mixin dropdown(caption,items)
- var args = Array.prototype.slice.call(arguments);
for item in args[1]
li(role="presentation")
a(role="menuitem",tabindex="-1",href="#{item.url}")= item.text
a(role="menuitem",tabindex="-1",href=item.url)= item.text

//- Dropup
mixin dropup(caption,items)
Expand All @@ -22,4 +22,4 @@ mixin dropup(caption,items)
- var args = Array.prototype.slice.call(arguments);
for item in args[1]
li(role="presentation")
a(role="menuitem",tabindex="-1",href="#{item.url}")= item.text
a(role="menuitem",tabindex="-1",href=item.url)= item.text
34 changes: 34 additions & 0 deletions test/dropdowns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var assert = require("assert");
var jade = require("pug");
var fs = require("fs");
var path = require("path");

describe("Dropdowns", function () {

function generateItems(count) {
var items = [];
for (var i = 0; i < count; i++) {
items[i] = {
url: 'url' + i,
text: 'text' + i
}
}
return items;
}
it("should generate a dropdown", function () {
var locals = {
caption: "dropdown caption",
items: generateItems()
};
var fn = jade.compileFile(path.join(__dirname, "fixtures/dropdowns/dropdown.pug"));
assert.equal('<div class="dropdown"><button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">dropdown caption&nbsp;<span class="caret"></span></button><ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1"></ul></div>', fn(locals));
});
it("should generate a dropup", function () {
var locals = {
caption: "dropup caption",
items: generateItems()
};
var fn = jade.compileFile(path.join(__dirname, "fixtures/dropdowns/dropup.pug"));
assert.equal('<div class="dropup"><button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">dropup caption&nbsp;<span class="caret"></span></button><ul class="dropdown-menu" role="menu" aria-labelledby="dropupMenu1"></ul></div>', fn(locals));
});
});
2 changes: 2 additions & 0 deletions test/fixtures/dropdowns/dropdown.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/dropdowns.pug
+dropdown(caption,items)
2 changes: 2 additions & 0 deletions test/fixtures/dropdowns/dropup.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/dropdowns.pug
+dropup(caption,items)

0 comments on commit d575f6a

Please sign in to comment.