Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tests for delimiter
One batch for a single character (;), and another
for a multi-char string
  • Loading branch information
bruderstein committed Jul 27, 2015
commit b47d788eed8556ff2c5610d2f96d1f68c5f35678
73 changes: 73 additions & 0 deletions test/Select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1025,5 +1025,78 @@ describe('Select', function() {
});
});
});

describe('delimiter', function () {

describe('is ;', function () {

beforeEach(function () {

instance = createControl({
multi: true,
value: 'four;three',
delimiter: ';',
options: defaultOptions
});
});

it('interprets the initial options correctly', function () {

var values = React.findDOMNode(instance).querySelectorAll('.Select-item');

expect(values[0], 'queried for', '.Select-item-label', 'to have items satisfying',
'to have text', 'AbcDef');
expect(values[1], 'queried for', '.Select-item-label', 'to have items satisfying',
'to have text', 'Three');
expect(values, 'to have length', 2);
});

it('adds an additional option with the correct delimiter', function () {

typeSearchText('one');
pressEnterToAccept();
expect(onChange, 'was called with', 'four;three;one', [
{ value: 'four', label: 'AbcDef' },
{ value: 'three', label: 'Three' },
{ value: 'one', label: 'One' }
]);
});
});

describe('is a multi-character string (`==XXX==`)', function () {

beforeEach(function () {

instance = createControl({
multi: true,
value: 'four==XXX==three',
delimiter: '==XXX==',
options: defaultOptions
});
});

it('interprets the initial options correctly', function () {

var values = React.findDOMNode(instance).querySelectorAll('.Select-item');

expect(values[0], 'queried for', '.Select-item-label', 'to have items satisfying',
'to have text', 'AbcDef');
expect(values[1], 'queried for', '.Select-item-label', 'to have items satisfying',
'to have text', 'Three');
expect(values, 'to have length', 2);
});

it('adds an additional option with the correct delimiter', function () {

typeSearchText('one');
pressEnterToAccept();
expect(onChange, 'was called with', 'four==XXX==three==XXX==one', [
{ value: 'four', label: 'AbcDef' },
{ value: 'three', label: 'Three' },
{ value: 'one', label: 'One' }
]);
});
});
});
});
});