Last active
December 14, 2015 00:39
-
-
Save JorgenHookham/5001009 to your computer and use it in GitHub Desktop.
Boilerplate for widget unit tests
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
// Save these as two separate files. | |
// Write your tests in the js file. | |
// Run your tests from the html file. | |
// Add your test module to /static/lib/js/tests/run_all_js_tests.html | |
// lib/tests/unit_tests.js | |
define([ | |
'jquery', | |
'underscore', | |
'backbone', | |
'../../review.js' | |
], function ($, _, Backbone, ReviewWidget) { | |
test('Universal truth test.', function () { | |
ok(1 == 1); | |
}); | |
}); | |
// lib/tests/test_loader.html | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>JAVASCRIPT UNIT TEST</title> | |
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.11.0.css"> | |
<script src="http://code.jquery.com/qunit/qunit-1.11.0.js"></script> | |
<script src="../../../../../lib/require/require.js"></script> | |
</head> | |
<body> | |
<div id="qunit"></div> | |
<script> | |
(function () { | |
QUnit.stop(); | |
QUnit.config.autostart = false; | |
require.config({ | |
baseUrl: './', | |
paths: { | |
main: '../../../../main', | |
lib: '../../../../../lib', | |
modules: '../../../../modules', | |
jquery: '../../../../../lib/jquery/jquery-min', | |
underscore: '../../../../../lib/underscore/underscore-amd-min', | |
backbone: '../../../../../lib/backbone/backbone-amd-min', | |
text: '../../../../../lib/require/text', | |
goog: '../../../../../lib/require/goog', | |
propertyParser : '../../../../../lib/require/propertyParser', | |
async: '../../../../../lib/require/async', | |
utils: '../../../../utils', | |
facebook_sdk: '../../../../facebook_sdk' | |
} | |
}); | |
require(['tests'], QUnit.start()); | |
}()); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment