Permalink
Browse files

Post 25: Automated Javascript Unit Tests (changes only - no blog post…

… HTML yet)
  • Loading branch information...
akmurray committed Oct 22, 2012
1 parent e123372 commit 7670721b64acaa3c87b3d8f8e71cd6e2f44f71b0
Binary file not shown.
Binary file not shown.
View
@@ -10,13 +10,15 @@
Aaron K. Murray, akmurray@gmail.com, @aaronkmurray, www.aaronkmurray.com
*/
})();
}());
// Global variables required by external scripts
var _qevents = _qevents || []; //quantcast
var switchTo5x=true; //ShareThis
var switchTo5x = true; //ShareThis
var _gaq = _gaq || []; //Google Analytics
_gaq.push(['_setAccount', 'UA-35522056-1']);
@@ -27,6 +29,7 @@ _gaq.push(['_trackPageview']);
// 'akm' is the base object that I will use like a namespace so that it's easy to navigate the js I write (and so that global space doesn't get too cluttered because that is frowned upon these days)
var akm = akm || {};
akm.blog = akm.blog || {}; //'akm.blog' is the root object for blog-related functions
akm.blog.intervalRefLogo = null; //variable set by 'setInterval(logoRotate, 3000)' in akm.blog._initDeferred()
akm.blog._init = function() {
///<summary>
@@ -39,8 +42,9 @@ akm.blog._init = function() {
var gistIds = [3811888,3811934,3739310,3694724,3678669];
for (var i=0;i<gistIds.length;i++)
for (var i=0;i<gistIds.length;i++) {
akm.gist.renderGist(gistIds[i], 'wrapper-gist-' + gistIds[i]);
}
setTimeout(akm.blog._initDeferred, 250);
@@ -56,13 +60,17 @@ akm.blog._initDeferred = function() {
//rotate the logo cube...
var logoRotate = function() {
var cube = document.getElementById('logo-cube');
for (var i=1;i<=6;i++)
if (!cube)
return;
for (var i=1;i<=6;i++) {
cube.removeClassName('show-side-' + i);
}
var num = Math.ceil(Math.random()*6);
cube.addClassName('show-side-' + num);
};
//...every few seconds
var intervalLogo = self.setInterval(logoRotate, 3000);
if (document.getElementById('logo-cube'))
akm.blog.intervalRefLogo = setInterval(logoRotate, 3000);
//Google Analytics
@@ -71,7 +79,7 @@ akm.blog._initDeferred = function() {
//ShareThis
akm.util.loadScript('http://w.sharethis.com/button/buttons.js', true, (function(){ stLight.options({publisher: "3be7e6b2-8565-4c3c-bbdc-a3de5fdd1bc3"}); }) );
akm.util.loadScript('http://w.sharethis.com/button/buttons.js', true, (function(){ var stLight = stLight || false; if (stLight) { stLight.options({publisher: "3be7e6b2-8565-4c3c-bbdc-a3de5fdd1bc3"}); } }) );
//quantcast
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -10,7 +10,7 @@
Aaron K. Murray, akmurray@gmail.com, @aaronkmurray, www.aaronkmurray.com
*/
})();
}());
// 'akm' is the base object that I will use like a namespace so that it's easy to navigate the js I write (and so that global space doesn't get too cluttered because that is frowned upon these days)
var akm = akm || {};
@@ -49,7 +49,7 @@ akm.util.loadScript = function (pUrl, pLoadAsync, pOnLoadCallback) {
akm.util.log('akm.util.loadScript start', [pUrl, pLoadAsync, async, akm.util.isPageLoaded, akm.util.pageLoadDate]);
if (!async && akm.util.isPageLoaded) {
if (!async && akm.util.isPageLoaded && location.protocol != 'file:') {
//after the page load event all javascript includes are async by default...so we have to handle that case specially
//need to create a syncronous ajax request to load the file
@@ -7,7 +7,7 @@
Aaron K. Murray, akmurray@gmail.com, @aaronkmurray, www.aaronkmurray.com
*/
})();
}());
if (!Element.prototype.hasClassName) Element.prototype.hasClassName = function (c) {
@@ -0,0 +1,71 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Spec Runner</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.2.0/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.2.0/jasmine.css">
<script type="text/javascript" src="lib/jasmine-1.2.0/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.2.0/jasmine-html.js"></script>
<!-- https://github.com/jcarver989/phantom-jasmine -->
<script type="text/javascript" src="lib/phantom-jasmine/console-runner.js"></script>
<!-- include source files here... -->
<script type="text/javascript" src="../../js/prototype-extensions.js"></script>
<script type="text/javascript" src="../../js/akm-util.js"></script>
<script type="text/javascript" src="../../js/akm-gist.js"></script>
<script type="text/javascript" src="../../js/akm-blog.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="spec/SpecHelper.js"></script>
<script type="text/javascript" src="spec/prototype-extensions-spec.js"></script>
<script type="text/javascript" src="spec/akm-util-spec.js"></script>
<script type="text/javascript" src="spec/akm-gist-spec.js"></script>
<script type="text/javascript" src="spec/akm-blog-spec.js"></script>
<script type="text/javascript">
var console_reporter;
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
//see: https://github.com/jcarver989/phantom-jasmine
console_reporter = new jasmine.ConsoleReporter()
jasmineEnv.addReporter(console_reporter);
jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
</script>
</head>
<body>
<div style='display:none' id='hidden-wrapper-around-test-elements'>
<div id='akm-gist-spec-element-id-1'></div>
</div>
</body>
</html>
@@ -0,0 +1,20 @@
Copyright (c) 2008-2011 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Oops, something went wrong.

0 comments on commit 7670721

Please sign in to comment.