-
Notifications
You must be signed in to change notification settings - Fork 86
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
andrewblond
committed
Jul 15, 2015
1 parent
96f2c12
commit 35ec5ca
Showing
6 changed files
with
130 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 |
---|---|---|
|
@@ -27,3 +27,4 @@ libs | |
/*.tests | ||
/*.sets | ||
/*.tmpl-specs | ||
/test/dist/fixtures |
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
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,46 @@ | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<link href="mocha.css" rel="stylesheet" /> | ||
<link href="../../../dist/${ platform }/bem-components.css" rel="stylesheet" /> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
<script src="../../../dist/${ platform }/bem-components.js+bemhtml.js"></script> | ||
<script src="mocha.js"></script> | ||
<script src="sinon.js"></script> | ||
<script src="chai.js"></script> | ||
<script src="sinon-chai.js"></script> | ||
<script> | ||
(function() { | ||
modules.define('spec', ['mocha', 'chai', 'sinon', 'sinon-chai'], | ||
function(provide, mocha, chai, sinon, sinonChai) { | ||
mocha.ui('bdd'); | ||
|
||
chai.use(sinonChai); | ||
chai.should(); | ||
|
||
provide(); | ||
}); | ||
}()); | ||
</script> | ||
${ scripts } | ||
<script> | ||
(function() { | ||
var global = this; | ||
|
||
modules.require(["jquery", "mocha", "spec"], function($, mocha) { | ||
if (global.mochaPhantomJS) { | ||
global.mochaPhantomJS.run(done) | ||
} else { | ||
mocha.run(done); | ||
} | ||
|
||
function done() { | ||
$("#mocha").show(); | ||
} | ||
}); | ||
}()); | ||
</script> | ||
</body> | ||
</html> |
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,59 @@ | ||
var fs = require('fs'), | ||
path = require('path'), | ||
walk = require('bem-walk'), | ||
borschik = require('borschik').api, | ||
sets = require('./config').sets, | ||
platforms = Object.keys(sets), | ||
fixturesDir = path.join(__dirname, 'fixtures'), | ||
blocksDir = path.resolve('libs/bem-pr/spec.blocks'), | ||
asset = fs.readFileSync(path.join(__dirname, 'assets', 'test.html'), 'utf-8'); | ||
|
||
if(!fs.existsSync(fixturesDir)) { | ||
fs.mkdirSync(fixturesDir); | ||
} | ||
|
||
[ | ||
'mocha.css', | ||
'mocha.js', | ||
'chai.js', | ||
'sinon.js', | ||
'sinon-chai.js' | ||
].map(function (basename) { | ||
var name = basename.split('.')[0]; | ||
|
||
borschik({ | ||
input : path.join(blocksDir, name, basename), | ||
output : path.join(fixturesDir, basename) | ||
}); | ||
}); | ||
|
||
platforms.forEach(function (platform) { | ||
var levels = sets[platform], | ||
config = { | ||
levels : levels.map(function (levelname) { | ||
return { path : levelname }; | ||
}) | ||
}, | ||
walker = walk(levels, config), | ||
specs = []; | ||
|
||
walker.on('data', function (data) { | ||
if(data.tech === 'spec.js') { | ||
specs.push(data.path); | ||
} | ||
}); | ||
|
||
walker.on('end', function () { | ||
html = buildHTML(platform, specs); | ||
|
||
fs.writeFileSync(path.join(fixturesDir, platform + '.html'), html, 'utf-8'); | ||
}); | ||
}); | ||
|
||
function buildHTML(platform, specs) { | ||
return asset | ||
.replace(/\${ platform }/g, platform) | ||
.replace(/\${ scripts }/g, specs.map(function (url) { | ||
return ' <script src="../../../' + url + '"></script>'; | ||
}).join('\n')); | ||
} |
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,18 @@ | ||
module.exports = { | ||
sets : { | ||
desktop : [ | ||
'common.blocks', | ||
'desktop.blocks' | ||
], | ||
'touch-pad' : [ | ||
'common.blocks', | ||
'touch.blocks', | ||
'touch-pad.blocks' | ||
], | ||
'touch-phone' : [ | ||
'common.blocks', | ||
'touch.blocks', | ||
'touch-phone.blocks' | ||
] | ||
} | ||
}; |