Ghost/ghost/admin/tests/unit/components/gh-selectize-test.js

34 lines
1.1 KiB
JavaScript
Raw Normal View History

/* jshint expr:true */
import {expect} from 'chai';
2016-11-24 01:50:57 +03:00
import {describe, it} from 'mocha';
import {setupComponentTest} from 'ember-mocha';
import {A as emberA} from 'ember-array/utils';
import run from 'ember-runloop';
2016-11-24 01:50:57 +03:00
describe('Unit: Component: gh-selectize', function () {
setupComponentTest('gh-selectize', {
// Specify the other units that are required for this test
// needs: ['component:foo', 'helper:bar'],
unit: true
2016-11-24 01:50:57 +03:00
});
2016-11-24 01:50:57 +03:00
it('re-orders selection when selectize order is changed', function () {
let component = this.subject();
2016-11-24 01:50:57 +03:00
run(() => {
component.set('content', emberA(['item 1', 'item 2', 'item 3']));
component.set('selection', emberA(['item 2', 'item 3']));
component.set('multiple', true);
});
2016-11-24 01:50:57 +03:00
this.render();
2016-11-24 01:50:57 +03:00
run(() => {
component._selectize.setValue(['item 3', 'item 2']);
});
2016-11-24 01:50:57 +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']);
});
});