Created
December 9, 2014 16:58
-
-
Save byelipk/7c557c2e70aeb031aa9f to your computer and use it in GitHub Desktop.
An example async test helper to use while integration testing addings tags with a Select2 component in an ember application.
This file contains hidden or 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
import Ember from 'ember'; | |
import startApp from '../helpers/start-app'; | |
import '../helpers/complete-group-form-part-two'; | |
var App; | |
module('Acceptance: AddingAutocompleteToken', { | |
setup: function() { | |
App = startApp(); | |
}, | |
teardown: function() { | |
Ember.run(App, 'destroy'); | |
} | |
}); | |
test('can create new token', function() { | |
expect(1); | |
visit('/autocomplete-form'); | |
autocompleteToken('Happy'); | |
autocompleteToken('Joy'); | |
andThen(function() { | |
equal(find('.select2-search-choice').length, 2); | |
}); | |
}); |
This file contains hidden or 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
import Ember from 'ember'; | |
// register custom helper | |
Ember.Test.registerAsyncHelper('autocompleteToken', function(app, tag) { | |
if (!tag) { tag = 'Test Tag'; } | |
triggerEvent('input.select2-input', 'keydown'); | |
fillIn('input.select2-input', tag); | |
triggerEvent('input.select2-input', 'keyup'); | |
triggerEvent('li.select2-result-selectable:first', 'mousedown'); | |
triggerEvent('li.select2-result-selectable:first', 'mouseup'); | |
return wait(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment