Skip to content

Commit

Permalink
refactor: migrate test-app package to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
vscav committed Nov 6, 2023
1 parent cb515b2 commit 11a6d59
Show file tree
Hide file tree
Showing 16 changed files with 487 additions and 370 deletions.
3 changes: 2 additions & 1 deletion ember-phone-input/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default {
addon.publicEntrypoints([
'components/**/*.js',
'services/**/*.js',
'instance-initializers/**/*.js'
'instance-initializers/**/*.js',
'template-registry.js'
]),

// These are the modules that should get reexported into the traditional
Expand Down
2 changes: 1 addition & 1 deletion ember-phone-input/src/components/phone-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type PhoneInputService from '../services/phone-input';
import 'intl-tel-input/build/css/intlTelInput.css';
import '../styles/styles.css';

interface MetaData {
export interface MetaData {
extension: string;
selectedCountryData: intlTelInput.CountryData;
isValidNumber: boolean;
Expand Down
5 changes: 5 additions & 0 deletions ember-phone-input/src/template-registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type PhoneInput from './components/phone-input';

export default interface Registry {
PhoneInput: typeof PhoneInput;
}
2 changes: 1 addition & 1 deletion test-app/app/app.js → test-app/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Application from '@ember/application';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
import config from 'test-app/config/environment';

export default class App extends Application {
modulePrefix = config.modulePrefix;
Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 12 additions & 3 deletions test-app/config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
const getChannelURL = require('ember-source-channel-url');
const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');

// Needed for ember-source < 4.8, when preview types were first shipped
const emberTypesPackages = {
'@types/ember__application': '^4.0.8',
'@types/ember__routing': '^4.0.17'
};

module.exports = async function () {
return {
usePnpm: true,
Expand All @@ -11,15 +17,17 @@ module.exports = async function () {
name: 'ember-lts-3.28',
npm: {
devDependencies: {
'ember-source': '~3.28.0'
'ember-source': '~3.28.0',
...emberTypesPackages
}
}
},
{
name: 'ember-lts-4.4',
npm: {
devDependencies: {
'ember-source': '~4.4.0'
'ember-source': '~4.4.0',
...emberTypesPackages
}
}
},
Expand Down Expand Up @@ -58,7 +66,8 @@ module.exports = async function () {
},
npm: {
devDependencies: {
'ember-source': '~3.28.0'
'ember-source': '~3.28.0',
...emberTypesPackages
},
ember: {
edition: 'classic'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { SetupTestOptions } from 'ember-qunit';
import {
setupApplicationTest as upstreamSetupApplicationTest,
setupRenderingTest as upstreamSetupRenderingTest,
Expand All @@ -8,7 +9,10 @@ import {
// test setup functions. This way, you can easily extend the setup that is
// needed per test type.

function setupApplicationTest(hooks, options) {
function setupApplicationTest(
hooks: NestedHooks,
options: SetupTestOptions
): void {
upstreamSetupApplicationTest(hooks, options);

// Additional setup for application tests can be done here.
Expand All @@ -27,13 +31,16 @@ function setupApplicationTest(hooks, options) {
// setupMirage(hooks); // ember-cli-mirage
}

function setupRenderingTest(hooks, options) {
function setupRenderingTest(
hooks: NestedHooks,
options: SetupTestOptions
): void {
upstreamSetupRenderingTest(hooks, options);

// Additional setup for rendering tests can be done here.
}

function setupTest(hooks, options) {
function setupTest(hooks: NestedHooks, options: SetupTestOptions): void {
upstreamSetupTest(hooks, options);

// Additional setup for unit tests can be done here.
Expand Down
Loading

0 comments on commit 11a6d59

Please sign in to comment.