From a6e5d697ef3c7796592ccbde593ed0d0157632e7 Mon Sep 17 00:00:00 2001 From: mike-goodwin Date: Tue, 22 Nov 2016 20:45:46 +0000 Subject: [PATCH 1/2] fixed navs and added tests --- components/navs.pug | 9 ++- test/accordion.js | 1 - test/fixtures/navs/nav-pills-justified.pug | 2 + test/fixtures/navs/nav-pills.pug | 2 + test/fixtures/navs/nav-stacked.pug | 2 + test/fixtures/navs/nav-tabs-justified.pug | 2 + test/fixtures/navs/nav-tabs.pug | 2 + test/fixtures/navs/nav.pug | 2 + test/navs.js | 82 ++++++++++++++++++++++ 9 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 test/fixtures/navs/nav-pills-justified.pug create mode 100644 test/fixtures/navs/nav-pills.pug create mode 100644 test/fixtures/navs/nav-stacked.pug create mode 100644 test/fixtures/navs/nav-tabs-justified.pug create mode 100644 test/fixtures/navs/nav-tabs.pug create mode 100644 test/fixtures/navs/nav.pug create mode 100644 test/navs.js diff --git a/components/navs.pug b/components/navs.pug index 193eb42..fa6fc38 100644 --- a/components/navs.pug +++ b/components/navs.pug @@ -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) diff --git a/test/accordion.js b/test/accordion.js index 34d4d15..6730c71 100644 --- a/test/accordion.js +++ b/test/accordion.js @@ -12,7 +12,6 @@ describe("Accordion",function() { var fn = pug.compileFile(path.join(__dirname,"fixtures/accordion","accordion.pug")); var actual = '
'; 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)); }); diff --git a/test/fixtures/navs/nav-pills-justified.pug b/test/fixtures/navs/nav-pills-justified.pug new file mode 100644 index 0000000..fce0c4a --- /dev/null +++ b/test/fixtures/navs/nav-pills-justified.pug @@ -0,0 +1,2 @@ +include ../../../components/navs.pug ++nav-pills-justified(items,active) \ No newline at end of file diff --git a/test/fixtures/navs/nav-pills.pug b/test/fixtures/navs/nav-pills.pug new file mode 100644 index 0000000..26c880c --- /dev/null +++ b/test/fixtures/navs/nav-pills.pug @@ -0,0 +1,2 @@ +include ../../../components/navs.pug ++nav-pills(items,active) \ No newline at end of file diff --git a/test/fixtures/navs/nav-stacked.pug b/test/fixtures/navs/nav-stacked.pug new file mode 100644 index 0000000..d5fd798 --- /dev/null +++ b/test/fixtures/navs/nav-stacked.pug @@ -0,0 +1,2 @@ +include ../../../components/navs.pug ++nav-stacked(items,active) \ No newline at end of file diff --git a/test/fixtures/navs/nav-tabs-justified.pug b/test/fixtures/navs/nav-tabs-justified.pug new file mode 100644 index 0000000..e4e456e --- /dev/null +++ b/test/fixtures/navs/nav-tabs-justified.pug @@ -0,0 +1,2 @@ +include ../../../components/navs.pug ++nav-tabs-justified(items,active) \ No newline at end of file diff --git a/test/fixtures/navs/nav-tabs.pug b/test/fixtures/navs/nav-tabs.pug new file mode 100644 index 0000000..84d1f4e --- /dev/null +++ b/test/fixtures/navs/nav-tabs.pug @@ -0,0 +1,2 @@ +include ../../../components/navs.pug ++nav-tabs(items,active) \ No newline at end of file diff --git a/test/fixtures/navs/nav.pug b/test/fixtures/navs/nav.pug new file mode 100644 index 0000000..dfada7a --- /dev/null +++ b/test/fixtures/navs/nav.pug @@ -0,0 +1,2 @@ +include ../../../components/navs.pug ++nav(type,items,active) \ No newline at end of file diff --git a/test/navs.js b/test/navs.js new file mode 100644 index 0000000..1c0fb05 --- /dev/null +++ b/test/navs.js @@ -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('', fn(item.locals)); + }); + }); +}); \ No newline at end of file From 81df7758b0774d9db9ecb17b5817df10bb39a5d4 Mon Sep 17 00:00:00 2001 From: mike-goodwin Date: Tue, 22 Nov 2016 20:46:17 +0000 Subject: [PATCH 2/2] 0.0.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 02857ca..855edc2 100644 --- a/package.json +++ b/package.json @@ -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": {