Skip to content

Instantly share code, notes, and snippets.

@moimikey
Last active November 6, 2015 14:58
Show Gist options
  • Save moimikey/2a06d21f2e114f0b6fc7 to your computer and use it in GitHub Desktop.
Save moimikey/2a06d21f2e114f0b6fc7 to your computer and use it in GitHub Desktop.
{
"username": "moimikey",
"test_path": "./test-bs.html",
"browsers": [
{
"browser": "firefox",
"browser_version": "latest",
"os": "OS X",
"os_version": "Lion"
},
{
"browser": "safari",
"browser_version": "latest",
"os": "OS X",
"os_version": "Mountain Lion"
},
{
"browser": "chrome",
"browser_version": "latest",
"os": "OS X",
"os_version": "Mountain Lion"
},
{
"browser": "firefox",
"browser_version": "latest",
"os": "Windows",
"os_version": "7"
},
{
"browser": "chrome",
"browser_version": "latest",
"os": "Windows",
"os_version": "7"
},
{
"browser": "ie",
"browser_version": "9.0",
"os": "Windows",
"os_version": "7"
},
{
"browser": "ie",
"browser_version": "10.0",
"os": "Windows",
"os_version": "8"
},
{
"browser": "ie",
"browser_version": "11.0",
"os": "Windows",
"os_version": "7"
}
]
}
{
"devDependencies": {
"faucet": "*",
"rewire": "*",
"tape": "*"
},
"optionalDependencies": {
"browserstack-runner": "*",
"browserstack-tape-reporter": "*",
"rewire-webpack": "*",
"tape-catch": "*",
"webpack": "*"
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
</head>
<body>
<script src="./test-bs.bundle.js"></script>
</body>
</html>
var test = require('tape')
var rewire = require('rewire')
var locale2 = rewire('./')
test('locale2 returns a string when called', function (t) {
t.plan(1)
t.equal(typeof locale2(), 'string', 'you should report this as failing!')
t.end()
})
test('locale2 can parse differently formatted locales', function (t) {
locale2.__with__('process.env.LANG', 'fil-PH')(function() {
t.equal(locale2(), 'fil-PH')
})
locale2.__with__('process.env.LANG', 'fil_PH')(function() {
t.equal(locale2(), 'fil-PH')
})
t.end()
})
test('clientInformation.language', function (t) {
t.plan(1)
locale2.__with__({
clientInformation: {
language: 'en-AA'
}
})(function() {
t.equal(locale2(), 'en-AA')
t.end()
})
})
test('navigator.language', function (t) {
t.plan(1)
locale2.__with__({
navigator: {
language: 'en-BB'
}
})(function() {
t.equal(locale2(), 'en-BB')
t.end()
})
})
test('navigator.userLanguage', function (t) {
t.plan(1)
locale2.__with__({
clientInformation: {
language: 'en-CC'
}
})(function () {
t.equal(locale2(), 'en-CC')
t.end()
})
})
test('navigator.languages', function (t) {
t.plan(1)
locale2.__with__({
navigator: {
languages: ['en-DD', 'en']
}
})(function () {
t.equal(locale2(), 'en-DD')
t.end()
})
})
test('navigator.userAgent', function (t) {
t.plan(1)
locale2.__with__({
navigator: {
userAgent: 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-EE) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10'
}
})(function () {
t.equal(locale2(), 'en-EE')
t.end()
})
})
test('process.env.LANG', function (t) {
t.plan(1)
locale2.__with__('process.env.LANG', 'en_FF.UTF-8')(function () {
t.equal(locale2(), 'en-FF')
t.end()
})
})
var RewirePlugin = require('rewire-webpack')
module.exports = {
devtool: 'eval',
entry: [
'./test.js',
'./node_modules/browserstack-tape-reporter/index.js'
],
output: {
filename: 'test-bs.bundle.js'
},
plugins: [
new RewirePlugin()
],
node: {
fs: 'empty'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment