diff --git a/package.json b/package.json
index 0e884daf5..74918147f 100644
--- a/package.json
+++ b/package.json
@@ -78,7 +78,7 @@
"ember-infinity": "1.4.7",
"ember-load": "0.0.17",
"ember-load-initializers": "2.0.0",
- "ember-mocha": "0.15.1",
+ "ember-mocha": "0.16.0",
"ember-moment": "7.8.1",
"ember-one-way-select": "4.0.0",
"ember-power-calendar-moment": "0.1.7",
diff --git a/tests/acceptance/settings/tags-test.js b/tests/acceptance/settings/tags-test.js
index 0cef97e36..ab3aea862 100644
--- a/tests/acceptance/settings/tags-test.js
+++ b/tests/acceptance/settings/tags-test.js
@@ -4,7 +4,6 @@ import {Response} from 'ember-cli-mirage';
import {afterEach, beforeEach, describe, it} from 'mocha';
import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-support';
import {blur, click, currentRouteName, currentURL, fillIn, find, findAll} from '@ember/test-helpers';
-import {errorOverride, errorReset} from 'ghost-admin/tests/helpers/adapter-error';
import {expect} from 'chai';
import {run} from '@ember/runloop';
import {setupApplicationTest} from 'ember-mocha';
@@ -312,11 +311,8 @@ describe('Acceptance: Settings - Tags', function () {
return new Response(404, {'Content-Type': 'application/json'}, {errors: [{message: 'Tag not found.', type: 'NotFoundError'}]});
});
- errorOverride();
-
await visit('settings/tags/unknown');
- errorReset();
expect(currentRouteName()).to.equal('error404');
expect(currentURL()).to.equal('/settings/tags/unknown');
});
diff --git a/tests/acceptance/staff-test.js b/tests/acceptance/staff-test.js
index f9856c0a3..0428dbfd7 100644
--- a/tests/acceptance/staff-test.js
+++ b/tests/acceptance/staff-test.js
@@ -16,7 +16,6 @@ import {
triggerEvent,
triggerKeyEvent
} from '@ember/test-helpers';
-import {errorOverride, errorReset} from '../helpers/adapter-error';
import {expect} from 'chai';
import {setupApplicationTest} from 'ember-mocha';
import {setupMirage} from 'ember-cli-mirage/test-support';
@@ -877,11 +876,8 @@ describe('Acceptance: Staff', function () {
return new Response(404, {'Content-Type': 'application/json'}, {errors: [{message: 'User not found.', type: 'NotFoundError'}]});
});
- errorOverride();
-
await visit('/staff/unknown');
- errorReset();
expect(currentRouteName()).to.equal('error404');
expect(currentURL()).to.equal('/staff/unknown');
});
@@ -911,11 +907,8 @@ describe('Acceptance: Staff', function () {
this.server.create('user', {roles: [adminRole]});
this.server.create('invite', {role: authorRole});
- errorOverride();
-
await visit('/staff');
- errorReset();
expect(currentRouteName()).to.equal('staff.index');
expect(findAll('.gh-alert').length).to.equal(0);
});
diff --git a/tests/helpers/adapter-error.js b/tests/helpers/adapter-error.js
deleted file mode 100644
index 371a6d658..000000000
--- a/tests/helpers/adapter-error.js
+++ /dev/null
@@ -1,22 +0,0 @@
-import Ember from 'ember';
-import Test from 'ember-test'; // eslint-disable-line
-
-// This is needed for testing error responses in acceptance tests
-// See http://williamsbdev.com/posts/testing-rsvp-errors-handled-globally/
-
-// ember-cli-shims doesn't export Logger
-const {Logger} = Ember;
-
-let originalException, originalLoggerError;
-
-export function errorOverride() {
- originalException = Test.adapter.exception;
- originalLoggerError = Logger.error;
- Test.adapter.exception = function () {};
- Logger.error = function () {};
-}
-
-export function errorReset() {
- Test.adapter.exception = originalException;
- Logger.error = originalLoggerError;
-}
diff --git a/tests/unit/components/gh-post-settings-menu-test.js b/tests/unit/components/gh-post-settings-menu-test.js
index 513b2e28f..94a3149c8 100644
--- a/tests/unit/components/gh-post-settings-menu-test.js
+++ b/tests/unit/components/gh-post-settings-menu-test.js
@@ -1,531 +1,533 @@
-/* eslint-disable camelcase */
-import EmberObject from '@ember/object';
-import RSVP from 'rsvp';
-import boundOneWay from 'ghost-admin/utils/bound-one-way';
-import {describe, it} from 'mocha';
-import {expect} from 'chai';
-import {run} from '@ember/runloop';
-import {setupComponentTest} from 'ember-mocha';
+// /* eslint-disable camelcase */
+// import EmberObject from '@ember/object';
+// import RSVP from 'rsvp';
+// import boundOneWay from 'ghost-admin/utils/bound-one-way';
+// import {describe, it} from 'mocha';
+// import {expect} from 'chai';
+// import {run} from '@ember/runloop';
+// import {setupComponentTest} from 'ember-mocha';
-function K() {
- return this;
-}
+// function K() {
+// return this;
+// }
// TODO: convert to integration tests
-describe.skip('Unit: Component: post-settings-menu', function () {
- setupComponentTest('gh-post-settings-menu', {
- needs: ['service:notifications', 'service:slug-generator', 'service:settings']
- });
-
- it('slugValue is one-way bound to post.slug', function () {
- let component = this.subject({
- post: EmberObject.create({
- slug: 'a-slug'
- })
- });
-
- expect(component.get('post.slug')).to.equal('a-slug');
- expect(component.get('slugValue')).to.equal('a-slug');
-
- run(function () {
- component.set('post.slug', 'changed-slug');
-
- expect(component.get('slugValue')).to.equal('changed-slug');
- });
-
- run(function () {
- component.set('slugValue', 'changed-directly');
-
- expect(component.get('post.slug')).to.equal('changed-slug');
- expect(component.get('slugValue')).to.equal('changed-directly');
- });
-
- run(function () {
- // test that the one-way binding is still in place
- component.set('post.slug', 'should-update');
-
- expect(component.get('slugValue')).to.equal('should-update');
- });
- });
-
- it('metaTitleScratch is one-way bound to post.metaTitle', function () {
- let component = this.subject({
- post: EmberObject.extend({
- metaTitle: 'a title',
- metaTitleScratch: boundOneWay('metaTitle')
- }).create()
- });
-
- expect(component.get('post.metaTitle')).to.equal('a title');
- expect(component.get('metaTitleScratch')).to.equal('a title');
-
- run(function () {
- component.set('post.metaTitle', 'a different title');
-
- expect(component.get('metaTitleScratch')).to.equal('a different title');
- });
-
- run(function () {
- component.set('metaTitleScratch', 'changed directly');
-
- expect(component.get('post.metaTitle')).to.equal('a different title');
- expect(component.get('post.metaTitleScratch')).to.equal('changed directly');
- });
-
- run(function () {
- // test that the one-way binding is still in place
- component.set('post.metaTitle', 'should update');
-
- expect(component.get('metaTitleScratch')).to.equal('should update');
- });
- });
-
- it('metaDescriptionScratch is one-way bound to post.metaDescription', function () {
- let component = this.subject({
- post: EmberObject.extend({
- metaDescription: 'a description',
- metaDescriptionScratch: boundOneWay('metaDescription')
- }).create()
- });
-
- expect(component.get('post.metaDescription')).to.equal('a description');
- expect(component.get('metaDescriptionScratch')).to.equal('a description');
-
- run(function () {
- component.set('post.metaDescription', 'a different description');
-
- expect(component.get('metaDescriptionScratch')).to.equal('a different description');
- });
-
- run(function () {
- component.set('metaDescriptionScratch', 'changed directly');
-
- expect(component.get('post.metaDescription')).to.equal('a different description');
- expect(component.get('metaDescriptionScratch')).to.equal('changed directly');
- });
-
- run(function () {
- // test that the one-way binding is still in place
- component.set('post.metaDescription', 'should update');
-
- expect(component.get('metaDescriptionScratch')).to.equal('should update');
- });
- });
-
- describe('seoTitle', function () {
- it('should be the metaTitle if one exists', function () {
- let component = this.subject({
- post: EmberObject.extend({
- titleScratch: 'should not be used',
- metaTitle: 'a meta-title',
- metaTitleScratch: boundOneWay('metaTitle')
- }).create()
- });
-
- expect(component.get('seoTitle')).to.equal('a meta-title');
- });
-
- it('should default to the title if an explicit meta-title does not exist', function () {
- let component = this.subject({
- post: EmberObject.create({
- titleScratch: 'should be the meta-title'
- })
- });
-
- expect(component.get('seoTitle')).to.equal('should be the meta-title');
- });
-
- it('should be the metaTitle if both title and metaTitle exist', function () {
- let component = this.subject({
- post: EmberObject.extend({
- titleScratch: 'a title',
- metaTitle: 'a meta-title',
- metaTitleScratch: boundOneWay('metaTitle')
- }).create()
- });
-
- expect(component.get('seoTitle')).to.equal('a meta-title');
- });
-
- it('should revert to the title if explicit metaTitle is removed', function () {
- let component = this.subject({
- post: EmberObject.extend({
- titleScratch: 'a title',
- metaTitle: 'a meta-title',
- metaTitleScratch: boundOneWay('metaTitle')
- }).create()
- });
-
- expect(component.get('seoTitle')).to.equal('a meta-title');
-
- run(function () {
- component.set('post.metaTitle', '');
-
- expect(component.get('seoTitle')).to.equal('a title');
- });
- });
-
- it('should truncate to 70 characters with an appended ellipsis', function () {
- let longTitle = new Array(100).join('a');
- let component = this.subject({
- post: EmberObject.create()
- });
-
- expect(longTitle.length).to.equal(99);
-
- run(function () {
- let expected = `${longTitle.substr(0, 70)}…`;
-
- component.set('metaTitleScratch', longTitle);
-
- expect(component.get('seoTitle').toString().length).to.equal(78);
- expect(component.get('seoTitle').toString()).to.equal(expected);
- });
- });
- });
-
- describe('seoDescription', function () {
- it('should be the metaDescription if one exists', function () {
- let component = this.subject({
- post: EmberObject.extend({
- metaDescription: 'a description',
- metaDescriptionScratch: boundOneWay('metaDescription')
- }).create()
- });
-
- expect(component.get('seoDescription')).to.equal('a description');
- });
-
- it('should be generated from the rendered mobiledoc if not explicitly set', function () {
- let component = this.subject({
- post: EmberObject.extend({
- metaDescription: null,
- metaDescriptionScratch: boundOneWay('metaDescription'),
- author: RSVP.resolve(),
-
- init() {
- this._super(...arguments);
- this.scratch = {
- cards: [
- ['markdown-card', {
- markdown: '# This is a test '
- }]
- ]
- };
- }
- }).create()
- });
-
- expect(component.get('seoDescription')).to.equal('This is a test');
- });
-
- it('should truncate to 156 characters with an appended ellipsis', function () {
- let longDescription = new Array(200).join('a');
- let component = this.subject({
- post: EmberObject.create()
- });
-
- expect(longDescription.length).to.equal(199);
-
- run(function () {
- let expected = `${longDescription.substr(0, 156)}…`;
-
- component.set('metaDescriptionScratch', longDescription);
-
- expect(component.get('seoDescription').toString().length).to.equal(164);
- expect(component.get('seoDescription').toString()).to.equal(expected);
- });
- });
- });
-
- describe('seoURL', function () {
- it('should be the URL of the blog if no post slug exists', function () {
- let component = this.subject({
- config: EmberObject.create({blogUrl: 'http://my-ghost-blog.com'}),
- post: EmberObject.create()
- });
-
- expect(component.get('seoURL')).to.equal('http://my-ghost-blog.com/');
- });
-
- it('should be the URL of the blog plus the post slug', function () {
- let component = this.subject({
- config: EmberObject.create({blogUrl: 'http://my-ghost-blog.com'}),
- post: EmberObject.create({slug: 'post-slug'})
- });
-
- expect(component.get('seoURL')).to.equal('http://my-ghost-blog.com/post-slug/');
- });
-
- it('should update when the post slug changes', function () {
- let component = this.subject({
- config: EmberObject.create({blogUrl: 'http://my-ghost-blog.com'}),
- post: EmberObject.create({slug: 'post-slug'})
- });
-
- expect(component.get('seoURL')).to.equal('http://my-ghost-blog.com/post-slug/');
-
- run(function () {
- component.set('post.slug', 'changed-slug');
-
- expect(component.get('seoURL')).to.equal('http://my-ghost-blog.com/changed-slug/');
- });
- });
-
- it('should truncate a long URL to 70 characters with an appended ellipsis', function () {
- let blogURL = 'http://my-ghost-blog.com';
- let longSlug = new Array(75).join('a');
- let component = this.subject({
- config: EmberObject.create({blogUrl: blogURL}),
- post: EmberObject.create({slug: longSlug})
- });
- let expected;
-
- expect(longSlug.length).to.equal(74);
-
- expected = `${blogURL}/${longSlug}/`;
- expected = `${expected.substr(0, 70)}…`;
-
- expect(component.get('seoURL').toString().length).to.equal(78);
- expect(component.get('seoURL').toString()).to.equal(expected);
- });
- });
-
- describe('toggleFeatured', function () {
- it('should toggle the featured property', function () {
- let component = this.subject({
- post: EmberObject.create({
- featured: false,
- isNew: true
- })
- });
-
- run(function () {
- component.send('toggleFeatured');
-
- expect(component.get('post.featured')).to.be.ok;
- });
- });
-
- it('should not save the post if it is still new', function () {
- let component = this.subject({
- post: EmberObject.create({
- featured: false,
- isNew: true,
- save() {
- this.incrementProperty('saved');
- return RSVP.resolve();
- }
- })
- });
-
- run(function () {
- component.send('toggleFeatured');
-
- expect(component.get('post.featured')).to.be.ok;
- expect(component.get('post.saved')).to.not.be.ok;
- });
- });
-
- it('should save the post if it is not new', function () {
- let component = this.subject({
- post: EmberObject.create({
- featured: false,
- isNew: false,
- save() {
- this.incrementProperty('saved');
- return RSVP.resolve();
- }
- })
- });
-
- run(function () {
- component.send('toggleFeatured');
-
- expect(component.get('post.featured')).to.be.ok;
- expect(component.get('post.saved')).to.equal(1);
- });
- });
- });
-
- describe('updateSlug', function () {
- it('should reset slugValue to the previous slug when the new slug is blank or unchanged', function () {
- let component = this.subject({
- post: EmberObject.create({
- slug: 'slug'
- })
- });
-
- run(function () {
- // unchanged
- component.set('slugValue', 'slug');
- component.send('updateSlug', component.get('slugValue'));
-
- expect(component.get('post.slug')).to.equal('slug');
- expect(component.get('slugValue')).to.equal('slug');
- });
-
- run(function () {
- // unchanged after trim
- component.set('slugValue', 'slug ');
- component.send('updateSlug', component.get('slugValue'));
-
- expect(component.get('post.slug')).to.equal('slug');
- expect(component.get('slugValue')).to.equal('slug');
- });
-
- run(function () {
- // blank
- component.set('slugValue', '');
- component.send('updateSlug', component.get('slugValue'));
-
- expect(component.get('post.slug')).to.equal('slug');
- expect(component.get('slugValue')).to.equal('slug');
- });
- });
-
- it('should not set a new slug if the server-generated slug matches existing slug', function (done) {
- let component = this.subject({
- slugGenerator: EmberObject.create({
- generateSlug(slugType, str) {
- let promise = RSVP.resolve(str.split('#')[0]);
- this.set('lastPromise', promise);
- return promise;
- }
- }),
- post: EmberObject.create({
- slug: 'whatever'
- })
- });
-
- run(function () {
- component.set('slugValue', 'whatever#slug');
- component.send('updateSlug', component.get('slugValue'));
-
- RSVP.resolve(component.get('lastPromise')).then(function () {
- expect(component.get('post.slug')).to.equal('whatever');
-
- done();
- }).catch(done);
- });
- });
-
- it('should not set a new slug if the only change is to the appended increment value', function (done) {
- let component = this.subject({
- slugGenerator: EmberObject.create({
- generateSlug(slugType, str) {
- let sanitizedStr = str.replace(/[^a-zA-Z]/g, '');
- let promise = RSVP.resolve(`${sanitizedStr}-2`);
- this.set('lastPromise', promise);
- return promise;
- }
- }),
- post: EmberObject.create({
- slug: 'whatever'
- })
- });
-
- run(function () {
- component.set('slugValue', 'whatever!');
- component.send('updateSlug', component.get('slugValue'));
-
- RSVP.resolve(component.get('lastPromise')).then(function () {
- expect(component.get('post.slug')).to.equal('whatever');
-
- done();
- }).catch(done);
- });
- });
-
- it('should set the slug if the new slug is different', function (done) {
- let component = this.subject({
- slugGenerator: EmberObject.create({
- generateSlug(slugType, str) {
- let promise = RSVP.resolve(str);
- this.set('lastPromise', promise);
- return promise;
- }
- }),
- post: EmberObject.create({
- slug: 'whatever',
- save: K
- })
- });
-
- run(function () {
- component.set('slugValue', 'changed');
- component.send('updateSlug', component.get('slugValue'));
-
- RSVP.resolve(component.get('lastPromise')).then(function () {
- expect(component.get('post.slug')).to.equal('changed');
-
- done();
- }).catch(done);
- });
- });
-
- it('should save the post when the slug changes and the post is not new', function (done) {
- let component = this.subject({
- slugGenerator: EmberObject.create({
- generateSlug(slugType, str) {
- let promise = RSVP.resolve(str);
- this.set('lastPromise', promise);
- return promise;
- }
- }),
- post: EmberObject.create({
- slug: 'whatever',
- saved: 0,
- isNew: false,
- save() {
- this.incrementProperty('saved');
- }
- })
- });
-
- run(function () {
- component.set('slugValue', 'changed');
- component.send('updateSlug', component.get('slugValue'));
-
- RSVP.resolve(component.get('lastPromise')).then(function () {
- expect(component.get('post.slug')).to.equal('changed');
- expect(component.get('post.saved')).to.equal(1);
-
- done();
- }).catch(done);
- });
- });
-
- it('should not save the post when the slug changes and the post is new', function (done) {
- let component = this.subject({
- slugGenerator: EmberObject.create({
- generateSlug(slugType, str) {
- let promise = RSVP.resolve(str);
- this.set('lastPromise', promise);
- return promise;
- }
- }),
- post: EmberObject.create({
- slug: 'whatever',
- saved: 0,
- isNew: true,
- save() {
- this.incrementProperty('saved');
- }
- })
- });
-
- run(function () {
- component.set('slugValue', 'changed');
- component.send('updateSlug', component.get('slugValue'));
-
- RSVP.resolve(component.get('lastPromise')).then(function () {
- expect(component.get('post.slug')).to.equal('changed');
- expect(component.get('post.saved')).to.equal(0);
-
- done();
- }).catch(done);
- });
- });
- });
-});
+// (commented out because top-level describe.skip was tripping up ember-mocha)
+
+// describe('Unit: Component: post-settings-menu', function () {
+// setupComponentTest('gh-post-settings-menu', {
+// needs: ['service:notifications', 'service:slug-generator', 'service:settings']
+// });
+
+// it('slugValue is one-way bound to post.slug', function () {
+// let component = this.subject({
+// post: EmberObject.create({
+// slug: 'a-slug'
+// })
+// });
+
+// expect(component.get('post.slug')).to.equal('a-slug');
+// expect(component.get('slugValue')).to.equal('a-slug');
+
+// run(function () {
+// component.set('post.slug', 'changed-slug');
+
+// expect(component.get('slugValue')).to.equal('changed-slug');
+// });
+
+// run(function () {
+// component.set('slugValue', 'changed-directly');
+
+// expect(component.get('post.slug')).to.equal('changed-slug');
+// expect(component.get('slugValue')).to.equal('changed-directly');
+// });
+
+// run(function () {
+// // test that the one-way binding is still in place
+// component.set('post.slug', 'should-update');
+
+// expect(component.get('slugValue')).to.equal('should-update');
+// });
+// });
+
+// it('metaTitleScratch is one-way bound to post.metaTitle', function () {
+// let component = this.subject({
+// post: EmberObject.extend({
+// metaTitle: 'a title',
+// metaTitleScratch: boundOneWay('metaTitle')
+// }).create()
+// });
+
+// expect(component.get('post.metaTitle')).to.equal('a title');
+// expect(component.get('metaTitleScratch')).to.equal('a title');
+
+// run(function () {
+// component.set('post.metaTitle', 'a different title');
+
+// expect(component.get('metaTitleScratch')).to.equal('a different title');
+// });
+
+// run(function () {
+// component.set('metaTitleScratch', 'changed directly');
+
+// expect(component.get('post.metaTitle')).to.equal('a different title');
+// expect(component.get('post.metaTitleScratch')).to.equal('changed directly');
+// });
+
+// run(function () {
+// // test that the one-way binding is still in place
+// component.set('post.metaTitle', 'should update');
+
+// expect(component.get('metaTitleScratch')).to.equal('should update');
+// });
+// });
+
+// it('metaDescriptionScratch is one-way bound to post.metaDescription', function () {
+// let component = this.subject({
+// post: EmberObject.extend({
+// metaDescription: 'a description',
+// metaDescriptionScratch: boundOneWay('metaDescription')
+// }).create()
+// });
+
+// expect(component.get('post.metaDescription')).to.equal('a description');
+// expect(component.get('metaDescriptionScratch')).to.equal('a description');
+
+// run(function () {
+// component.set('post.metaDescription', 'a different description');
+
+// expect(component.get('metaDescriptionScratch')).to.equal('a different description');
+// });
+
+// run(function () {
+// component.set('metaDescriptionScratch', 'changed directly');
+
+// expect(component.get('post.metaDescription')).to.equal('a different description');
+// expect(component.get('metaDescriptionScratch')).to.equal('changed directly');
+// });
+
+// run(function () {
+// // test that the one-way binding is still in place
+// component.set('post.metaDescription', 'should update');
+
+// expect(component.get('metaDescriptionScratch')).to.equal('should update');
+// });
+// });
+
+// describe('seoTitle', function () {
+// it('should be the metaTitle if one exists', function () {
+// let component = this.subject({
+// post: EmberObject.extend({
+// titleScratch: 'should not be used',
+// metaTitle: 'a meta-title',
+// metaTitleScratch: boundOneWay('metaTitle')
+// }).create()
+// });
+
+// expect(component.get('seoTitle')).to.equal('a meta-title');
+// });
+
+// it('should default to the title if an explicit meta-title does not exist', function () {
+// let component = this.subject({
+// post: EmberObject.create({
+// titleScratch: 'should be the meta-title'
+// })
+// });
+
+// expect(component.get('seoTitle')).to.equal('should be the meta-title');
+// });
+
+// it('should be the metaTitle if both title and metaTitle exist', function () {
+// let component = this.subject({
+// post: EmberObject.extend({
+// titleScratch: 'a title',
+// metaTitle: 'a meta-title',
+// metaTitleScratch: boundOneWay('metaTitle')
+// }).create()
+// });
+
+// expect(component.get('seoTitle')).to.equal('a meta-title');
+// });
+
+// it('should revert to the title if explicit metaTitle is removed', function () {
+// let component = this.subject({
+// post: EmberObject.extend({
+// titleScratch: 'a title',
+// metaTitle: 'a meta-title',
+// metaTitleScratch: boundOneWay('metaTitle')
+// }).create()
+// });
+
+// expect(component.get('seoTitle')).to.equal('a meta-title');
+
+// run(function () {
+// component.set('post.metaTitle', '');
+
+// expect(component.get('seoTitle')).to.equal('a title');
+// });
+// });
+
+// it('should truncate to 70 characters with an appended ellipsis', function () {
+// let longTitle = new Array(100).join('a');
+// let component = this.subject({
+// post: EmberObject.create()
+// });
+
+// expect(longTitle.length).to.equal(99);
+
+// run(function () {
+// let expected = `${longTitle.substr(0, 70)}…`;
+
+// component.set('metaTitleScratch', longTitle);
+
+// expect(component.get('seoTitle').toString().length).to.equal(78);
+// expect(component.get('seoTitle').toString()).to.equal(expected);
+// });
+// });
+// });
+
+// describe('seoDescription', function () {
+// it('should be the metaDescription if one exists', function () {
+// let component = this.subject({
+// post: EmberObject.extend({
+// metaDescription: 'a description',
+// metaDescriptionScratch: boundOneWay('metaDescription')
+// }).create()
+// });
+
+// expect(component.get('seoDescription')).to.equal('a description');
+// });
+
+// it('should be generated from the rendered mobiledoc if not explicitly set', function () {
+// let component = this.subject({
+// post: EmberObject.extend({
+// metaDescription: null,
+// metaDescriptionScratch: boundOneWay('metaDescription'),
+// author: RSVP.resolve(),
+
+// init() {
+// this._super(...arguments);
+// this.scratch = {
+// cards: [
+// ['markdown-card', {
+// markdown: '# This is a test '
+// }]
+// ]
+// };
+// }
+// }).create()
+// });
+
+// expect(component.get('seoDescription')).to.equal('This is a test');
+// });
+
+// it('should truncate to 156 characters with an appended ellipsis', function () {
+// let longDescription = new Array(200).join('a');
+// let component = this.subject({
+// post: EmberObject.create()
+// });
+
+// expect(longDescription.length).to.equal(199);
+
+// run(function () {
+// let expected = `${longDescription.substr(0, 156)}…`;
+
+// component.set('metaDescriptionScratch', longDescription);
+
+// expect(component.get('seoDescription').toString().length).to.equal(164);
+// expect(component.get('seoDescription').toString()).to.equal(expected);
+// });
+// });
+// });
+
+// describe('seoURL', function () {
+// it('should be the URL of the blog if no post slug exists', function () {
+// let component = this.subject({
+// config: EmberObject.create({blogUrl: 'http://my-ghost-blog.com'}),
+// post: EmberObject.create()
+// });
+
+// expect(component.get('seoURL')).to.equal('http://my-ghost-blog.com/');
+// });
+
+// it('should be the URL of the blog plus the post slug', function () {
+// let component = this.subject({
+// config: EmberObject.create({blogUrl: 'http://my-ghost-blog.com'}),
+// post: EmberObject.create({slug: 'post-slug'})
+// });
+
+// expect(component.get('seoURL')).to.equal('http://my-ghost-blog.com/post-slug/');
+// });
+
+// it('should update when the post slug changes', function () {
+// let component = this.subject({
+// config: EmberObject.create({blogUrl: 'http://my-ghost-blog.com'}),
+// post: EmberObject.create({slug: 'post-slug'})
+// });
+
+// expect(component.get('seoURL')).to.equal('http://my-ghost-blog.com/post-slug/');
+
+// run(function () {
+// component.set('post.slug', 'changed-slug');
+
+// expect(component.get('seoURL')).to.equal('http://my-ghost-blog.com/changed-slug/');
+// });
+// });
+
+// it('should truncate a long URL to 70 characters with an appended ellipsis', function () {
+// let blogURL = 'http://my-ghost-blog.com';
+// let longSlug = new Array(75).join('a');
+// let component = this.subject({
+// config: EmberObject.create({blogUrl: blogURL}),
+// post: EmberObject.create({slug: longSlug})
+// });
+// let expected;
+
+// expect(longSlug.length).to.equal(74);
+
+// expected = `${blogURL}/${longSlug}/`;
+// expected = `${expected.substr(0, 70)}…`;
+
+// expect(component.get('seoURL').toString().length).to.equal(78);
+// expect(component.get('seoURL').toString()).to.equal(expected);
+// });
+// });
+
+// describe('toggleFeatured', function () {
+// it('should toggle the featured property', function () {
+// let component = this.subject({
+// post: EmberObject.create({
+// featured: false,
+// isNew: true
+// })
+// });
+
+// run(function () {
+// component.send('toggleFeatured');
+
+// expect(component.get('post.featured')).to.be.ok;
+// });
+// });
+
+// it('should not save the post if it is still new', function () {
+// let component = this.subject({
+// post: EmberObject.create({
+// featured: false,
+// isNew: true,
+// save() {
+// this.incrementProperty('saved');
+// return RSVP.resolve();
+// }
+// })
+// });
+
+// run(function () {
+// component.send('toggleFeatured');
+
+// expect(component.get('post.featured')).to.be.ok;
+// expect(component.get('post.saved')).to.not.be.ok;
+// });
+// });
+
+// it('should save the post if it is not new', function () {
+// let component = this.subject({
+// post: EmberObject.create({
+// featured: false,
+// isNew: false,
+// save() {
+// this.incrementProperty('saved');
+// return RSVP.resolve();
+// }
+// })
+// });
+
+// run(function () {
+// component.send('toggleFeatured');
+
+// expect(component.get('post.featured')).to.be.ok;
+// expect(component.get('post.saved')).to.equal(1);
+// });
+// });
+// });
+
+// describe('updateSlug', function () {
+// it('should reset slugValue to the previous slug when the new slug is blank or unchanged', function () {
+// let component = this.subject({
+// post: EmberObject.create({
+// slug: 'slug'
+// })
+// });
+
+// run(function () {
+// // unchanged
+// component.set('slugValue', 'slug');
+// component.send('updateSlug', component.get('slugValue'));
+
+// expect(component.get('post.slug')).to.equal('slug');
+// expect(component.get('slugValue')).to.equal('slug');
+// });
+
+// run(function () {
+// // unchanged after trim
+// component.set('slugValue', 'slug ');
+// component.send('updateSlug', component.get('slugValue'));
+
+// expect(component.get('post.slug')).to.equal('slug');
+// expect(component.get('slugValue')).to.equal('slug');
+// });
+
+// run(function () {
+// // blank
+// component.set('slugValue', '');
+// component.send('updateSlug', component.get('slugValue'));
+
+// expect(component.get('post.slug')).to.equal('slug');
+// expect(component.get('slugValue')).to.equal('slug');
+// });
+// });
+
+// it('should not set a new slug if the server-generated slug matches existing slug', function (done) {
+// let component = this.subject({
+// slugGenerator: EmberObject.create({
+// generateSlug(slugType, str) {
+// let promise = RSVP.resolve(str.split('#')[0]);
+// this.set('lastPromise', promise);
+// return promise;
+// }
+// }),
+// post: EmberObject.create({
+// slug: 'whatever'
+// })
+// });
+
+// run(function () {
+// component.set('slugValue', 'whatever#slug');
+// component.send('updateSlug', component.get('slugValue'));
+
+// RSVP.resolve(component.get('lastPromise')).then(function () {
+// expect(component.get('post.slug')).to.equal('whatever');
+
+// done();
+// }).catch(done);
+// });
+// });
+
+// it('should not set a new slug if the only change is to the appended increment value', function (done) {
+// let component = this.subject({
+// slugGenerator: EmberObject.create({
+// generateSlug(slugType, str) {
+// let sanitizedStr = str.replace(/[^a-zA-Z]/g, '');
+// let promise = RSVP.resolve(`${sanitizedStr}-2`);
+// this.set('lastPromise', promise);
+// return promise;
+// }
+// }),
+// post: EmberObject.create({
+// slug: 'whatever'
+// })
+// });
+
+// run(function () {
+// component.set('slugValue', 'whatever!');
+// component.send('updateSlug', component.get('slugValue'));
+
+// RSVP.resolve(component.get('lastPromise')).then(function () {
+// expect(component.get('post.slug')).to.equal('whatever');
+
+// done();
+// }).catch(done);
+// });
+// });
+
+// it('should set the slug if the new slug is different', function (done) {
+// let component = this.subject({
+// slugGenerator: EmberObject.create({
+// generateSlug(slugType, str) {
+// let promise = RSVP.resolve(str);
+// this.set('lastPromise', promise);
+// return promise;
+// }
+// }),
+// post: EmberObject.create({
+// slug: 'whatever',
+// save: K
+// })
+// });
+
+// run(function () {
+// component.set('slugValue', 'changed');
+// component.send('updateSlug', component.get('slugValue'));
+
+// RSVP.resolve(component.get('lastPromise')).then(function () {
+// expect(component.get('post.slug')).to.equal('changed');
+
+// done();
+// }).catch(done);
+// });
+// });
+
+// it('should save the post when the slug changes and the post is not new', function (done) {
+// let component = this.subject({
+// slugGenerator: EmberObject.create({
+// generateSlug(slugType, str) {
+// let promise = RSVP.resolve(str);
+// this.set('lastPromise', promise);
+// return promise;
+// }
+// }),
+// post: EmberObject.create({
+// slug: 'whatever',
+// saved: 0,
+// isNew: false,
+// save() {
+// this.incrementProperty('saved');
+// }
+// })
+// });
+
+// run(function () {
+// component.set('slugValue', 'changed');
+// component.send('updateSlug', component.get('slugValue'));
+
+// RSVP.resolve(component.get('lastPromise')).then(function () {
+// expect(component.get('post.slug')).to.equal('changed');
+// expect(component.get('post.saved')).to.equal(1);
+
+// done();
+// }).catch(done);
+// });
+// });
+
+// it('should not save the post when the slug changes and the post is new', function (done) {
+// let component = this.subject({
+// slugGenerator: EmberObject.create({
+// generateSlug(slugType, str) {
+// let promise = RSVP.resolve(str);
+// this.set('lastPromise', promise);
+// return promise;
+// }
+// }),
+// post: EmberObject.create({
+// slug: 'whatever',
+// saved: 0,
+// isNew: true,
+// save() {
+// this.incrementProperty('saved');
+// }
+// })
+// });
+
+// run(function () {
+// component.set('slugValue', 'changed');
+// component.send('updateSlug', component.get('slugValue'));
+
+// RSVP.resolve(component.get('lastPromise')).then(function () {
+// expect(component.get('post.slug')).to.equal('changed');
+// expect(component.get('post.saved')).to.equal(0);
+
+// done();
+// }).catch(done);
+// });
+// });
+// });
+// });
diff --git a/tests/unit/services/unsplash-test.js b/tests/unit/services/unsplash-test.js
index 4588b0aa1..b83552911 100644
--- a/tests/unit/services/unsplash-test.js
+++ b/tests/unit/services/unsplash-test.js
@@ -1,7 +1,6 @@
import Pretender from 'pretender';
import wait from 'ember-test-helpers/wait';
import {describe, it} from 'mocha';
-import {errorOverride, errorReset} from '../../helpers/adapter-error';
import {expect} from 'chai';
import {run} from '@ember/runloop';
import {setupTest} from 'ember-mocha';
@@ -48,9 +47,7 @@ describe('Unit: Service: unsplash', function () {
});
await wait();
- errorOverride();
expect(service.get('error')).to.have.string('Unsplash API rate limit reached');
- errorReset();
});
it('handles json errors', async function () {
@@ -67,9 +64,7 @@ describe('Unit: Service: unsplash', function () {
});
await wait();
- errorOverride();
expect(service.get('error')).to.equal('Unsplash API Error');
- errorReset();
});
it('handles text errors', async function () {
@@ -84,9 +79,7 @@ describe('Unit: Service: unsplash', function () {
});
await wait();
- errorOverride();
expect(service.get('error')).to.equal('Unsplash text error');
- errorReset();
});
});
diff --git a/tests/unit/validators/post-test.js b/tests/unit/validators/post-test.js
index 5a23c55a8..255dceb51 100644
--- a/tests/unit/validators/post-test.js
+++ b/tests/unit/validators/post-test.js
@@ -40,7 +40,7 @@ describe('Unit: Validator: post', function () {
it('cannot be a random string', async function () {
let post = Post.create({canonicalUrl: 'asdfghjk'});
- let passed = await post.validate({property: 'canonicalUrl'}).then(() => true);
+ let passed = await post.validate({property: 'canonicalUrl'}).then(() => true).catch(() => false);
expect(passed, 'passed').to.be.false;
expect(post.hasValidated).to.include('canonicalUrl');
@@ -52,14 +52,14 @@ describe('Unit: Validator: post', function () {
it('cannot be too long', async function () {
let post = Post.create({canonicalUrl: `http://example.com/${(new Array(1983).join('x'))}`});
- let passed = await post.validate({property: 'canonicalUrl'}).then(() => true);
+ let passed = await post.validate({property: 'canonicalUrl'}).then(() => true).catch(() => false);
expect(passed, 'passed').to.be.false;
expect(post.hasValidated).to.include('canonicalUrl');
let error = post.errors.errorsFor('canonicalUrl').get(0);
expect(error.attribute).to.equal('canonicalUrl');
- expect(error.message).to.equal('Please enter a valid URL');
+ expect(error.message).to.equal('Canonical URL is too long, max 2000 chars');
});
});
});
diff --git a/yarn.lock b/yarn.lock
index 1f9d0fe22..2052eef0c 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5024,16 +5024,16 @@ ember-maybe-in-element@^0.2.0:
dependencies:
ember-cli-babel "^7.1.0"
-ember-mocha@0.15.1:
- version "0.15.1"
- resolved "https://registry.yarnpkg.com/ember-mocha/-/ember-mocha-0.15.1.tgz#f044cd5a6091f2c97bb3a1e472cb8476b4fde3b6"
- integrity sha512-OqSeLU84kAfsmkkUUQl0FJlxFhDAPnAyRX6uOFKSHAAffWKTR205txqzbtaxzEJbGJfBODvxqjfdk0tuAIU7BA==
+ember-mocha@0.16.0:
+ version "0.16.0"
+ resolved "https://registry.yarnpkg.com/ember-mocha/-/ember-mocha-0.16.0.tgz#0a8499f59e626a5af5ca47e3f1d19c2bd5cc7393"
+ integrity sha512-iYWrCOHdPQNwFsD1UNKa6RnA629wgN4zql9730hfiV0Ib4I4VwDueldGwWjXEF+3jGM/R993z6DPvYQKbNfTdg==
dependencies:
"@ember/test-helpers" "^1.5.0"
broccoli-funnel "^2.0.2"
broccoli-merge-trees "^3.0.2"
common-tags "^1.8.0"
- ember-cli-babel "^6.6.0"
+ ember-cli-babel "^7.7.3"
ember-cli-test-loader "^2.2.0"
mocha "^2.5.3"