Skip to content

Commit

Permalink
Convert to Intern 4 (dojo#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanforbes authored Oct 18, 2017
1 parent 134babc commit 07eb13e
Show file tree
Hide file tree
Showing 44 changed files with 4,822 additions and 4,754 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ install:
- travis_retry npm install
script:
- grunt
- grunt test:node --combined
- grunt test:browserstack --combined
- grunt remapIstanbul:ci
- grunt intern:browserstack
- grunt uploadCoverage
- grunt doc
deploy:
Expand Down
3 changes: 3 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ require('ts-node').register({
'compilerOptions': {
module: 'commonjs',
target: 'es6'
},
intern: {
version: 4
}
});

Expand Down
107 changes: 107 additions & 0 deletions intern.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"environments": [
{ "browserName": "node" }
],

"suites": [
"./_build/common/tests/unit/all.js"
],

"functionalSuites": [
"./_build/common/tests/functional/all.js"
],

"browser": {
"loader": {
"script": "dojo2",
"options": {
"packages": [
{ "name": "src", "location": "_build" },
{ "name": "@dojo", "location": "node_modules/@dojo" },
{ "name": "sinon", "location": "node_modules/sinon/pkg", "main": "sinon" },
{ "name": "maquette", "location": "node_modules/maquette/dist", "main": "maquette" },
{ "name": "pepjs", "location": "node_modules/pepjs/dist", "main": "pep" }
]
}
}
},

"node": {
"plugins": [
"_build/common/tests/node-css-plugin.js"
]
},

"configs": {
"coverage": {
"coverage": [
"./_build/**/*.js",
"!./_build/**/tests/**/*",
"!./_build/**/styles/**/*",
"!./_build/**/themes/**/*",
"!./_build/**/example/**/*",
"!./_build/**/*Element.js"
]
},

"remoteCapabilities": {
"capabilities": {
"project": "Dojo 2",
"name": "@dojo/widgets",
"fixSessionCapabilities": false
}
},

"browserstack": {
"extends": [ "coverage", "remoteCapabilities" ],

"tunnel": "browserstack",
"capabilities+": {
"browserstack.debug": false
},

"environments+": [
{ "browserName": "internet explorer", "version": "11" },
{ "browserName": "edge" },
{ "browserName": "firefox", "platform": "WINDOWS" },
{ "browserName": "chrome", "platform": "WINDOWS" },
{ "browserName": "safari", "version": "9.1", "platform": "MAC" },
{ "browserName": "iPhone", "version": "9.1" }
],

"maxConcurrency": 5
},

"local": {
"extends": [ "coverage", "remoteCapabilities" ],

"tunnel": "selenium",
"tunnelOptions": {
"hostname": "localhost",
"port": 4444
},

"environments+": [
{ "browserName": "chrome" }
]
},

"saucelabs": {
"extends": [ "coverage", "remoteCapabilities" ],

"tunnel": "saucelabs",
"tunnelOptions": {},

"defaultTimeout": 10000,
"environments+": [
{ "browserName": "internet explorer", "version": [ "11.0" ], "platform": "Windows 7" },
{ "browserName": "firefox", "version": "43", "platform": "Windows 10" },
{ "browserName": "chrome", "platform": "Windows 10" },
{ "browserName": "chrome", "platform": "Windows 10" },
{ "browserName": "safari", "version": "9.0", "platform": "OS X 10.11" },
{ "browserName": "iphone", "version": "9.3" }
],
"maxConcurrency": 4
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"grunt-dojo2-extras": "^2.0.0-beta1.3",
"grunt-exec": "^3.0.0",
"grunt-prompt": "^1.3.3",
"intern": "^3.4.1",
"intern": "~4.0.2",
"load-grunt-tasks": "^3.5.2",
"sinon": "^1.17.6",
"ts-node": "^3.3.0",
Expand Down
62 changes: 30 additions & 32 deletions src/button/tests/functional/Button.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import * as registerSuite from 'intern!object';
import * as assert from 'intern/chai!assert';
const { registerSuite } = intern.getInterface('object');
const { assert } = intern.getPlugin('chai');

import { Remote } from 'intern/lib/executors/Node';
import * as css from '../../styles/button.m.css';

function getPage(remote: any) {
function getPage(remote: Remote) {
return remote
.get('http://localhost:9000/_build/common/example/?module=button')
.setFindTimeout(5000);
}

registerSuite({
name: 'Button',

'button should be visible'(this: any) {
registerSuite('Button', {
'button should be visible'() {
return getPage(this.remote)
.findByCssSelector(`#example-1 .${css.root}`)
.getSize()
Expand All @@ -22,7 +22,7 @@ registerSuite({
.end();
},

'button text should be as defined'(this: any) {
'button text should be as defined'() {
return getPage(this.remote)
.findByCssSelector(`#example-1 .${css.root}`)
.getVisibleText()
Expand All @@ -32,38 +32,36 @@ registerSuite({
.end();

},
'button should be disabled'(this: any) {
'button should be disabled'() {
return getPage(this.remote)
.findByCssSelector(`#example-2 .${css.root}`)
.isEnabled()
.then((enabled: boolean) => {
.then(enabled => {
assert.isTrue(!enabled, 'The button should be disabled.');
})
.end();
},
'button should be toggle-able'(this: any) {
'button should be toggle-able'() {
return getPage(this.remote)
.findByCssSelector(`#example-3 .${css.root}`)
.getAttribute('aria-pressed')
.then((pressed: string) => {
assert.isNull(pressed, 'Initial state should be null');
})
.click()
.then(function (this: any) {
// `getAttribute` needs to be placed in then callback, rather than being
// directly chainable after `click()` - it won't wait until `click is done`
this.getAttribute('aria-pressed')
.then((pressed: string) => {
assert.strictEqual(pressed, 'true');
});
})
.click()
.then(function (this: any) {
this.getAttribute('aria-pressed')
.then((pressed: string) => {
assert.strictEqual(pressed, 'false');
});
})
.findByCssSelector(`#example-4 .${css.root}`)
.getAttribute('aria-pressed')
.then((pressed: string) => {
assert.isNull(pressed, 'Initial state should be null');
})
.click()
.end()
.findByCssSelector(`#example-4 .${css.root}`)
.getAttribute('aria-pressed')
.then((pressed: string) => {
assert.strictEqual(pressed, 'true');
})
.click()
.end()
.findByCssSelector(`#example-4 .${css.root}`)
.getAttribute('aria-pressed')
.then((pressed: string) => {
assert.strictEqual(pressed, 'false');
})
.end();
}
});
Loading

0 comments on commit 07eb13e

Please sign in to comment.