Ghost/ghost/admin/tests/integration/components/gh-navigation-test.js
Kevin Ansfield 343b2ccbca deps: grunt-jscs@2.1.0
no issue
- update grunt-jscs dependency
- fix deprecated `validateJSDoc` configuration
- fix numerous linting errors, including:
  - use of future-reserved `public` and `private` variable names
  - use of `[]` instead of dot-notation (especially `express['static']` and `cacheRules['x']`)
  - extra spaces in `const { run } = Ember` style constructs

One issue that did become apparent is that there are conflicting rules that prevent the use of object function shorthand such that both of these:

```
{ myFunc() {} }
{ myFunc () {} }
```

are called out due to either the missing or the extra space before the `(`
2015-10-12 19:21:16 +01:00

76 lines
2.8 KiB
JavaScript

/* jshint expr:true */
import { expect } from 'chai';
import { describeComponent, it } from 'ember-mocha';
import hbs from 'htmlbars-inline-precompile';
import Ember from 'ember';
import { NavItem } from 'ghost/controllers/settings/navigation';
const {run} = Ember;
describeComponent(
'gh-navigation',
'Integration: Component: gh-navigation',
{
integration: true
},
function () {
it('renders', function () {
this.render(hbs`{{#gh-navigation}}<div class="js-gh-blognav"><div class="gh-blognav-item"></div></div>{{/gh-navigation}}`);
expect(this.$('section.gh-view')).to.have.length(1);
expect(this.$('.ui-sortable')).to.have.length(1);
});
it('triggers reorder action', function () {
let navItems = [],
expectedOldIndex = -1,
expectedNewIndex = -1;
navItems.pushObject(NavItem.create({label: 'First', url: '/first'}));
navItems.pushObject(NavItem.create({label: 'Second', url: '/second'}));
navItems.pushObject(NavItem.create({label: 'Third', url: '/third'}));
navItems.pushObject(NavItem.create({label: '', url: '', last: true}));
this.set('navigationItems', navItems);
this.set('blogUrl', 'http://localhost:2368');
this.on('moveItem', (oldIndex, newIndex) => {
expect(oldIndex).to.equal(expectedOldIndex);
expect(newIndex).to.equal(expectedNewIndex);
});
run(() => {
this.render(hbs `
{{#gh-navigation moveItem="moveItem"}}
<form id="settings-navigation" class="gh-blognav js-gh-blognav" novalidate="novalidate">
{{#each navigationItems as |navItem|}}
{{gh-navitem navItem=navItem baseUrl=blogUrl addItem="addItem" deleteItem="deleteItem" updateUrl="updateUrl"}}
{{/each}}
</form>
{{/gh-navigation}}`);
});
// check it renders the nav item rows
expect(this.$('.gh-blognav-item')).to.have.length(4);
// move second item up one
expectedOldIndex = 1;
expectedNewIndex = 0;
run(() => {
Ember.$(this.$('.gh-blognav-item')[1]).simulateDragSortable({
move: -1,
handle: '.gh-blognav-grab'
});
});
// move second item down one
expectedOldIndex = 1;
expectedNewIndex = 2;
run(() => {
Ember.$(this.$('.gh-blognav-item')[1]).simulateDragSortable({
move: 1,
handle: '.gh-blognav-grab'
});
});
});
}
);