mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 09:22:49 +03:00
73daa80b7f
no issue - upgrade to latest `ember-source` and related dependencies including `ember-cli` - upgrade to latest `ember-mocha` and modern ember testing setup - https://github.com/emberjs/rfcs/blob/master/text/0268-acceptance-testing-refactor.md - switch from using global acceptance test helpers and `native-dom-helpers` to using the new `ember-test-helpers` methods - use [`chai-dom`](https://github.com/nathanboktae/chai-dom) assertions where in some places (still a lot of places in the tests that could use these) - pin `ember-in-viewport` to 3.0.x to work around incompatibilities between different versions used in `ember-light-table`, `ember-infinity`, and `ember-sticky-element` - incompatibilities manifested as "Invalid value used as weak map key" errors thrown when using `ember-light-table` (subscribers screen) - pin `ember-power-datepicker` to unreleased version that contains a move from global acceptance test helpers to modern test helpers
66 lines
2.5 KiB
JavaScript
66 lines
2.5 KiB
JavaScript
import hbs from 'htmlbars-inline-precompile';
|
|
import sinon from 'sinon';
|
|
import {blur, fillIn, find, findAll, render} from '@ember/test-helpers';
|
|
import {describe, it} from 'mocha';
|
|
import {expect} from 'chai';
|
|
import {setupRenderingTest} from 'ember-mocha';
|
|
|
|
describe('Integration: Component: gh-timezone-select', function () {
|
|
setupRenderingTest();
|
|
|
|
beforeEach(function () {
|
|
this.set('availableTimezones', [
|
|
{name: 'Pacific/Pago_Pago', label: '(GMT -11:00) Midway Island, Samoa'},
|
|
{name: 'Etc/UTC', label: '(GMT) UTC'},
|
|
{name: 'Pacific/Kwajalein', label: '(GMT +12:00) International Date Line West'}
|
|
]);
|
|
this.set('activeTimezone', 'Etc/UTC');
|
|
});
|
|
|
|
it('renders', async function () {
|
|
await render(hbs`{{gh-timezone-select
|
|
availableTimezones=availableTimezones
|
|
activeTimezone=activeTimezone}}`);
|
|
|
|
expect(this.element, 'top-level elements').to.exist;
|
|
expect(findAll('option'), 'number of options').to.have.length(3);
|
|
expect(find('select').value, 'selected option value').to.equal('Etc/UTC');
|
|
});
|
|
|
|
it('handles an unknown timezone', async function () {
|
|
this.set('activeTimezone', 'Europe/London');
|
|
|
|
await render(hbs`{{gh-timezone-select
|
|
availableTimezones=availableTimezones
|
|
activeTimezone=activeTimezone}}`);
|
|
|
|
// we have an additional blank option at the top
|
|
expect(findAll('option'), 'number of options').to.have.length(4);
|
|
// blank option is selected
|
|
expect(find('select').value, 'selected option value').to.equal('');
|
|
// we indicate the manual override
|
|
expect(find('p').textContent).to.match(/Your timezone has been automatically set to Europe\/London/);
|
|
});
|
|
|
|
it('triggers update action on change', async function () {
|
|
let update = sinon.spy();
|
|
this.set('update', update);
|
|
|
|
await render(hbs`{{gh-timezone-select
|
|
availableTimezones=availableTimezones
|
|
activeTimezone=activeTimezone
|
|
update=(action update)}}`);
|
|
|
|
await fillIn('select', 'Pacific/Pago_Pago');
|
|
await blur('select');
|
|
|
|
expect(update.calledOnce, 'update was called once').to.be.true;
|
|
expect(update.firstCall.args[0].name, 'update was passed new timezone')
|
|
.to.equal('Pacific/Pago_Pago');
|
|
});
|
|
|
|
// TODO: mock clock service, fake the time, test we have the correct
|
|
// local time and it changes alongside selection changes
|
|
it('renders local time');
|
|
});
|