mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-02 08:13:34 +03:00
753681e9e9
no issue - standardize on "{TestType}: {ModuleType}: {module-name}" for test description strings - standardize on `{module-name}-test.js` for test file names - fix deprecation notices for ember component unit tests without explicit `unit: test` or `needs: []`
92 lines
2.8 KiB
JavaScript
92 lines
2.8 KiB
JavaScript
import Ember from 'ember';
|
|
import {
|
|
describeModule,
|
|
it
|
|
} from 'ember-mocha';
|
|
|
|
describeModule(
|
|
'controller:settings/general',
|
|
'Unit: Controller: settings/general',
|
|
{
|
|
needs: ['service:notifications']
|
|
},
|
|
|
|
function () {
|
|
it('isDatedPermalinks should be correct', function () {
|
|
var controller = this.subject({
|
|
model: Ember.Object.create({
|
|
permalinks: '/:year/:month/:day/:slug/'
|
|
})
|
|
});
|
|
|
|
expect(controller.get('isDatedPermalinks')).to.be.ok;
|
|
|
|
Ember.run(function () {
|
|
controller.set('model.permalinks', '/:slug/');
|
|
|
|
expect(controller.get('isDatedPermalinks')).to.not.be.ok;
|
|
});
|
|
});
|
|
|
|
it('setting isDatedPermalinks should switch between dated and slug', function () {
|
|
var controller = this.subject({
|
|
model: Ember.Object.create({
|
|
permalinks: '/:year/:month/:day/:slug/'
|
|
})
|
|
});
|
|
|
|
Ember.run(function () {
|
|
controller.set('isDatedPermalinks', false);
|
|
|
|
expect(controller.get('isDatedPermalinks')).to.not.be.ok;
|
|
expect(controller.get('model.permalinks')).to.equal('/:slug/');
|
|
});
|
|
|
|
Ember.run(function () {
|
|
controller.set('isDatedPermalinks', true);
|
|
|
|
expect(controller.get('isDatedPermalinks')).to.be.ok;
|
|
expect(controller.get('model.permalinks')).to.equal('/:year/:month/:day/:slug/');
|
|
});
|
|
});
|
|
|
|
it('themes should be correct', function () {
|
|
var controller,
|
|
themes = [];
|
|
|
|
themes.push({
|
|
name: 'casper',
|
|
active: true,
|
|
package: {
|
|
name: 'Casper',
|
|
version: '1.1.5'
|
|
}
|
|
});
|
|
|
|
themes.push({
|
|
name: 'rasper',
|
|
package: {
|
|
name: 'Rasper',
|
|
version: '1.0.0'
|
|
}
|
|
});
|
|
|
|
controller = this.subject({
|
|
model: Ember.Object.create({
|
|
availableThemes: themes
|
|
})
|
|
});
|
|
|
|
themes = controller.get('themes');
|
|
expect(themes).to.be.an.Array;
|
|
expect(themes.length).to.equal(2);
|
|
expect(themes.objectAt(0).name).to.equal('casper');
|
|
expect(themes.objectAt(0).active).to.be.ok;
|
|
expect(themes.objectAt(0).label).to.equal('Casper - 1.1.5');
|
|
expect(themes.objectAt(1).name).to.equal('rasper');
|
|
expect(themes.objectAt(1).active).to.not.be.ok;
|
|
expect(themes.objectAt(1).label).to.equal('Rasper - 1.0.0');
|
|
});
|
|
}
|
|
);
|