Skip to content

Instantly share code, notes, and snippets.

@bryanforbes
Last active December 16, 2015 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bryanforbes/5477807 to your computer and use it in GitHub Desktop.
Save bryanforbes/5477807 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Button test</title>
<link rel="stylesheet" href="dijit/themes/claro/claro.css">
</head>
<body>
<button id="button" type="button" data-dojo-type="dijit/form/Button">My Button</button>
<script src="dojo/dojo.js" data-dojo-config="async: true"></script>
<script>
var button, ready,
tests = {};
require([
'dojo/parser',
'dijit/registry',
'dijit/form/Button',
'dojo/domReady!'
], function (parser, registry) {
parser.parse();
button = registry.byId('button');
ready = true;
});
</script>
</body>
</html>
define(function (require) {
var tdd = require('intern!tdd'),
assert = require('intern/chai!assert');
tdd.suite('dijit/form/Button', function () {
tdd.before(function () {
return this.get('remote')
// load ./Button.html in the remote browser
.get(require.toUrl('./Button.html'))
// Poll the page to see if `ready` is truthy and proceed when it is
.waitForCondition('!!ready', 5000);
});
tdd.test('Click button', function () {
// An asynchronous test that times out after 10 seconds
var dfd = this.async(10000);
this.get('remote')
.execute_async(function (done) {
/*jshint undef:false*/
require(['dojo/window'], function (dwin) {
dwin.scrollIntoView(button.domNode);
var handle = button.on('click', function () {
handle.remove();
tests.buttonClicked = true;
});
// return the "node" to the client
done(button.domNode);
});
})
.click()
.execute(function () {
/*jshint undef:false*/
return tests.buttonClicked;
})
.then(dfd.callback(function (buttonClicked) {
assert(buttonClicked, 'The button should have been clicked');
}));
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment