2015-10-26 19:02:28 +03:00
|
|
|
/* jshint expr:true */
|
2016-11-14 16:16:51 +03:00
|
|
|
import {expect} from 'chai';
|
2015-10-26 19:02:28 +03:00
|
|
|
import {
|
|
|
|
describeComponent,
|
|
|
|
it
|
|
|
|
} from 'ember-mocha';
|
2016-06-30 13:21:47 +03:00
|
|
|
import {A as emberA} from 'ember-array/utils';
|
|
|
|
import run from 'ember-runloop';
|
2015-10-26 19:02:28 +03:00
|
|
|
|
|
|
|
describeComponent(
|
|
|
|
'gh-selectize',
|
|
|
|
'Unit: Component: gh-selectize',
|
|
|
|
{
|
|
|
|
// Specify the other units that are required for this test
|
|
|
|
// needs: ['component:foo', 'helper:bar'],
|
|
|
|
unit: true
|
|
|
|
},
|
|
|
|
function () {
|
|
|
|
it('re-orders selection when selectize order is changed', function () {
|
2015-10-28 14:36:45 +03:00
|
|
|
let component = this.subject();
|
2015-10-26 19:02:28 +03:00
|
|
|
|
|
|
|
run(() => {
|
2015-10-28 14:36:45 +03:00
|
|
|
component.set('content', emberA(['item 1', 'item 2', 'item 3']));
|
|
|
|
component.set('selection', emberA(['item 2', 'item 3']));
|
2015-10-26 19:02:28 +03:00
|
|
|
component.set('multiple', true);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.render();
|
|
|
|
|
|
|
|
run(() => {
|
|
|
|
component._selectize.setValue(['item 3', 'item 2']);
|
|
|
|
});
|
|
|
|
|
2016-08-06 10:04:06 +03:00
|
|
|
expect(component.get('value').toArray(), 'component value').to.deep.equal(['item 3', 'item 2']);
|
|
|
|
expect(component.get('selection').toArray(), 'component selection').to.deep.equal(['item 3', 'item 2']);
|
2015-10-26 19:02:28 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|