Skip to content

Commit

Permalink
test: Default locale to 'en-US' on all browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
motss committed Mar 26, 2020
1 parent 27f5eb3 commit 693052b
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 58 deletions.
2 changes: 2 additions & 0 deletions src/tests/app-datepicker-dialog/a11y.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ describe(`${DATEPICKER_DIALOG_NAME}::a11y`, () => {

document.body.appendChild(el);

el.locale = 'en-US';

await el.updateComplete;

done();
Expand Down
5 changes: 3 additions & 2 deletions src/tests/app-datepicker-dialog/attributes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ describe(`${DATEPICKER_DIALOG_NAME}::attributes`, () => {
await browser.executeAsync(async (a, done) => {
const el: DatepickerDialog = document.createElement(a);

el.min = '2000-01-01';

document.body.appendChild(el);

el.locale = 'en-US';
el.min = '2000-01-01';

await el.open();
await el.updateComplete;

Expand Down
7 changes: 7 additions & 0 deletions src/tests/app-datepicker-dialog/events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe(`${DATEPICKER_DIALOG_NAME}::events`, () => {

const n: DatepickerDialog = document.createElement(a);

n.locale = 'en-US';
n.min = '2000-01-01';
n.value = '2020-02-20';

Expand Down Expand Up @@ -100,6 +101,8 @@ describe(`${DATEPICKER_DIALOG_NAME}::events`, () => {

document.body.appendChild(n);

n.locale = 'en-US';

await n.updateComplete;

const firstUpdatedResult = await firstUpdated;
Expand Down Expand Up @@ -131,6 +134,8 @@ describe(`${DATEPICKER_DIALOG_NAME}::events`, () => {

document.body.appendChild(n);

n.locale = 'en-US';

await n.open();
await n.updateComplete;

Expand Down Expand Up @@ -163,6 +168,8 @@ describe(`${DATEPICKER_DIALOG_NAME}::events`, () => {

document.body.appendChild(n);

n.locale = 'en-US';

await n.open();
await n.updateComplete;

Expand Down
2 changes: 2 additions & 0 deletions src/tests/app-datepicker-dialog/gestures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ describe('gestures', () => {

document.body.appendChild(el);

el.locale = 'en-US';

await el.open();
await el.updateComplete;

Expand Down
2 changes: 2 additions & 0 deletions src/tests/app-datepicker-dialog/initial-render.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ describe(`${DATEPICKER_DIALOG_NAME}::initial_render`, () => {

document.body.appendChild(el);

el.locale = 'en-US';

await el.updateComplete;

done();
Expand Down
1 change: 1 addition & 0 deletions src/tests/app-datepicker-dialog/keyboards.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe(`${DATEPICKER_DIALOG_NAME}::keyboards`, () => {
await browser.executeAsync(async (a, done) => {
const el: DatepickerDialog = document.createElement(a);

el.locale = 'en-US';
// Reset `min` and `value` here before running tests
el.min = '2000-01-01';
el.value = '2020-02-20';
Expand Down
1 change: 1 addition & 0 deletions src/tests/app-datepicker-dialog/mouses.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ describe(`${DATEPICKER_DIALOG_NAME}::mouses`, () => {
await browser.executeAsync(async (a, done) => {
const el: DatepickerDialog = document.createElement(a);

el.locale = 'en-US';
// Reset `min` and `value` here before running tests
el.min = '2000-01-01';
el.value = '2020-02-20';
Expand Down
2 changes: 2 additions & 0 deletions src/tests/app-datepicker-dialog/properties.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ describe(`${DATEPICKER_DIALOG_NAME}::properties`, () => {

document.body.appendChild(el);

el.locale = 'en-US';

await el.open();
await el.updateComplete;

Expand Down
2 changes: 2 additions & 0 deletions src/tests/app-datepicker/a11y.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ describe('a11y', () => {

document.body.appendChild(el);

el.locale = 'en-US';

await el.updateComplete;

done();
Expand Down
1 change: 1 addition & 0 deletions src/tests/app-datepicker/attributes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('attributes', () => {
await browser.executeAsync(async (a, done) => {
const el: Datepicker = document.createElement(a);

el.locale = 'en-US';
el.min = '2000-01-01';

document.body.appendChild(el);
Expand Down
1 change: 1 addition & 0 deletions src/tests/app-datepicker/edge-cases.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('edge cases', () => {
await browser.executeAsync(async (a, done) => {
const el: Datepicker = document.createElement(a);

el.locale = 'en-US';
el.min = '2000-01-01';
el.value = '2020-02-02';

Expand Down
3 changes: 3 additions & 0 deletions src/tests/app-datepicker/events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('events', () => {
timer = window.setTimeout(() => yay(['', '', '']), 15e3);
});

n.locale = 'en-US';
n.min = '2000-01-01';
n.inline = b;

Expand Down Expand Up @@ -107,6 +108,7 @@ describe('events', () => {

const n: Datepicker = document.createElement(a);

n.locale = 'en-US';
n.min = '2000-01-01';
n.value = '2020-02-20';

Expand Down Expand Up @@ -163,6 +165,7 @@ describe('events', () => {
]: A = await browser.executeAsync(async (a, b, done) => {
const n: Datepicker = document.createElement(a);

n.locale = 'en-US';
n.min = '2000-01-01';
n.value = '2020-02-02';

Expand Down
2 changes: 2 additions & 0 deletions src/tests/app-datepicker/gestures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ describe('gestures', () => {

document.body.appendChild(el);

el.locale = 'en-US';

await el.updateComplete;

done();
Expand Down
2 changes: 2 additions & 0 deletions src/tests/app-datepicker/initial-render.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('initial render', () => {
await browser.executeAsync(async (a, done) => {
const el: Datepicker = document.createElement(a);

el.locale = 'en-US';
el.min = '2000-01-01';
el.value = '2020-02-02';

Expand Down Expand Up @@ -162,6 +163,7 @@ describe('initial render', () => {
await browser.executeAsync(async (a, done) => {
const el: Datepicker = document.createElement(a);

el.locale = 'en-US';
el.min = '2000-01-01';
el.startView = 'yearList';
el.value = '2020-02-02';
Expand Down
1 change: 1 addition & 0 deletions src/tests/app-datepicker/keyboards.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('keyboards', () => {
await browser.executeAsync(async (a, done) => {
const el: Datepicker = document.createElement(a);

el.locale = 'en-US';
// Reset `min` and `value` here before running tests
el.min = '2000-01-01';
el.value = '2020-02-20';
Expand Down
1 change: 1 addition & 0 deletions src/tests/app-datepicker/mouses.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('mouses', () => {
await browser.executeAsync(async (a, done) => {
const el: Datepicker = document.createElement(a);

el.locale = 'en-US';
// Reset `min` and `value` here before running tests
el.min = '2000-01-01';
el.value = '2020-02-20';
Expand Down
2 changes: 2 additions & 0 deletions src/tests/app-datepicker/properties.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ describe('properties', () => {

document.body.appendChild(el);

el.locale = 'en-US';

await el.updateComplete;

done();
Expand Down
1 change: 1 addition & 0 deletions src/tests/app-datepicker/timezones.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('timezones', () => {
await browser.executeAsync(async (a, done) => {
const el: Datepicker = document.createElement(a);

el.locale = 'en-US';
// Reset `min` and `value` here before running tests
el.min = '2000-01-01';
el.value = '2020-01-01';
Expand Down
64 changes: 11 additions & 53 deletions src/tests/full-icu.spec.ts
Original file line number Diff line number Diff line change
@@ -1,67 +1,25 @@
import { getResolvedLocale } from '../helpers/get-resolved-locale.js';
import { APP_INDEX_URL } from './constants.js';
import {
deepStrictEqual,
ok,
strictEqual,
} from './helpers/typed-assert.js';

describe('timezones', () => {
function hasFullICU() {
try {
const january = new Date(9e8);
const spanish = new Intl.DateTimeFormat('es', { month: 'long' });
return spanish.format(january) === 'enero';
} catch (err) {
return false;
}
}

describe('full-icu', () => {
before(async () => {
await browser.url(APP_INDEX_URL);
});

function hasFullICU() {
try {
const january = new Date(9e8);
const spanish = new Intl.DateTimeFormat('es', { month: 'long' });
return spanish.format(january) === 'enero';
} catch (err) {
return false;
}
}

it(`supports full ICU`, async () => {
ok(hasFullICU());
strictEqual(
Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
}).format(new Date('2020-02-02')),
'Feb 2, 2020'
);
strictEqual(getResolvedLocale(), 'en-US');

const content = await browser.executeAsync(async (done) => {
const a = document.createElement('app-datepicker');

document.body.appendChild(a);

a.locale = 'en-US';

while (!await a.updateComplete) { /** no-op */ }

done(
[
a.locale,
(a as any)._formatters.fullDateFormat(new Date('2020-03-03')),
JSON.stringify(Intl.DateTimeFormat().resolvedOptions(), null, 2),
]
// a.locale,
// Array.from(
// a.shadowRoot?.querySelectorAll('.full-calendar__day') ?? []
// )[2]?.outerHTML ?? 'nil'
);
});

console.debug('1', content, Intl.DateTimeFormat('en-US', {
timeZone: 'UTC',
year: 'numeric',
month: 'short',
day: 'numeric',
}).format(new Date('2020-03-03')));
deepStrictEqual(content, []);
});

});
5 changes: 2 additions & 3 deletions src/tests/wdio.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import type { WdioConfig } from './custom_wdio.js';
export const config: WdioConfig = {
runner: 'local',
specs: [
'./dist/tests/**/full-icu.spec.js',
// './dist/tests/**/*.spec.js',
'./dist/tests/**/*.spec.js',
// './dist/tests/app-datepicker/tests.js',
// './dist/tests/app-datepicker-dialog/tests.js',
],
Expand Down Expand Up @@ -41,7 +40,7 @@ export const config: WdioConfig = {
bail: 1,
baseUrl: 'http://localhost',
waitforTimeout: 10e3,
connectionRetryCount: 3,
connectionRetryCount: 2,

services: [
'selenium-standalone',
Expand Down

0 comments on commit 693052b

Please sign in to comment.