Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types 2024 part 4 #56

Merged
merged 9 commits into from
May 29, 2024
1 change: 0 additions & 1 deletion src/host/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-nocheck
/**
* @module host
*/
Expand Down
7 changes: 3 additions & 4 deletions src/host/plan-object.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-nocheck
/// <reference path="../shared/file-record.js" />
/// <reference path="types.js" />

Expand All @@ -21,7 +20,7 @@ export function blankTestPlan(name) {
protocol: 'unknown',
hostname: 'unknown',
port: 0xffff,
path: '',
pathname: '',
},
},
tests: [],
Expand Down Expand Up @@ -92,7 +91,7 @@ export function addTestLogToTestPlan(testPlan, { filepath: testFilepath }) {
* @param {AriaATCIHost.TestPlan} testPlan
* @param {string} testFilepath
* @param {*} result
* @param {AriaATCIHost.TestPlan}
* @returns {AriaATCIHost.TestPlan}
*/
export function addTestResultToTestPlan(testPlan, testFilepath, result) {
const test = testPlan.tests.find(({ filepath }) => filepath === testFilepath);
Expand All @@ -104,7 +103,7 @@ export function addTestResultToTestPlan(testPlan, testFilepath, result) {

/**
* @param {*} serverOptions
* @returns {TestPlanServerOptionsPartial}
* @returns {AriaATCIHost.TestPlanServerOptionsPartial}
*/
function validateTestPlanServerOptionsPartial(serverOptions) {
invariant(typeof serverOptions === 'object' && serverOptions !== null);
Expand Down
3 changes: 1 addition & 2 deletions src/host/server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-nocheck
/// <reference path="types.js" />

/**
Expand Down Expand Up @@ -148,7 +147,7 @@ class HostServerBaseURL {
* @param {object} url
* @param {string} url.protocol
* @param {string} url.hostname
* @param {number} url.port
* @param {string|number} url.port
* @param {string} url.pathname
*/
constructor({ protocol, hostname, port, pathname }) {
Expand Down
5 changes: 2 additions & 3 deletions src/host/tests/cli-run-plan.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @ts-nocheck
import { exec } from 'child_process';
import path from 'path';
import * as path from 'path';
import { fileURLToPath } from 'url';

import test from 'ava';
Expand Down Expand Up @@ -98,7 +97,7 @@ async function spawnRunPlan(args) {
const { stdout, stderr } = await new Promise((resolve, reject) =>
exec(
['node', hostBin, 'run-plan', ...args].join(' '),
{ cwd: dirname, shell: false },
{ cwd: dirname },
(error, stdout, stderr) => {
if (error) {
reject(error);
Expand Down
5 changes: 2 additions & 3 deletions src/host/tests/messages.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// @ts-nocheck
import test from 'ava';

import { HostMessage, createHostLogger } from '../messages.js';

test('log', async t => {
t.plan(16);
const { log, emitter } = createHostLogger();
const logAndResolveMessage = async (...args) => {
const logAndResolveMessage = async (type, more) => {
const message = await new Promise(resolve => {
emitter.once('message', resolve);
log(...args);
log(type, more);
});
// Remove non-determinstic date from the log data.
delete message.data.date;
Expand Down
9 changes: 6 additions & 3 deletions src/host/tests/plan-from.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @ts-nocheck
/// <reference path="../types.js"/>

import path from 'path';
import * as path from 'path';
import { fileURLToPath } from 'url';

import test from 'ava';
Expand All @@ -28,7 +27,11 @@ test('plansFrom', async t => {
['tests/**', '*.{html,js}'],
['tests/**', 'reference/**'],
]) {
for (const protocol of [undefined, 'fork', 'developer']) {
for (const protocol of /**@type {('fork'|'developer')[]}*/ ([
undefined,
'fork',
'developer',
])) {
for (const testPattern of [undefined, '*.json', 'tests/*']) {
for (const log of [undefined, () => {}]) {
for await (const plan of plansFrom(
Expand Down
8 changes: 5 additions & 3 deletions src/host/tests/plan-object.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// @ts-nocheck
import test from 'ava';

import * as planObject from '../plan-object.js';

test('planObject', t => {
t.plan(13);
const plan0 = planObject.blankTestPlan();
const plan0 = planObject.blankTestPlan('fake name for testing');
t.snapshot(plan0);
t.snapshot(planObject.setServerOptionsInTestPlan(plan0, {}));
t.throws(() => planObject.setServerOptionsInTestPlan(plan0, { notAnOption: true }));
t.throws(() => {
// @ts-expect-error
planObject.setServerOptionsInTestPlan(plan0, { notAnOption: true });
});
t.snapshot(
planObject.setServerOptionsInTestPlan(plan0, {
baseUrl: { protocol: 'http', hostname: 'host', port: 1234, pathname: '/path' },
Expand Down
Loading
Loading