Skip to content

Commit

Permalink
Merge pull request #6 from mike-goodwin/development
Browse files Browse the repository at this point in the history
Fixes issue #5
  • Loading branch information
mike-goodwin authored Nov 22, 2016
2 parents df0ecc4 + 81df775 commit 96d2949
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 7 deletions.
9 changes: 4 additions & 5 deletions components/navs.pug
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
//- Nav mixins
mixin nav(type,items,active)
ul.nav(class="#{type}")
ul.nav(class=type)
each item,index in items
if(index === active)
li.active(role="presentation")
a(href="#{item.href}")= item.text
a(href=item.href)= item.text
else
li(role="presentation")
a(href="#{item.href}")= item.text
a(href=item.href)= item.text


mixin nav-tabs(items,active)
+nav("nav-tabs",items,active)




mixin nav-tabs-justified(items,active)
+nav("nav-tabs nav-justified",items,active)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pug-bootstrap",
"version": "0.0.3",
"version": "0.0.4",
"description": "Bootstrap framework written completely using mixins in pug",
"main": "bootstrap.pug",
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion test/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ describe("Accordion",function() {
var fn = pug.compileFile(path.join(__dirname,"fixtures/accordion","accordion.pug"));
var actual = '<div id="accordionmyaccordion" role="tablist" aria-multiselectable="true" class="panel-group"><div class="panel panel-primary"><div role="tab" id="headingMy Accordion Item" class="panel-heading"><h4 class="panel-title"><a data-toggle="collapse" data-parent="#accordionmyaccordion" href="#collapseMyAccordionItem" aria-expanded="true" aria-controls="collapseOne">My Accordion Item</a></h4></div><div id="collapseMyAccordionItem" role="tabpanel" aria-labelledby="headingMy Accordion Item" class="panel-collapse collapse"><div class="panel-body"></div></div></div></div>';
var locals = { id: "myaccordion",title:"My Accordion Item",type: "primary", parent: "myaccordion",expanded:false};
console.log(fn(locals));
it("should generate an accordion",function() {
assert(actual,fn(locals));
});
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/navs/nav-pills-justified.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/navs.pug
+nav-pills-justified(items,active)
2 changes: 2 additions & 0 deletions test/fixtures/navs/nav-pills.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/navs.pug
+nav-pills(items,active)
2 changes: 2 additions & 0 deletions test/fixtures/navs/nav-stacked.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/navs.pug
+nav-stacked(items,active)
2 changes: 2 additions & 0 deletions test/fixtures/navs/nav-tabs-justified.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/navs.pug
+nav-tabs-justified(items,active)
2 changes: 2 additions & 0 deletions test/fixtures/navs/nav-tabs.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/navs.pug
+nav-tabs(items,active)
2 changes: 2 additions & 0 deletions test/fixtures/navs/nav.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/navs.pug
+nav(type,items,active)
82 changes: 82 additions & 0 deletions test/navs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
var assert = require("assert");
var jade = require("pug");
var fs = require("fs");
var path = require("path");

describe("Navs", function () {
function generateItems(count) {
var items = [];
for (var i = 0; i < count; i++) {
items[i] = {
href: 'href' + i,
text: 'text' + i
}
}
return items;
}

var testData = [
{
title: 'nav with a specified class',
file: 'nav',
class: 'nav nav-default',
locals: {
type: 'nav-default',
items: generateItems(3),
active: 2
}
},
{
title: 'nav with tabs',
file: 'nav-tabs',
class: 'nav nav-tabs',
locals: {
items: generateItems(3),
active: 2
}
},
{
title: 'justified nav with tabs',
file: 'nav-tabs-justified',
class: 'nav nav-tabs nav-justified',
locals: {
items: generateItems(3),
active: 2
}
},
{
title: 'nav with pills',
file: 'nav-pills',
class: 'nav nav-pills',
locals: {
items: generateItems(3),
active: 2
}
},
{
title: 'justified nav with pills',
file: 'nav-pills-justified',
class: 'nav nav-pills nav-justified',
locals: {
items: generateItems(3),
active: 2
}
},
{
title: 'stacked nav with pills',
file: 'nav-stacked',
class: 'nav nav-pills nav-stacked',
locals: {
items: generateItems(3),
active: 2
}
}
];

testData.forEach(function(item) {
it("should generate a " + item.title, function () {
var fn = jade.compileFile(path.join(__dirname, "fixtures/navs", item.file + ".pug"));
assert.equal('<ul class="' + item.class + '"><li role="presentation"><a href="href0">text0</a></li><li role="presentation"><a href="href1">text1</a></li><li class="active" role="presentation"><a href="href2">text2</a></li></ul>', fn(item.locals));
});
});
});

0 comments on commit 96d2949

Please sign in to comment.