GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — commitwork/codegraph/test/unit-schema-make-edge.test.mjs at main · Portll/commitwork

Expand file tree

/

unit-schema-make-edge.test.mjs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
41 lines (33 loc) · 2 KB
/

unit-schema-make-edge.test.mjs

Copy path

File metadata and controls

41 lines (33 loc) · 2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Builds a schema edge object with validated kind, witness, and existence (codegraph/schema.mjs makeEdge).
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { makeEdge } from '../schema.mjs';
test('returns an edge with defaults for a valid kind', () => {
const r = makeEdge('a', 'b', 'imports');
assert.deepEqual(r, { v: 1, from: "a", to: "b", kind: "imports", witness: "lexical", existence: "unknown", evidence: null });
});
test('throws for an unknown edge kind', () => {
assert.throws(() => makeEdge('a', 'b', 'bogus'), { name: 'Error', message: 'unknown edge kind bogus' });
});
test('returns an edge with custom witness and existence', () => {
const r = makeEdge('a', 'b', 'calls', { witness: 'v8', existence: 'confirmed' });
assert.deepEqual(r, { v: 1, from: "a", to: "b", kind: "calls", witness: "v8", existence: "confirmed", evidence: null });
});
test('throws for an unknown witness', () => {
assert.throws(() => makeEdge('a', 'b', 'imports', { witness: 'bad' }), { name: 'Error', message: 'unknown witness bad' });
});
test('throws for an unknown existence', () => {
assert.throws(() => makeEdge('a', 'b', 'imports', { existence: 'bad' }), { name: 'Error', message: 'unknown existence bad' });
});
test('spreads extra properties into the edge', () => {
const r = makeEdge('a', 'b', 'defines', { extra: 1 });
assert.deepEqual(r, { v: 1, from: "a", to: "b", kind: "defines", witness: "lexical", existence: "unknown", evidence: null, extra: 1 });
});
test('returns an edge with evidence set', () => {
const r = makeEdge('a', 'b', 'reexports', { evidence: 'ev' });
assert.deepEqual(r, { v: 1, from: "a", to: "b", kind: "reexports", witness: "lexical", existence: "unknown", evidence: "ev" });
});
test('returns an edge for binds kind with both witness', () => {
const r = makeEdge('a', 'b', 'binds', { witness: 'both', existence: 'contradicted' });
assert.deepEqual(r, { v: 1, from: "a", to: "b", kind: "binds", witness: "both", existence: "contradicted", evidence: null });
});
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.