npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-select2-with-test-helper

v0.0.1

Published

Ember wrapper for select2, with test helpers

Downloads

2

Readme

Ember select2 with test helper

This repo contains an Ember component wrapper for the select2 select box, and a page object test helper to make it easy to test in acceptance tests.

installation

ember install ember-select2-with-helper

This will install the select2-select component, and copy select2-helper.js to your app's tests/pages directory.

component

sample usage:

{{#select2-select
    action="onChangeSelect"
    config=config
    items=items
    selectId="mySelect"
}}
    <select id="mySelect">
    {{#each items as |item|}}
        <option value="{{item.id}}" selected={{item.selected}} data-label="{{item.label}}">
            {{item.label}}
        </option>
    </select>
{{/select2-select}}

action will be called whenever a user selects or deselects with two paramters: an array of currently selected values, and a string describing the action ("select" or "deselect")

config is a hash of settings passed to select2; see the select2 documentation

example: {tags: true, multiple: true, placeholder: 'Select some items'}

items is an array of objects with id, text, and (optional) selected properties. The Ember component needs the list of items to redraw the component if the items change.

example: [{ id: 0, text: 'enhancement' }, { id: 1, text: 'bug', selected: true }, ... ]

selectId is the id of the select element to select2-ize; this must match the selectId param

if data-label is set on option elements, use this value in the selected items chip.

if option elements contain HTML, override the escapeMarkup function as needed

test helper

setup

generate a page object for your page:

ember generate page-object my-page

in the page object file, import the select2 test helper:

import Select2Helper from './select2-helper';

define your page object, then add in the select2 helpers:

let MyPage = {
    visit: visitable('/:page'),
    ....
};

export default PageObject.create(Object.assign(Demo, Select2Helper));

usage

use the select2 helper methods in your test as your would any other:

andThen(function() {
    assert.equal(page.selectedCount, 1, '1 selected');
    page.selectByTitle('Cantaloupe');
});

andThen(function() {
    assert.equal(page.selectedCount, 2, '2 selected');
});

see the sample acceptance tests for more details