Skip to content

Commit 5f06cb7

Browse files
author
Robert Jackson
authored
Merge pull request #793 from kiwiupover/move-async-test
2 parents 1dbd839 + 58b64e2 commit 5f06cb7

10 files changed

Lines changed: 69 additions & 77 deletions

File tree

packages/ember-cli-fastboot/test/async-content-test.js

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

packages/ember-cli-fastboot/test/fixtures/async-content/app/components/async-content.js

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

packages/ember-cli-fastboot/test/fixtures/async-content/app/templates/application.hbs

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/ember-cli-fastboot/test/fixtures/async-content/app/templates/components/async-content.hbs renamed to test-packages/basic-app/app/components/async-content.hbs

File renamed without changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { defer } from 'rsvp';
2+
import { later } from '@ember/runloop';
3+
import Component from '@glimmer/component';
4+
import { tracked } from '@glimmer/tracking';
5+
import { inject as service } from '@ember/service';
6+
7+
export default class AsyncContenComponent extends Component {
8+
@service fastboot;
9+
10+
@tracked setLater = null;
11+
12+
constructor() {
13+
super(...arguments);
14+
const deferred = defer();
15+
16+
later(() => {
17+
this.setLater = 'Go Sounders';
18+
deferred.resolve();
19+
}, 100)
20+
21+
this.fastboot.deferRendering(deferred.promise);
22+
}
23+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ Router.map(function() {
1010
this.route('posts');
1111
this.route('boom');
1212
this.route('imports');
13+
this.route('async-content');
1314
});
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 AsyncContentRoute extends Route {
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<AsyncContent />
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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('async content via deferred content', function() {
9+
this.timeout(100000);
10+
11+
before(function() {
12+
return startServer();
13+
});
14+
15+
after(function() {
16+
return stopServer();
17+
});
18+
19+
it('waits for async content when using `fastboot.deferRendering`', async () => {
20+
const response = await request({
21+
url: `http://localhost:45678/async-content`,
22+
headers: {
23+
'Accept': 'text/html'
24+
}
25+
});
26+
27+
expect(response.body).to.contain('Async content: Go Sounders');
28+
});
29+
});
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 | async-content', function(hooks) {
5+
setupTest(hooks);
6+
7+
test('it exists', function(assert) {
8+
let route = this.owner.lookup('route:async-content');
9+
assert.ok(route);
10+
});
11+
});

0 commit comments

Comments
 (0)