Ghost/ghost/admin/tests/unit/models/invite-test.js
Kevin Ansfield 05a3a11855 welcome tour (#527)
refs https://github.com/TryGhost/Ghost/issues/5168
- adds a `tour` service that handles syncing and management of tour throbbers & content
- adds a `gh-tour-item` component that handles the display of a throbber and it's associated popover when clicked
- uses settings API endpoint to populate viewed tour items on app boot/signin
- adds `liquid-tether@2.0.3` dependency for attaching throbbers and popups
- adds initial tour contents
2017-06-08 22:00:10 +07:00

68 lines
1.9 KiB
JavaScript

import Pretender from 'pretender';
import run from 'ember-runloop';
import {describe, it} from 'mocha';
import {expect} from 'chai';
import {setupModelTest} from 'ember-mocha';
describe('Unit: Model: invite', function() {
setupModelTest('invite', {
needs: [
'model:role',
'serializer:application',
'serializer:invite',
'transform:moment-utc',
'service:ghost-paths',
'service:ajax',
'service:session',
'service:feature',
'service:tour'
]
});
describe('with network', function () {
let server;
beforeEach(function () {
server = new Pretender();
});
afterEach(function () {
server.shutdown();
});
it('resend hits correct endpoint', function () {
let model = this.subject();
let role;
server.post('/ghost/api/v0.1/invites/', function () {
return [200, {}, '{}'];
});
run(() => {
role = this.store().push({data: {id: 1, type: 'role', attributes: {name: 'Editor'}}});
model.set('email', 'resend-test@example.com');
model.set('role', role);
model.resend();
});
expect(
server.handledRequests.length,
'number of requests'
).to.equal(1);
let [lastRequest] = server.handledRequests;
let requestBody = JSON.parse(lastRequest.requestBody);
let [invite] = requestBody.invites;
expect(
requestBody.invites.length,
'number of invites in request body'
).to.equal(1);
expect(invite.email).to.equal('resend-test@example.com');
// eslint-disable-next-line camelcase
expect(invite.role_id, 'role ID').to.equal('1');
});
});
});