Skip to content
This repository has been archived by the owner on Dec 31, 2017. It is now read-only.

Add unit tests #54

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ A brief tour
* The file `src/app/resources/app.css` contains import statements to load
the CSS for Dojo’s Claro theme. _If you are not using Dijit widgets, you
probably want to remove these imports!_
* The `tests` folder contains tests for our app. To run the `Dialog` tests you must
open a browser and point to this url: `http://localhost/dojo-boilerplate/src/util/doh/runner.html?testModule=tests/app/Dialog&paths=tests,../../tests;app,../app;dojo,.;dijit,../dijit;dojox,../dojox` (your host may be in another address).

Useful resources
----------------
Expand Down
44 changes: 44 additions & 0 deletions tests/app/Dialog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!doctype html>
<html>
<head>
<title>Testing app/Dialog</title>
<meta charset="utf-8">
<style type="text/css">
/* Load all your required stylesheets */
@import "../../src/dojo/resources/dojo.css";
@import "../../src/dijit/themes/claro/claro.css";
</style>
<script type="text/javascript">
var dojoConfig = {
isDebug: true,
baseUrl: '../../src/',
packages: [
{name: 'dojo' , location: 'dojo'},
{name: 'dijit', location: 'dijit'},
{name: 'dojox', location: 'dojox'},
{name: 'doh' , location: 'util/doh'},
{name: 'app' , location: 'app'}
]
};
</script>
<script type="text/javascript" src="../../src/dojo/dojo.js"></script>
<script type="text/javascript">
require([
'doh',
'app/Dialog',
'dojo/domReady!'
], function(doh, Dialog){
doh.register([
function HereIsAnotherTestThatRunsOnAnIsolatedHtmlPage (t) {
t.t(true);
t.f(false);
t.is(1, 1);
}
]);

doh.runOnLoad();
});
</script>
</head>
<body></body>
</html>
37 changes: 37 additions & 0 deletions tests/app/Dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
define([
'doh/runner',
'app/Dialog'
], function (
doh,
Dialog
) {

doh.register('Dialog tests', [{

name: 'Dialog must have correct title',

setUp: function () {
this.dialog = new Dialog();
},

tearDown: function () {
// 'clean' workspace. We must destroy the dialog if we open it.
},

runTest: function (t) {
t.is('Hello World', this.dialog.get('title'));
}

}, function DialogMustHaveCorrectContent (t) {
// Another way to write tests
var dialog = new Dialog();
t.is('Loaded successfully!', dialog.get('content'));
}]);

// In order to test DOM manipulation, you may want to run in an HTML page.
if(doh.isBrowser) {
doh.register('Dialog DOM tests',
require.toUrl('../../../tests/app/Dialog.html'), 30000);
}

});