Skip to content

Commit 6b9b928

Browse files
author
Robert Jackson
authored
Merge pull request #795 from kiwiupover/response-details-test
2 parents 5f06cb7 + 6391c7e commit 6b9b928

11 files changed

Lines changed: 77 additions & 101 deletions

File tree

packages/ember-cli-fastboot/test/fixtures/response/app/router.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/ember-cli-fastboot/test/fixtures/response/app/routes/echo-request-headers.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/ember-cli-fastboot/test/fixtures/response/app/routes/return-status-code-418.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/ember-cli-fastboot/test/response-details-test.js

Lines changed: 0 additions & 69 deletions
This file was deleted.

test-packages/basic-app/app/router.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ Router.map(function() {
1111
this.route('boom');
1212
this.route('imports');
1313
this.route('async-content');
14+
this.route('echo-request-headers');
15+
this.route('return-status-code-418');
1416
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Route from '@ember/routing/route';
2+
import { inject as service } from '@ember/service';
3+
4+
export default class EchoRequestHeadersRoute extends Route {
5+
@service fastboot;
6+
7+
model() {
8+
let headerToEchoBack = this.fastboot.request.headers.get('x-fastboot-echo');
9+
this.fastboot.response.headers.set('x-fastboot-echoed-back', headerToEchoBack);
10+
}
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Route from '@ember/routing/route';
2+
import { inject as service } from '@ember/service';
3+
4+
export default class ReturnStatusCode418Route extends Route {
5+
@service fastboot;
6+
7+
model() {
8+
this.fastboot.response.statusCode = 418;
9+
}
10+
}

packages/ember-cli-fastboot/test/fixtures/response/app/templates/echo-request-headers.hbs renamed to test-packages/basic-app/app/templates/echo-request-headers.hbs

File renamed without changes.

packages/ember-cli-fastboot/test/fixtures/response/app/templates/return-status-code-418.hbs renamed to test-packages/basic-app/app/templates/return-status-code-418.hbs

File renamed without changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use strict';
2+
3+
const RSVP = require('rsvp');
4+
const request = RSVP.denodeify(require('request'));
5+
const expect = require('chai').use(require('chai-string')).expect;
6+
const { startServer, stopServer } = require('../../test-libs');
7+
8+
describe('response details', function() {
9+
this.timeout(80000);
10+
11+
before(function() {
12+
return startServer();
13+
});
14+
15+
after(function() {
16+
return stopServer();
17+
});
18+
19+
it('makes headers available via a service', async () => {
20+
const response = await request({
21+
url: `http://localhost:45678/echo-request-headers`,
22+
headers: {
23+
'X-FastBoot-echo': 'i-should-be-echoed-back',
24+
'Accept': 'text/html'
25+
}
26+
});
27+
28+
expect(response.headers).to.include.keys('x-fastboot-echoed-back');
29+
expect(response.headers['x-fastboot-echoed-back']).to.include('i-should-be-echoed-back');
30+
});
31+
32+
it('makes the status code available via a service', async () => {
33+
const response = await request({
34+
url: `http://localhost:45678/return-status-code-418`,
35+
headers: {
36+
'Accept': 'text/html'
37+
}
38+
});
39+
40+
expect(response.statusCode).to.equal(418);
41+
});
42+
});

0 commit comments

Comments
 (0)