Skip to content

Instantly share code, notes, and snippets.

@leepfrog
Created June 12, 2014 18:54
Show Gist options
  • Select an option

  • Save leepfrog/da4959b1728621b3fe59 to your computer and use it in GitHub Desktop.

Select an option

Save leepfrog/da4959b1728621b3fe59 to your computer and use it in GitHub Desktop.
test('selections should be populated as checkboxes are marked', function() {
expect(4);
var selections = Em.A();
var testData = {
models: Em.A([
Em.Object.create({ id: 1, name: "Foo", desc: "Hey"}),
Em.Object.create({ id: 2, name: "Bar", desc: "World"}),
]),
value: selections
};
// Special helper used to render a component into the test view
setupComponentTestView({
app: App,
widgetName: 'checkbox-list',
args: testData,
});
var checkboxes = find('ul.checkbox-list input[type=checkbox]');
equal(selections.get('length'), 0, 'valueData should be empty initially');
click(checkboxes.first());
equal(selections.get('length'), 1, 'valueData should have a single element after clicking unchecked box');
click(checkboxes.last());
equal(selections.get('length'), 2, 'valueData should have two elements after clicking unchecked box');
click(checkboxes.last());
equal(selections.get('length'), 1, 'valueData should have a single element after unclicking the checked box');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment