mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Handle dashes in keys in toHaveData matcher
This commit is contained in:
10
vendor/jasmine-jquery.js
vendored
10
vendor/jasmine-jquery.js
vendored
@@ -132,7 +132,15 @@ var jQueryMatchers = {
|
||||
|
||||
toHaveData: function(key, expectedValue) {
|
||||
if (this.actual instanceof HTMLElement) {
|
||||
return hasProperty(this.actual.dataset[key], expectedValue)
|
||||
var camelCaseKey
|
||||
for (var part of key.split('-')) {
|
||||
if (camelCaseKey) {
|
||||
camelCaseKey += part[0].toUpperCase() + part.substring(1)
|
||||
} else {
|
||||
camelCaseKey = part
|
||||
}
|
||||
}
|
||||
return hasProperty(this.actual.dataset[camelCaseKey], expectedValue)
|
||||
} else {
|
||||
return hasProperty(this.actual.data(key), expectedValue)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user