Created
July 19, 2013 16:58
-
-
Save csprocket777/6040692 to your computer and use it in GitHub Desktop.
Ember Unit Testing help.
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
Env = Ember.Application.create({ | |
LOG_TRANSITIONS:true, | |
LOG_BINDING: true, | |
ready:function(){ | |
console.log( Env.browsers ); | |
}, | |
supportedVideoFormats: ["mp4","ogg"], | |
contentLocation: "content/", | |
videoPlayer: '#videoPlayer', | |
envData: "", | |
loadEnvData:function(){ | |
$.ajax({ | |
url: "data/player.json", | |
dataType: "jsonp", | |
jsonpCallback:'playerData', | |
crossDomain: true, | |
success: function(data){ | |
Env.set('envData', data); | |
Env.advanceReadiness(); | |
Env.set('resumeCookie', Env.get('cookiePrefix') + data.title + ".contentResume"); | |
} | |
}); | |
}, | |
cookiePrefix: "Cisco.TM.", | |
resumeCookie: null, | |
browsers: new UserAgents({ | |
useFeatures: true, | |
detectCamouflage: true | |
}), | |
menuItems: null, | |
currentContentID: null, | |
unitTesting: false | |
}); | |
if( window.hasOwnProperty('unittesting') ) | |
{ | |
if( unittesting ) | |
{ | |
Env.unitTesting = true; | |
Env.rootElement = "#emberAppContainer"; | |
Env.setupForTesting(); | |
Env.injectTestHelpers(); | |
} | |
} | |
Env.deferReadiness(); | |
Env.loadEnvData(); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Course Player Unit Tests</title> | |
<link rel="stylesheet" href="qunit-1.11.0.css"> | |
</head> | |
<body> | |
<div id="qunit"></div> | |
<div id="qunit-fixture"></div> | |
<div id="unitTestingContainer"> | |
<div id="emberAppContainer"></div> | |
</div> | |
<script type="text/javascript">unittesting = true;</script> | |
<script src="../js/jquery-2.0.2.js"></script> | |
<script src="../js/bootstrap-2.3.2.js"></script> | |
<script src="../js/handlebars-1.0.0-rc.4.js"></script> | |
<script src="../js/ember-1.0.0-rc.6.js"></script> | |
<script src="../js/ember-model.js"></script> | |
<script src="../js/jquery.jpanelmenu.js"></script> | |
<script src="../js/video.js"></script> | |
<script src="../js/jquery.cookie.js"></script> | |
<script src="../js/ember-bootstrap.js"></script> | |
<script src="../js/detect.js"></script> | |
<script src="../js/Course_Player.js"></script> | |
<script src="qunit-1.11.0.js"></script> | |
<script src="../../src/js/unit_tests.js"></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
module("Ingegration Tests",{ | |
setup: function(){ | |
Env.reset(); | |
Ember.run(Env, Env.advanceReadiness); | |
} | |
}); | |
/* TESTING THE GENERIC FUNCTIONS FILE */ | |
test( "Given a list of dependant files, filter out videos from the other file types.", function(){ | |
var tmp = []; | |
["starWars.mp4,starWars.ogg,starWars.xml"].forEach(filterVideos, tmp); | |
equal( tmp.length, 2, "This list should only have 2 videos out of 3 entries" ); | |
tmp = null; | |
}); | |
test( "Find the first playable child in the data structure", function(){ | |
var noDefaultFirstPlay = []; | |
Env.Lo.find().forEach(FirstPlayableChild, noDefaultFirstPlay); | |
equal( noDefaultFirstPlay.length, 1, "We should only be returning 1 playable child back from the data"); | |
noDefaultFirstPlay = null; | |
}); | |
/* END TESTING THE GENERIC FUNCTIONS FILE */ | |
/* TEST THE LAYOUT OF THE SPLASH SCREEN */ | |
test("Check for the course title header tag", function(){ | |
equal($.find("#introPage>h1").length, 1, "There should be a header tag showing the course title"); | |
}); | |
test("Check to ensure the course title actually has content displayed", function(){ | |
ok($.find("#introPage>h1").text().length > 0, "There should be text in the header tag showing the course title"); | |
}); | |
/* END TEST THE LAYOUT OF THE SPLASH SCREEN */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment