Skip to content

Commit

Permalink
Handle dashes in keys in toHaveData matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Sobo committed Sep 19, 2015
1 parent 8f5568b commit 2ef6d1b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion vendor/jasmine-jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 2ef6d1b

Please sign in to comment.