-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from zett90/master
Fix for issue with multiple elements
- Loading branch information
Showing
2 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
var assert = console.assert; | ||
var DomProcessor = require('../dom-processor'); | ||
|
||
describe('multiple element test (replace function should get the corresponding element)', function() { | ||
|
||
var configLoader = { | ||
load: function() { | ||
return [{ | ||
selector: 'div', | ||
replace: function($element) { | ||
return $element.attr('text'); | ||
} | ||
}]; | ||
} | ||
}; | ||
|
||
var processor = new DomProcessor(configLoader); | ||
|
||
it('should replace <div text="test"> with test', function() { | ||
var result = processor.process('<div text="test"></div>'); | ||
|
||
assert(result === 'test'); | ||
}); | ||
|
||
it('should replace <div text="test"></div><div text="-secondtest"></div> with test-secondtest', function() { | ||
var result = processor.process('<div text="test"></div><div text="-secondtest"></div>'); | ||
assert(result === 'test-secondtest'); | ||
}); | ||
}); |