mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 16:08:34 +02:00
mysterious casperjs errors....
This commit is contained in:
parent
1afd48bb39
commit
8493b51ec2
7 changed files with 80 additions and 18 deletions
|
@ -149,6 +149,7 @@ module.exports = function(grunt) {
|
|||
browser: true,
|
||||
debug: true,
|
||||
globals: {
|
||||
casper: true,
|
||||
Raphael: true,
|
||||
require: true,
|
||||
console: true,
|
||||
|
|
|
@ -12,7 +12,15 @@ var CasperUtils = {
|
|||
},
|
||||
|
||||
getUrl: function () {
|
||||
return 'file://localhost/' + this.getRoot() + '/index.html?NODEMO';
|
||||
return 'file://localhost/' + this.getRoot() + 'index.html?NODEMO';
|
||||
},
|
||||
|
||||
getUrlWithQueryParams: function(params) {
|
||||
var paramsString = '';
|
||||
Object.keys(params).forEach(function(key) {
|
||||
paramsString = paramsString + '&' + key + '=' + params[key];
|
||||
});
|
||||
return this.getUrl() + paramsString;
|
||||
},
|
||||
|
||||
getUrlForCommands: function(commands) {
|
||||
|
@ -40,6 +48,7 @@ var CasperUtils = {
|
|||
},
|
||||
|
||||
asserts: {
|
||||
|
||||
visibleIDs: function(visibleIDs) {
|
||||
return function then() {
|
||||
visibleIDs.forEach(function(id) {
|
||||
|
@ -62,6 +71,22 @@ var CasperUtils = {
|
|||
};
|
||||
},
|
||||
|
||||
selectorContainsText: function(selector, text) {
|
||||
return function then() {
|
||||
this.test.assertEvalEquals(function(selector) {
|
||||
__utils__.echo('hellow');
|
||||
__utils__.echo('hellow' + selector);
|
||||
__utils__.echo(document.querySelector(selector).innerText);
|
||||
return document.querySelector(selector).innerText;
|
||||
},
|
||||
text,
|
||||
'Checking that selector "' + selector + '" contains "' +
|
||||
text + '".',
|
||||
{selector: selector}
|
||||
);
|
||||
};
|
||||
},
|
||||
|
||||
existingIDs: function(existingIDs) {
|
||||
return function then() {
|
||||
existingIDs.forEach(function(id) {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
var CasperUtils = require('./casperUtils').CasperUtils;
|
||||
|
||||
/**
|
||||
* TODO(pcottle) -- find a way to get this from
|
||||
* LocaleStore but not have the import error
|
||||
*/
|
||||
var langLocaleMap = {
|
||||
en: 'en_US',
|
||||
zh: 'zh_CN',
|
||||
|
@ -11,12 +15,11 @@ var langLocaleMap = {
|
|||
pt: 'pt_BR'
|
||||
};
|
||||
|
||||
/*
|
||||
var headerLocaleMap = {
|
||||
'zh-CN': 'zh_CN',
|
||||
'zh-TW': 'zh_TW',
|
||||
'pt-BR': 'pt_BR'
|
||||
};*/
|
||||
};
|
||||
|
||||
casper.start(
|
||||
CasperUtils.getUrl(),
|
||||
|
@ -24,11 +27,7 @@ casper.start(
|
|||
this.test.assertTitle('Learn Git Branching');
|
||||
|
||||
casper.waitFor(CasperUtils.waits.jsMount)
|
||||
.then(CasperUtils.asserts.visibleIDs([
|
||||
'commandLineHistory',
|
||||
]))
|
||||
.then(function() {
|
||||
|
||||
Object.keys(langLocaleMap).forEach(function(lang) {
|
||||
var locale = langLocaleMap[lang];
|
||||
this.test.assertEvalEquals(function(lang) {
|
||||
|
@ -38,7 +37,21 @@ casper.start(
|
|||
locale,
|
||||
'Testing changing store locale from ' + lang +
|
||||
' to ' + locale,
|
||||
{ lang: lang }
|
||||
{lang: lang}
|
||||
);
|
||||
}.bind(this));
|
||||
})
|
||||
.then(function() {
|
||||
Object.keys(headerLocaleMap).forEach(function(header) {
|
||||
var locale = headerLocaleMap[header];
|
||||
this.test.assertEvalEquals(function(header) {
|
||||
debug_LocaleActions_changeLocaleFromHeader(header);
|
||||
return debug_LocaleStore_getLocale();
|
||||
},
|
||||
locale,
|
||||
'Testing changing store locale from ' + header +
|
||||
' to ' + locale,
|
||||
{header: header}
|
||||
);
|
||||
}.bind(this));
|
||||
})
|
||||
|
|
20
src/__tests__/casperjs/locale_uri_param_test.js
Normal file
20
src/__tests__/casperjs/locale_uri_param_test.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
var CasperUtils = require('./casperUtils').CasperUtils;
|
||||
|
||||
casper.start(
|
||||
CasperUtils.getUrlForCommands([
|
||||
'locale fr_FR'
|
||||
]),
|
||||
function() {
|
||||
this.test.assertTitle('Learn Git Branching');
|
||||
casper.waitFor(CasperUtils.waits.jsMount)
|
||||
.then(CasperUtils.screenshot.entirePage)
|
||||
.wait(3000)
|
||||
.then(CasperUtils.screenshot.entirePage)
|
||||
.then(CasperUtils.asserts.selectorContainsText(
|
||||
// The title bar on command line history
|
||||
'span[data-intl="learn-git-branching"]',
|
||||
"APRENDÉ A BRANCHEAR EN GIT"
|
||||
))
|
||||
.then(CasperUtils.testDone);
|
||||
|
||||
}).run();
|
|
@ -1,10 +1,6 @@
|
|||
var AppConstants = require('../constants/AppConstants');
|
||||
var AppDispatcher = require('../dispatcher/AppDispatcher');
|
||||
var LocaleActions = require('../actions/LocaleActions');
|
||||
var LocaleStore = require('../stores/LocaleStore');
|
||||
|
||||
var ActionTypes = AppConstants.ActionTypes;
|
||||
|
||||
describe('LocaleStore', function() {
|
||||
|
||||
it('has default locale', function() {
|
||||
|
|
|
@ -14,6 +14,13 @@ var LocaleActions = {
|
|||
});
|
||||
},
|
||||
|
||||
changeLocaleFromURI: function(newLocale) {
|
||||
AppDispatcher.handleURIAction({
|
||||
type: ActionTypes.CHANGE_LOCALE,
|
||||
locale: newLocale
|
||||
});
|
||||
},
|
||||
|
||||
changeLocaleFromHeader: function(header) {
|
||||
AppDispatcher.handleViewAction({
|
||||
type: ActionTypes.CHANGE_LOCALE_FROM_HEADER,
|
||||
|
|
|
@ -217,7 +217,7 @@ var initDemo = function(sandbox) {
|
|||
}
|
||||
|
||||
if (params.locale !== undefined && params.locale.length) {
|
||||
LocaleActions.changeLocale(params.locale);
|
||||
LocaleActions.changeLocaleFromURI(params.locale);
|
||||
} else {
|
||||
tryLocaleDetect();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue