-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Test dependencies. | ||
*/ | ||
|
||
var tape = require('tape') | ||
var vomit = require('..') | ||
|
||
|
||
tape('should call function on event', (test) => { | ||
test.plan(1) | ||
var btn = vomit`<button onclick="${function() { | ||
test.equal(this.outerHTML, '<button onclick="">hello</button>') | ||
}}">hello</button>` | ||
trigger('click', btn) | ||
}) | ||
|
||
|
||
tape('should call muiltiple function on event', (test) => { | ||
test.plan(1) | ||
var hello = function() { | ||
this.innerHTML += 'hello ' | ||
} | ||
|
||
var world = function() { | ||
this.innerHTML += 'world!' | ||
} | ||
var btn = vomit`<button onclick="${hello}${world}"></button>` | ||
trigger('click', btn) | ||
test.equal(btn.outerHTML, '<button onclick="">hello world!</button>') | ||
}) | ||
|
||
/** | ||
* Trigger event. | ||
* | ||
* @pram {String} type | ||
* @param {Element} el | ||
* @api private | ||
*/ | ||
|
||
function trigger(type, el) { | ||
var event = new Event(type); | ||
el.dispatchEvent(event); | ||
} |