(name: string)
| 55 | * the renderer to read them. |
| 56 | */ |
| 57 | const engineTable = <T>(name: string): Record<string, T> => { |
| 58 | const start = engineSource.indexOf(`const ${name}={`); |
| 59 | expect(start).toBeGreaterThan(-1); |
| 60 | |
| 61 | const open = engineSource.indexOf('{', start); |
| 62 | let depth = 0; |
| 63 | let end = open; |
| 64 | for (; end < engineSource.length; end += 1) { |
| 65 | if (engineSource[end] === '{') { |
| 66 | depth += 1; |
| 67 | } |
| 68 | if (engineSource[end] === '}') { |
| 69 | depth -= 1; |
| 70 | if (!depth) { |
| 71 | break; |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | const json = engineSource |
| 77 | .slice(open, end + 1) |
| 78 | .replace(/([{,]\s*)([A-Za-z_]\w*)\s*:/g, '$1"$2":') |
| 79 | .replace(/,(\s*[}\]])/g, '$1'); |
| 80 | |
| 81 | return JSON.parse(json) as Record<string, T>; |
| 82 | }; |
| 83 | |
| 84 | describe('world authoring contract', () => { |
| 85 | it('grants the same families on both sides', () => { |
no test coverage detected