Skip to content

Instantly share code, notes, and snippets.

@amitgupta15
Last active April 30, 2020 23:15
Show Gist options
  • Save amitgupta15/0a6f0f76ee6742c339050430ab052d32 to your computer and use it in GitHub Desktop.
Save amitgupta15/0a6f0f76ee6742c339050430ab052d32 to your computer and use it in GitHub Desktop.
it('should add a todo item to the list', function () {
var selector = document.querySelector('#selector');
selector.innerHTML = '<form id="aform"><input type="text" name="todo-input"><button>Submit</button></form><ul id="todo-list"></ul>';
var form = document.querySelector('#aform');
form.elements['todo-input'].value = 'task 1';
var ev = document.createEvent('HTMLEvents');
ev.initEvent('submit', true, true);
form.dispatchEvent(ev);
assert(selector.innerHTML.toLowerCase().includes('<li>task 1</li>'));
//cleanup
selector.innerHTML = '';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment