mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-16 17:44:28 +02:00
First CasperJS test -- woohoo
This commit is contained in:
parent
6ac9ed298d
commit
65480b4ed1
4 changed files with 94 additions and 11 deletions
|
@ -203,7 +203,9 @@ module.exports = function(grunt) {
|
||||||
browserify: {
|
browserify: {
|
||||||
options: {
|
options: {
|
||||||
ignore: [
|
ignore: [
|
||||||
'src/js/__tests__/create.js'
|
'src/__tests__/casperjs/*.js',
|
||||||
|
'src/js/__tests__/create.js',
|
||||||
|
'src/js/__tests__/*.js'
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
dist: {
|
dist: {
|
||||||
|
@ -211,7 +213,7 @@ module.exports = function(grunt) {
|
||||||
'build/bundle.js': ['src/**/*.js', 'src/js/**/*.js'],
|
'build/bundle.js': ['src/**/*.js', 'src/js/**/*.js'],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// all my npm helpers
|
// all my npm helpers
|
||||||
|
|
19
package.json
19
package.json
|
@ -2,19 +2,20 @@
|
||||||
"name": "LearnGitBranching",
|
"name": "LearnGitBranching",
|
||||||
"version": "0.8.0",
|
"version": "0.8.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"grunt": "~0.4.2",
|
|
||||||
"jasmine-node": "~1.12.0",
|
|
||||||
"grunt-browserify": "~1.3.0",
|
|
||||||
"grunt-jasmine-node": "~0.1.0",
|
|
||||||
"grunt-hash": "~0.5.0",
|
|
||||||
"prompt": "0.2.9",
|
|
||||||
"browserify": "~3.14.1",
|
"browserify": "~3.14.1",
|
||||||
|
"grunt": "~0.4.2",
|
||||||
|
"grunt-browserify": "~1.3.0",
|
||||||
|
"grunt-casperjs": "^2.1.0",
|
||||||
"grunt-cli": "~0.1.11",
|
"grunt-cli": "~0.1.11",
|
||||||
"grunt-contrib-uglify": "~0.2.7",
|
|
||||||
"grunt-contrib-jshint": "~0.7.2",
|
|
||||||
"grunt-contrib-clean": "~0.5.0",
|
"grunt-contrib-clean": "~0.5.0",
|
||||||
|
"grunt-contrib-jshint": "~0.7.2",
|
||||||
|
"grunt-contrib-uglify": "~0.2.7",
|
||||||
|
"grunt-hash": "~0.5.0",
|
||||||
|
"grunt-jasmine-node": "~0.1.0",
|
||||||
"grunt-lib-phantomjs": "~0.4.0",
|
"grunt-lib-phantomjs": "~0.4.0",
|
||||||
"grunt-shell-spawn": "~0.3.0"
|
"grunt-shell-spawn": "~0.3.0",
|
||||||
|
"jasmine-node": "~1.12.0",
|
||||||
|
"prompt": "0.2.9"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"backbone": "~0.9.9",
|
"backbone": "~0.9.9",
|
||||||
|
|
34
src/__tests__/casperjs/casperHelp.js
Normal file
34
src/__tests__/casperjs/casperHelp.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
var CasperHelp = {
|
||||||
|
|
||||||
|
getRoot: function() {
|
||||||
|
// Unfortunately this is hardcoded for now :*( cant get the path
|
||||||
|
// variable while in a casper context
|
||||||
|
return '/Users/pcottle/Dropbox/wip/learnGitBranching/';
|
||||||
|
},
|
||||||
|
|
||||||
|
getUrl: function () {
|
||||||
|
return 'file://localhost/' + this.getRoot() + '/index.html?NODEMO';
|
||||||
|
},
|
||||||
|
|
||||||
|
getUrlForCommands: function(commands) {
|
||||||
|
return this.getUrl() + '&command=' + commands.join(';');
|
||||||
|
},
|
||||||
|
|
||||||
|
waits: {
|
||||||
|
jsMount: function() {
|
||||||
|
return this.evaluate(function() {
|
||||||
|
return document.querySelectorAll('div.BaseHelperBar').length > 0;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
allCommandsFinished: function () {
|
||||||
|
return this.evaluate(function() {
|
||||||
|
return document.querySelectorAll('p.commandLine').length ===
|
||||||
|
document.querySelectorAll('p.finished').length;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.CasperHelp = CasperHelp;
|
46
src/__tests__/casperjs/sanity.js
Normal file
46
src/__tests__/casperjs/sanity.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
var CasperHelp = require('./casperHelp').CasperHelp;
|
||||||
|
|
||||||
|
var visibleIDs = [
|
||||||
|
'commandLineHistory',
|
||||||
|
'terminal',
|
||||||
|
'interfaceWrapper',
|
||||||
|
'mainVisSpace',
|
||||||
|
'commandLineBar'
|
||||||
|
];
|
||||||
|
|
||||||
|
var selectors = [
|
||||||
|
'div.visBackgroundColor',
|
||||||
|
'p.commandLine'
|
||||||
|
];
|
||||||
|
|
||||||
|
var doneSelectors = [
|
||||||
|
'p.finished'
|
||||||
|
];
|
||||||
|
|
||||||
|
casper.start(
|
||||||
|
CasperHelp.getUrlForCommands([
|
||||||
|
'git commit',
|
||||||
|
]),
|
||||||
|
function() {
|
||||||
|
this.test.assertTitle('Learn Git Branching');
|
||||||
|
|
||||||
|
casper.waitFor(CasperHelp.waits.jsMount, function then() {
|
||||||
|
visibleIDs.forEach(function(id) {
|
||||||
|
this.test.assertVisible('#' + id);
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
selectors.forEach(function(selector) {
|
||||||
|
this.test.assertExists(selector);
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
this.test.done();
|
||||||
|
})
|
||||||
|
.waitFor(CasperHelp.waits.allCommandsFinished, function then() {
|
||||||
|
doneSelectors.forEach(function(selector) {
|
||||||
|
this.test.assertExists(selector);
|
||||||
|
}.bind(this));
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.run();
|
Loading…
Add table
Add a link
Reference in a new issue