示例工程 04-object-types-structural

04-object-types-structural/04-interface-vs-type/main.test.mjs

javascript · 0.5 KB

运行:04 · interface-vs-type

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

import { test } from 'node:test';
import assert from 'node:assert/strict';
import { describe, relabel, run } from './dist/main.js';
 
test('合并后的 Config 同时要求 host 与 port', () => {
  const out = [];
  const ret = run((msg) => out.push(msg));
  assert.deepEqual(ret, ['localhost:8080', '1,2', 'demo']);
  assert.deepEqual(out, ret);
  assert.equal(describe({ host: 'h', port: 1 }), 'h:1');
  assert.deepEqual(relabel({ id: 9 }, 'x'), { id: 9, label: 'x' });
});