Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af96a6c
commit 7389a1e
Showing
5 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/node_modules | ||
/test/dest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
'use strict'; | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
var rimraf = require('rimraf'); | ||
|
||
var j = path.join; | ||
|
||
var THEME = path.resolve(__dirname, 'theme'); | ||
var DEST = path.resolve(__dirname, 'dest'); | ||
|
||
process.on('uncaughtException', function (e) { | ||
console.error(e.stack); | ||
}); | ||
|
||
exports.render = function (test) { | ||
test.expect(2); | ||
|
||
rimraf(DEST, function () { | ||
var themeleon = require('..')(); | ||
|
||
themeleon.use(j(THEME, 'mixin'), 'test'); | ||
themeleon.use({object: 'object'}); | ||
|
||
var theme = themeleon(THEME, function (t) { | ||
test.ok(t.test === 'test', 'Node.js module mixin (function)'); | ||
test.ok(t.object === 'object', 'Object mixin (literal)'); | ||
|
||
t.copy('assets'); | ||
t.copy('assets', 'public'); | ||
}); | ||
|
||
theme(DEST, {}).done(test.done); | ||
}); | ||
}; | ||
|
||
exports.copy = function (t) { | ||
t.ok( | ||
compare( | ||
j(THEME, 'assets/css/main.css'), | ||
j(DEST, 'assets/css/main.css') | ||
), | ||
'Copy an asset (same name)' | ||
); | ||
|
||
t.ok( | ||
compare( | ||
j(THEME, 'assets/css/main.css'), | ||
j(DEST, 'public/css/main.css') | ||
), | ||
'Copy an asset (rename)' | ||
); | ||
|
||
t.done(); | ||
}; | ||
|
||
function compare(src, dest) { | ||
return cat(src) === cat(dest); | ||
} | ||
|
||
function cat(file) { | ||
return fs.readFileSync(file, 'utf8'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body { | ||
margin: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
module.exports = function (test) { | ||
return { | ||
test: test, | ||
}; | ||
}; |