mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
cb59388c5b
no issue - adds `eslint-plugin-sort-imports-es6-autofix` dependency - implements ESLint's base `sort-imports` rule but has a distinction in that `import {foo} from 'bar';` is considered `multiple` rather than `single` - fixes ESLint's autofix behaviour so `eslint --fix` will actually fix the sort order - updates all unordered import rules by using `eslint --fix` With the increased number of `import` statements since Ember+ecosystem started moving towards es6 modules I've found it frustrating at times trying to search through randomly ordered import statements. Recently I've been sorting imports manually when I've added new code or touched old code so I thought I'd add an ESLint rule to codify it.
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
/* jshint expr:true */
|
|
import run from 'ember-runloop';
|
|
import {describe, it} from 'mocha';
|
|
import {A as emberA} from 'ember-array/utils';
|
|
import {expect} from 'chai';
|
|
import {setupComponentTest} from 'ember-mocha';
|
|
|
|
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
|
|
});
|
|
|
|
it('re-orders selection when selectize order is changed', function () {
|
|
let component = this.subject();
|
|
|
|
let item1 = {id: '1', name: 'item 1'};
|
|
let item2 = {id: '2', name: 'item 2'};
|
|
let item3 = {id: '3', name: 'item 3'};
|
|
|
|
run(() => {
|
|
component.set('content', emberA([item1, item2, item3]));
|
|
component.set('selection', emberA([item2, item3]));
|
|
component.set('multiple', true);
|
|
component.set('optionValuePath', 'content.id');
|
|
component.set('optionLabelPath', 'content.name');
|
|
});
|
|
|
|
this.render();
|
|
|
|
run(() => {
|
|
component._selectize.setValue(['3', '2']);
|
|
});
|
|
|
|
expect(component.get('selection').toArray(), 'component selection').to.deep.equal([item3, item2]);
|
|
});
|
|
});
|