MCPcopy
hub / github.com/lingodotdev/lingo.dev / createMockData

Function createMockData

packages/compiler/src/utils/ast-key.spec.ts:28–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26// helpers
27
28function createMockData() {
29 const ast = parse(
30 `
31 export function MyComponent() {
32 return <div>Hello world!</div>;
33 }
34`,
35 { sourceType: "module", plugins: ["jsx"] },
36 );
37
38 let testElementPath: NodePath | null = null;
39 traverse(ast, {
40 JSXElement(nodePath) {
41 testElementPath = nodePath;
42 },
43 });
44 if (!testElementPath) {
45 throw new Error(
46 "testElementPath cannot be null - check test case definition",
47 );
48 }
49
50 const testElementKey = `0/declaration/body/0/argument`;
51
52 return {
53 ast,
54 testElementPath,
55 testElementKey,
56 };
57}

Callers 1

ast-key.spec.tsFile · 0.85

Calls 2

parseFunction · 0.85
traverseFunction · 0.50

Tested by

no test coverage detected