Ghost/ghost/admin/tests/unit/transforms/navigation-settings-test.js
Austin Burdine cf36851265 deps: grunt-jscs,ember-suave@3.0.0
replaces #41, #60
- update ember-suave and grunt-jscs to 3.0
- standardize Ember global de-structuring rules across app & tests
2016-06-11 13:39:31 -06:00

42 lines
1.5 KiB
JavaScript

/* jshint expr:true */
import { expect } from 'chai';
import { describeModule, it } from 'ember-mocha';
import Ember from 'ember';
import NavigationItem from 'ghost-admin/models/navigation-item';
const {
A: emberA
} = Ember;
describeModule(
'transform:navigation-settings',
'Unit: Transform: navigation-settings',
{},
function() {
it('deserializes navigation json', function () {
let transform = this.subject();
let serialized = '[{"label":"One","url":"/one"},{"label":"Two","url":"/two"}]';
let result = transform.deserialize(serialized);
expect(result.length).to.equal(2);
expect(result[0]).to.be.instanceof(NavigationItem);
expect(result[0].get('label')).to.equal('One');
expect(result[0].get('url')).to.equal('/one');
expect(result[1]).to.be.instanceof(NavigationItem);
expect(result[1].get('label')).to.equal('Two');
expect(result[1].get('url')).to.equal('/two');
});
it('serializes array of NavigationItems', function () {
let transform = this.subject();
let deserialized = emberA([
NavigationItem.create({label: 'One', url: '/one'}),
NavigationItem.create({label: 'Two', url: '/two'})
]);
let result = transform.serialize(deserialized);
expect(result).to.equal('[{"label":"One","url":"/one"},{"label":"Two","url":"/two"}]');
});
}
);