mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 08:50:06 +02:00
fixed all tests with weird function scoping bug
This commit is contained in:
parent
36161d3406
commit
dd4bec0597
6 changed files with 37 additions and 18 deletions
|
@ -199,7 +199,7 @@ module.exports = function(grunt) {
|
||||||
command: 'git add build/'
|
command: 'git add build/'
|
||||||
},
|
},
|
||||||
casperTest: {
|
casperTest: {
|
||||||
command: 'casperjs test ./src/__tests__/casperjs/*.js || ' +
|
command: 'casperjs test ./src/__tests__/casperjs/*_test.js || ' +
|
||||||
'open ./src/__tests__/casperjs/screenshots/*.png'
|
'open ./src/__tests__/casperjs/screenshots/*.png'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,7 +8,7 @@ var CasperUtils = {
|
||||||
// Unfortunately this is hardcoded for now :*( cant get the path
|
// Unfortunately this is hardcoded for now :*( cant get the path
|
||||||
// variable synchronously when running this test, and CasperJS does
|
// variable synchronously when running this test, and CasperJS does
|
||||||
// not like being started asynchronously.
|
// not like being started asynchronously.
|
||||||
return '/Users/pcottle/Dropbox/wip/learnGitBranching/';
|
return '/Users/pcottle/Dropbox (Personal)/wip/learnGitBranching/';
|
||||||
},
|
},
|
||||||
|
|
||||||
getUrl: function () {
|
getUrl: function () {
|
||||||
|
@ -74,9 +74,6 @@ var CasperUtils = {
|
||||||
selectorContainsText: function(selector, text) {
|
selectorContainsText: function(selector, text) {
|
||||||
return function then() {
|
return function then() {
|
||||||
this.test.assertEvalEquals(function(selector) {
|
this.test.assertEvalEquals(function(selector) {
|
||||||
__utils__.echo('hellow');
|
|
||||||
__utils__.echo('hellow' + selector);
|
|
||||||
__utils__.echo(document.querySelector(selector).innerText);
|
|
||||||
return document.querySelector(selector).innerText;
|
return document.querySelector(selector).innerText;
|
||||||
},
|
},
|
||||||
text,
|
text,
|
||||||
|
@ -87,6 +84,19 @@ var CasperUtils = {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
intlKeyReturns: function(key, text) {
|
||||||
|
return function then() {
|
||||||
|
this.test.assertEvalEquals(function(key) {
|
||||||
|
return debug_Intl_str(key);
|
||||||
|
},
|
||||||
|
text,
|
||||||
|
'Checking that intl key "' + key + '" contains "' +
|
||||||
|
text + '".',
|
||||||
|
{key: key}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
existingIDs: function(existingIDs) {
|
existingIDs: function(existingIDs) {
|
||||||
return function then() {
|
return function then() {
|
||||||
existingIDs.forEach(function(id) {
|
existingIDs.forEach(function(id) {
|
||||||
|
@ -171,7 +181,7 @@ var CasperUtils = {
|
||||||
return document.querySelectorAll('p.commandLine').length > 0;
|
return document.querySelectorAll('p.commandLine').length > 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
var CasperUtils = require('./casperUtils').CasperUtils;
|
var CasperUtils = require('./casperUtils').CasperUtils;
|
||||||
|
|
||||||
casper.start(
|
casper.start(
|
||||||
CasperUtils.getUrlForCommands([
|
CasperUtils.getUrlWithQueryParams({
|
||||||
'locale fr_FR'
|
locale: 'fr_FR',
|
||||||
]),
|
}),
|
||||||
function() {
|
function() {
|
||||||
this.test.assertTitle('Learn Git Branching');
|
this.test.assertTitle('Learn Git Branching');
|
||||||
casper.waitFor(CasperUtils.waits.jsMount)
|
casper.waitFor(CasperUtils.waits.jsMount)
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
.then(CasperUtils.asserts.intlKeyReturns(
|
||||||
.wait(3000)
|
'learn-git-branching',
|
||||||
.then(CasperUtils.screenshot.entirePage)
|
"Apprenez Git Branching"
|
||||||
|
))
|
||||||
.then(CasperUtils.asserts.selectorContainsText(
|
.then(CasperUtils.asserts.selectorContainsText(
|
||||||
// The title bar on command line history
|
|
||||||
'span[data-intl="learn-git-branching"]',
|
'span[data-intl="learn-git-branching"]',
|
||||||
"APRENDÉ A BRANCHEAR EN GIT"
|
"APPRENEZ GIT BRANCHING"
|
||||||
))
|
))
|
||||||
.then(CasperUtils.testDone);
|
.then(CasperUtils.testDone);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,11 @@ var init = function() {
|
||||||
wait: true
|
wait: true
|
||||||
});
|
});
|
||||||
|
|
||||||
LocaleStore.subscribe(intlRefresh);
|
LocaleStore.subscribe(function() {
|
||||||
|
if (LocaleStore.getLocale() !== LocaleStore.getDefaultLocale()) {
|
||||||
|
intlRefresh();
|
||||||
|
}
|
||||||
|
});
|
||||||
events.on('vcsModeChange', vcsModeRefresh);
|
events.on('vcsModeChange', vcsModeRefresh);
|
||||||
|
|
||||||
initRootEvents(eventBaton);
|
initRootEvents(eventBaton);
|
||||||
|
@ -64,7 +68,6 @@ var vcsModeRefresh = function(eventData) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var intlRefresh = function() {
|
var intlRefresh = function() {
|
||||||
console.log('refreshing inlt');
|
|
||||||
if (!window.$) { return; }
|
if (!window.$) { return; }
|
||||||
$('span.intl-aware').each(function(i, el) {
|
$('span.intl-aware').each(function(i, el) {
|
||||||
var intl = require('../intl');
|
var intl = require('../intl');
|
||||||
|
|
|
@ -30,6 +30,7 @@ var toGlobalize = {
|
||||||
LevelDropdownView: require('../views/levelDropdownView'),
|
LevelDropdownView: require('../views/levelDropdownView'),
|
||||||
BuilderViews: require('../views/builderViews'),
|
BuilderViews: require('../views/builderViews'),
|
||||||
LevelArbiter: require('../level/arbiter'),
|
LevelArbiter: require('../level/arbiter'),
|
||||||
|
Util: require('../util/index'),
|
||||||
Intl: require('../intl')
|
Intl: require('../intl')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -69,11 +69,16 @@ var LevelDropdownView = ContainedBase.extend({
|
||||||
title: intl.str('select-a-level')
|
title: intl.str('select-a-level')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Lol WTF. For some reason we cant use this.render.bind(this) so
|
||||||
|
// instead setup a lame callback version. The CasperJS tests
|
||||||
|
// fail otherwise.
|
||||||
|
var that = this;
|
||||||
|
LocaleStore.subscribe(function() {
|
||||||
|
that.render.apply(that);
|
||||||
|
});
|
||||||
this.render();
|
this.render();
|
||||||
|
|
||||||
Main.getEvents().on('resetMapSolved', this.render, this);
|
Main.getEvents().on('resetMapSolved', this.render, this);
|
||||||
LocaleStore.subscribe(this.render.bind(this));
|
|
||||||
|
|
||||||
if (!options.wait) {
|
if (!options.wait) {
|
||||||
this.show();
|
this.show();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue