Ghost/ghost/admin/tests/integration/components/gh-download-count-test.js
Kevin Ansfield 5534678f02 💄 replace DownloadCountPoller with gh-download-count
closes https://github.com/TryGhost/Ghost/issues/8321
- adds `gh-download-count` component that uses ember-concurrency to poll the count endpoint
- removes the no-longer-needed `setup/one` route as ember-concurrency now handles the setInterval bookkeeping for us
2017-04-17 10:04:53 -04:00

46 lines
1.2 KiB
JavaScript

import {expect} from 'chai';
import {describe, it} from 'mocha';
import {setupComponentTest} from 'ember-mocha';
import hbs from 'htmlbars-inline-precompile';
import Pretender from 'pretender';
import wait from 'ember-test-helpers/wait';
describe('Integration: Component: gh-download-count', function() {
setupComponentTest('gh-download-count', {
integration: true
});
let server;
beforeEach(function () {
server = new Pretender();
server.get('https://count.ghost.org/', function () {
return [200, {}, JSON.stringify({count: 42})];
});
});
afterEach(function () {
server.shutdown();
});
it('hits count endpoint and renders', function () {
this.render(hbs`{{gh-download-count}}`);
return wait().then(() => {
expect(this.$().text().trim()).to.equal('42');
});
});
it('renders with a block', function () {
this.render(hbs`
{{#gh-download-count as |count|}}
{{count}} downloads
{{/gh-download-count}}
`);
return wait().then(() => {
expect(this.$().text().trim()).to.equal('42 downloads');
});
});
});