Skip to content

Commit c7b710b

Browse files
committed
adding shoebox tests
1 parent 6d9dc36 commit c7b710b

11 files changed

Lines changed: 114 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Route from '@ember/routing/route';
2+
import { inject as service } from '@ember/service';
3+
4+
export default class ApplicationRoute extends Route {
5+
@service fastboot;
6+
7+
model() {
8+
if (this.fastboot.isFastBoot) {
9+
const shoebox = this.fastboot.shoebox;
10+
shoebox.put('key1', { newZealand: 'beautiful' });
11+
shoebox.put('key2', { moa: '20 foot tall bird!' });
12+
}
13+
}
14+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Route from '@ember/routing/route';
2+
3+
export default class BoomRoute extends Route {
4+
model() {
5+
throw 'BOOM';
6+
}
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Route from '@ember/routing/route';
2+
3+
export default class ImportsRoute extends Route {
4+
model() {
5+
return {
6+
importStatus: window.browserImportStatus || 'FastBoot default default value'
7+
};
8+
}
9+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Route from '@ember/routing/route';
2+
3+
export default class PostsRoute extends Route {
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{outlet}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FastBoot compatible vendor file: {{model.importStatus}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h3>Posts Route!</h3>
2+
{{outlet}}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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/index');
7+
8+
describe.only('shoebox - put', function() {
9+
this.timeout(20000);
10+
11+
before(function() {
12+
return startServer({
13+
command: 'serve'
14+
});
15+
16+
});
17+
18+
after(function() {
19+
return stopServer();
20+
});
21+
22+
it.only('put items into the shoebox', async () => {
23+
const response = await request({
24+
url: 'http://localhost:49741/',
25+
headers: {
26+
'Accept': 'text/html'
27+
}
28+
})
29+
30+
expect(response.statusCode).to.equal(200);
31+
expect(response.body).to.contain(
32+
'<script type="fastboot/shoebox" id="shoebox-key1">' +
33+
'{"newZealand":"beautiful"}' +
34+
'</script>'
35+
);
36+
37+
expect(response.body).to.contain(
38+
'<script type="fastboot/shoebox" id="shoebox-key2">' +
39+
'{"moa":"20 foot tall bird!"}' +
40+
'</script>'
41+
);
42+
});
43+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { module, test } from 'qunit';
2+
import { setupTest } from 'ember-qunit';
3+
4+
module('Unit | Route | boom', function(hooks) {
5+
setupTest(hooks);
6+
7+
test('it exists', function(assert) {
8+
let route = this.owner.lookup('route:boom');
9+
assert.ok(route);
10+
});
11+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { module, test } from 'qunit';
2+
import { setupTest } from 'ember-qunit';
3+
4+
module('Unit | Route | imports', function(hooks) {
5+
setupTest(hooks);
6+
7+
test('it exists', function(assert) {
8+
let route = this.owner.lookup('route:imports');
9+
assert.ok(route);
10+
});
11+
});

0 commit comments

Comments
 (0)