Skip to content

Commit c62e2b4

Browse files
shleewhiteaklkv
andauthored
Showcase: convert modifier/helper integration tests to gts or typescript (#3366)
Co-authored-by: Alexey Kulakov <[email protected]>
1 parent 683479a commit c62e2b4

13 files changed

+1225
-991
lines changed

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

showcase/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@embroider/macros": "^1.18.1",
5151
"@embroider/test-setup": "^4.0.0",
5252
"@eslint/js": "^9.27.0",
53+
"@floating-ui/dom": "^1.6.12",
5354
"@glimmer/component": "^2.0.0",
5455
"@glimmer/tracking": "^1.1.2",
5556
"@glint/core": "^1.5.2",

showcase/tests/integration/helpers/hds-format-date-test.js renamed to showcase/tests/integration/helpers/hds-format-date-test.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,27 @@
44
*/
55

66
import { module, test } from 'qunit';
7-
import { setupRenderingTest } from 'showcase/tests/helpers';
7+
88
import { hdsFormatDate } from '@hashicorp/design-system-components/helpers/hds-format-date';
99

10+
import { setupRenderingTest } from 'showcase/tests/helpers';
11+
1012
module(
1113
'Integration | Helper | hds-format-date - hdsFormatDate()',
1214
function (hooks) {
1315
setupRenderingTest(hooks);
1416

15-
test('it formats a date with the provided options', async function (assert) {
17+
test('it formats a date with the provided options', function (assert) {
1618
const date = new Date('2021-01-01T00:00:00Z');
17-
const options = {
19+
const options: {
20+
month: Intl.DateTimeFormatOptions['month'];
21+
day: Intl.DateTimeFormatOptions['day'];
22+
year?: Intl.DateTimeFormatOptions['year'];
23+
hour?: Intl.DateTimeFormatOptions['hour'];
24+
minute?: Intl.DateTimeFormatOptions['minute'];
25+
second?: Intl.DateTimeFormatOptions['second'];
26+
timeZoneName?: Intl.DateTimeFormatOptions['timeZoneName'];
27+
} = {
1828
month: 'long',
1929
day: 'numeric',
2030
year: 'numeric',

showcase/tests/integration/helpers/hds-format-relative-test.js renamed to showcase/tests/integration/helpers/hds-format-relative-test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
*/
55

66
import { module, test } from 'qunit';
7-
import { setupRenderingTest } from 'showcase/tests/helpers';
7+
88
import { hdsFormatRelative } from '@hashicorp/design-system-components/helpers/hds-format-relative';
99

10+
import { setupRenderingTest } from 'showcase/tests/helpers';
11+
1012
module(
1113
'Integration | Helper | hds-format-relative - hdsFormatRelative()',
1214
function (hooks) {
1315
setupRenderingTest(hooks);
1416

15-
test('it formats a relative time with the default options', async function (assert) {
17+
test('it formats a relative time with the default options', function (assert) {
1618
const value = -1;
1719
const result = hdsFormatRelative([value]);
1820

@@ -22,7 +24,7 @@ module(
2224
);
2325
});
2426

25-
test('it formats a relative time with the provided options', async function (assert) {
27+
test('it formats a relative time with the provided options', function (assert) {
2628
const value = -1;
2729
const unit = 'day';
2830
const result = hdsFormatRelative([value, unit]);

showcase/tests/integration/helpers/hds-t-test.gjs renamed to showcase/tests/integration/helpers/hds-t-test.gts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
*/
55

66
import { module, test } from 'qunit';
7-
import { setupRenderingTest } from 'showcase/tests/helpers';
87
import { render, setupOnerror } from '@ember/test-helpers';
8+
99
import hdsT from '@hashicorp/design-system-components/helpers/hds-t';
1010

11+
import { setupRenderingTest } from 'showcase/tests/helpers';
12+
1113
const DEFAULT_STRING = 'Default text';
1214

1315
module('Integration | Helper | hds-t', function (hooks) {
@@ -49,7 +51,10 @@ module('Integration | Helper | hds-t', function (hooks) {
4951
});
5052

5153
await render(
52-
<template>{{hdsT value default=DEFAULT_STRING}}</template>,
54+
<template>
55+
{{! @glint-expect-error - testing invalid scenarios }}
56+
{{hdsT value default=DEFAULT_STRING}}
57+
</template>,
5358
);
5459

5560
assert.throws(function () {
@@ -59,11 +64,7 @@ module('Integration | Helper | hds-t', function (hooks) {
5964
});
6065
});
6166

62-
module('ember-intl service is available', function (hooks) {
63-
hooks.beforeEach(function () {
64-
this.intl = this.owner.lookup('service:intl');
65-
});
66-
67+
module('ember-intl service is available', function () {
6768
test('it returns translated string if locale is present and key exists', async function (assert) {
6869
const intl = this.owner.lookup('service:intl');
6970

0 commit comments

Comments
 (0)