Skip to content

Instantly share code, notes, and snippets.

@rmurphey
Forked from kmiyashiro/admin.html
Created July 6, 2012 01:02
Show Gist options
  • Save rmurphey/3057400 to your computer and use it in GitHub Desktop.
Save rmurphey/3057400 to your computer and use it in GitHub Desktop.
Mocha HTML spec
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="../libs/mocha.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div id="mocha"></div>
<script src="../libs/mocha.js" type="text/javascript" charset="utf-8"></script>
<script src="../libs/sinon.js" type="text/javascript" charset="utf-8"></script>
<!-- Common config -->
<script src="../config.js" type="text/javascript" charset="utf-8"></script>
<!-- Admin config -->
<script src="config.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/libs/require/require.js" type="text/javascript" charset="utf-8"></script>
<script src="../spec-helpers.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
require([
'specs/app.js',
'specs/configBundle.js',
'specs/device.js',
'specs/email.js',
'specs/group.js',
'specs/map.js',
'specs/modal.js',
'specs/policy.js',
'specs/user.js',
'specs/util.js'
], runMocha);
</script>
</body>
</html>
define(function(require) {
var UploadApp = require('view/apps/uploadAppDialog'),
modalShared = require('../shared/modal.js');
describe('App', function() {
describe('Model', function() {
});
describe('Collection', function() {
});
describe('Views', function() {
describe('Upload App', function() {
before(function() {
this.view = new UploadApp();
// This disables the animation, which breaks during the test.
// Most likely because it requires CSS
this.view.$el.removeClass('fade');
});
after(function() {
this.view.close({ remove: true });
this.view = undefined;
});
modalShared();
});
});
});
});
// Include and setup all the stuff for testing
define(function(require) {
window.$ = window.jQuery = require('jquery');
window.chai = require('chai');
window.expect = chai.expect;
window.assert = chai.assert;
window.sinonChai = require('sinon-chai'); // Buggy as hell right now
window.jqueryChai = require('chai-jquery');
chai.use(sinonChai);
chai.use(jqueryChai);
});
// Partial config file
var require = {
// Base URL relative to the test runner
// Paths are relative to this
baseUrl: '../../js/',
paths: {
// Testing libs
'chai' : '../test/libs/chai',
'sinon-chai' : '../test/libs/sinon-chai',
'chai-jquery' : '../test/libs/chai-jquery',
'common' : '../test/libs/common',
'fixtures' : '../test/admin/fixtures/fixtures',
'jquery' : 'libs/jquery/jquery.min',
'underscore' : 'libs/underscore/underscore',
'backbone' : 'vendor/backbone',
'visualsearch' : 'libs/backbone/visualsearch',
'highcharts' : 'libs/highcharts/highcharts',
'charts' : 'vendor/highcharts',
'templates' : 'templates/templates'
},
use: {
backbone: {
deps: ['use!underscore', 'jquery'],
attach: 'Backbone'
},
'libs/backbone/backbone': {
deps: ['use!underscore', 'jquery'],
attach: 'Backbone'
},
'libs/leaflet/leaflet-src': {
attach: 'L'
},
underscore: {
attach: '_'
},
mocha: {
attach: 'mocha'
}
},
priority: [
'jquery',
'underscore',
'common'
]
// urlArgs: /debug\=1/.test(window.location.search) ? '' : 'bust=' + (new Date()).getTime(), // debug
};
mocha.setup({
ui: 'bdd',
ignoreLeaks: true
});
// Protect from barfs
console = window.console || function() {};
// Don't track
window.notrack = true;
// Helper... not really needed but in case we want to do something fancy
var runMocha = function() {
mocha.run();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment