choices.js
Advanced tools
Comparing version 1.1.8 to 1.1.9
{ | ||
"name": "choices.js", | ||
"version": "1.1.8", | ||
"version": "1.1.9", | ||
"description": "A vanilla JS customisable text input/select box plugin", | ||
@@ -42,3 +42,3 @@ "main": "./assets/scripts/dist/choices.min.js", | ||
"eslint-plugin-react": "^6.1.0", | ||
"jasmine-core": "^2.4.1", | ||
"jasmine-core": "2.4.1", | ||
"karma": "^1.1.0", | ||
@@ -45,0 +45,0 @@ "karma-coverage": "^1.0.0", |
@@ -259,3 +259,3 @@ # Choices.js [![Build Status](https://travis-ci.org/jshjohnson/Choices.svg?branch=master)](https://travis-ci.org/jshjohnson/Choices) | ||
**Usage:** Specify which fields should be used for sorting. | ||
**Usage:** Specify which fields should be used for sorting when a user is searching. If a user is not searching and sorting is enabled, only the choice's label will be sorted. | ||
@@ -262,0 +262,0 @@ ### placeholder |
@@ -38,8 +38,5 @@ import 'whatwg-fetch'; | ||
it('should have a blank state', function() { | ||
const blankState = { | ||
items: [], | ||
groups: [], | ||
choices: [], | ||
}; | ||
expect(this.choices.currentState).toEqual(blankState); | ||
expect(this.choices.currentState.items.length).toEqual(0); | ||
expect(this.choices.currentState.groups.length).toEqual(0); | ||
expect(this.choices.currentState.choices.length).toEqual(0); | ||
}); | ||
@@ -137,3 +134,2 @@ | ||
document.body.appendChild(this.input); | ||
}); | ||
@@ -241,3 +237,3 @@ | ||
option.value = `Value ${i}`; | ||
option.innerHTML = `Value ${i}`; | ||
option.innerHTML = `Label ${i}`; | ||
@@ -248,9 +244,6 @@ this.input.appendChild(option); | ||
document.body.appendChild(this.input); | ||
this.choices = new Choices(this.input, { | ||
removeItemButton: true | ||
}); | ||
}); | ||
it('should open the choice list on focussing', function() { | ||
this.choices = new Choices(this.input); | ||
this.choices.input.focus(); | ||
@@ -261,2 +254,3 @@ expect(this.choices.dropdown.classList).toContain(this.choices.config.classNames.activeState); | ||
it('should select the first choice', function() { | ||
this.choices = new Choices(this.input); | ||
expect(this.choices.currentState.items[0].value).toContain('Value 1'); | ||
@@ -266,2 +260,3 @@ }); | ||
it('should highlight the choices on keydown', function() { | ||
this.choices = new Choices(this.input); | ||
this.choices.input.focus(); | ||
@@ -283,2 +278,3 @@ | ||
it('should select choice on enter key press', function() { | ||
this.choices = new Choices(this.input); | ||
this.choices.input.focus(); | ||
@@ -305,2 +301,3 @@ | ||
it('should trigger a change callback on selection', function() { | ||
this.choices = new Choices(this.input); | ||
spyOn(this.choices.config, 'callbackOnChange'); | ||
@@ -328,2 +325,3 @@ this.choices.input.focus(); | ||
it('should open the dropdown on click', function() { | ||
this.choices = new Choices(this.input); | ||
const container = this.choices.containerOuter; | ||
@@ -340,2 +338,3 @@ this.choices._onClick({ | ||
it('should close the dropdown on double click', function() { | ||
this.choices = new Choices(this.input); | ||
const container = this.choices.containerOuter; | ||
@@ -359,2 +358,3 @@ | ||
it('should filter choices when searching', function() { | ||
this.choices = new Choices(this.input); | ||
this.choices.input.focus(); | ||
@@ -374,2 +374,28 @@ this.choices.input.value = 'Value 3'; | ||
}); | ||
it('shouldn\'t sort choices if shouldSort is false', function() { | ||
this.choices = new Choices(this.input, { | ||
shouldSort: false, | ||
choices: [ | ||
{value: 'Value 5', label: 'Label Five'}, | ||
{value: 'Value 6', label: 'Label Six'}, | ||
{value: 'Value 7', label: 'Label Seven'}, | ||
], | ||
}); | ||
expect(this.choices.currentState.choices[0].value).toEqual('Value 5'); | ||
}); | ||
it('should sort choices if shouldSort is false', function() { | ||
this.choices = new Choices(this.input, { | ||
shouldSort: true, | ||
choices: [ | ||
{value: 'Value 5', label: 'Label Five'}, | ||
{value: 'Value 6', label: 'Label Six'}, | ||
{value: 'Value 7', label: 'Label Seven'}, | ||
], | ||
}); | ||
expect(this.choices.currentState.choices[0].value).toEqual('Value 1'); | ||
}); | ||
}); | ||
@@ -376,0 +402,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
688239
8279