Comparing version 1.0.1 to 1.0.2
module.exports = KarmaConfig | ||
function KarmaConfig(config) { | ||
const browser = process.argv[5] | ||
const browsers = [ | ||
'Chrome', | ||
'Safari', | ||
'Firefox', | ||
'Nightmare', | ||
'browserstack:chrome', | ||
'browserstack:safari', | ||
'browserstack:firefox', | ||
] | ||
config.set({ | ||
@@ -11,11 +22,3 @@ basePath: '', | ||
browsers: [ | ||
'Chrome', | ||
'Safari', | ||
'Firefox', | ||
'Nightmare', | ||
'browserstack:chrome', | ||
'browserstack:safari', | ||
'browserstack:firefox', | ||
], | ||
browsers, | ||
@@ -59,2 +62,3 @@ customLaunchers: { | ||
'mocha', | ||
'detectBrowsers', | ||
], | ||
@@ -87,3 +91,13 @@ | ||
}, | ||
detectBrowsers: { | ||
enabled: browser === 'all', | ||
usePhantomJS: false, | ||
postDetection(availableBrowsers) { | ||
const runnableBrowsers = availableBrowsers.filter(browser => browsers.indexOf(browser) > -1) | ||
console.log(`Testing specs in ${runnableBrowsers.length} browsers (${runnableBrowsers.join(', ')})`) | ||
return runnableBrowsers | ||
}, | ||
}, | ||
}) | ||
} |
{ | ||
"name": "chai-style", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "CSS Style assertions for elements, using Chai.js", | ||
@@ -46,2 +46,3 @@ "main": "sources/index.js", | ||
"karma-chrome-launcher": "^2.1.0", | ||
"karma-detect-browsers": "^2.2.5", | ||
"karma-firefox-launcher": "^1.0.1", | ||
@@ -48,0 +49,0 @@ "karma-mocha": "^1.3.0", |
@@ -43,3 +43,3 @@ module.exports = chaiStyle | ||
const hasAutoValue = value.includes('auto') | ||
const reg = new RegExp(value.replace(/auto/g, '(\\d+(.\\d+)?px|auto)')) | ||
const reg = new RegExp(escapeRegExp(value).replace(/auto/g, '(\\d+(.\\d+)?px|auto)')) | ||
@@ -53,1 +53,5 @@ return hasAutoValue | ||
// https://github.com/benjamingr/RegExp.escape/blob/master/polyfill.js | ||
function escapeRegExp(value) { | ||
return String(value).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&') | ||
} |
@@ -7,23 +7,5 @@ const {describe, it, before, beforeEach} = require('mocha') | ||
before(function addExternalStyle() { | ||
const style = document.createElement('style') | ||
style.innerHTML = 'div {text-transform: uppercase}' | ||
document | ||
.querySelector('head') | ||
.appendChild(style) | ||
}) | ||
before(addExternalStyle) | ||
beforeEach(createElement) | ||
beforeEach(function createElement() { | ||
element = document.createElement('div') | ||
document.body.appendChild(element) | ||
element.style.color = 'red' | ||
element.style.fontSize = '12px' | ||
element.style.lineHeight = '1em' | ||
element.style.margin = '2em auto' | ||
element.style.padding = '0 10px' | ||
element.style.height = '50vh' | ||
element.style.width = '50vw' | ||
element.style.boxShadow = '0 0 10px red' | ||
}) | ||
describe('chai-style', () => { | ||
@@ -63,2 +45,6 @@ describe('module', () => { | ||
}) | ||
it('should support asserting non-regex-safe values', () => { | ||
expect(element).to.have.style('backgroundImage', 'url("data:image/gif;base64,ABC++DEF==")') | ||
}) | ||
}) | ||
@@ -198,1 +184,23 @@ | ||
}) | ||
function addExternalStyle() { | ||
const style = document.createElement('style') | ||
style.innerHTML = 'div {text-transform: uppercase}' | ||
document | ||
.querySelector('head') | ||
.appendChild(style) | ||
} | ||
function createElement() { | ||
element = document.createElement('div') | ||
document.body.appendChild(element) | ||
element.style.color = 'red' | ||
element.style.fontSize = '12px' | ||
element.style.lineHeight = '1em' | ||
element.style.margin = '2em auto' | ||
element.style.padding = '0 10px' | ||
element.style.height = '50vh' | ||
element.style.width = '50vw' | ||
element.style.boxShadow = '0 0 10px red' | ||
element.style.backgroundImage = 'url("data:image/gif;base64,ABC++DEF==")' | ||
} |
Sorry, the diff of this file is not supported yet
16024
292
16