2016-04-26 12:45:59 +03:00
|
|
|
/* jshint expr:true */
|
2017-05-29 21:50:03 +03:00
|
|
|
import NavigationItem from 'ghost-admin/models/navigation-item';
|
2016-11-24 01:50:57 +03:00
|
|
|
import {describe, it} from 'mocha';
|
2017-08-22 10:53:26 +03:00
|
|
|
import {A as emberA} from '@ember/array';
|
2017-05-29 21:50:03 +03:00
|
|
|
import {expect} from 'chai';
|
|
|
|
import {setupTest} from 'ember-mocha';
|
2016-04-26 12:45:59 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
describe('Unit: Transform: navigation-settings', function() {
|
|
|
|
setupTest('transform:navigation-settings', {});
|
|
|
|
it('deserializes navigation json', function () {
|
|
|
|
let transform = this.subject();
|
|
|
|
let serialized = '[{"label":"One","url":"/one"},{"label":"Two","url":"/two"}]';
|
|
|
|
let result = transform.deserialize(serialized);
|
2016-04-26 12:45:59 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
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');
|
|
|
|
});
|
2016-04-26 12:45:59 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
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);
|
2016-04-26 12:45:59 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
expect(result).to.equal('[{"label":"One","url":"/one"},{"label":"Two","url":"/two"}]');
|
|
|
|
});
|
|
|
|
});
|