Open shawninder opened 8 years ago
Here is an example of testing language switching on the live ADM app:
'use strict'
var test = require('tape')
var Nightmare = require('nightmare')
require('nightmare-evaluate-async')(Nightmare)
function browse (url, fn, check) {
return function (t) {
var nm = Nightmare()
nm.goto(url)
.evaluateAsync(fn)
.then((result) => {
check(t, result)
nm.end(function () {
t.end()
})
})
}
}
test('language', browse('http://tv.ae',
function fn () {
return new Promise(function (resolve, reject) {
window.app.cases.$notloaded.once(function () {
var originalValue = window.app.origin.discover.title.val
window.app.origin.discover.title.once(function () {
resolve(window.app.origin.discover.title.val !== originalValue)
})
window.app.api.language.set(window.app.origin.modals.languages.fields.arabic)
})
})
},
function check (t, result) {
console.log('result', result)
t.equal(result, true, 'language changed')
}
))
This is not what we want in the end, just a first baby step.
First example is happening in ADM: https://github.com/vigour-io/abu-dhabi-media/pull/211
This is about making a a working example exactly the way we want it, but it will involve adding features to this repo. Also see #3, which allows running the same test on live apps