tjs-lang 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,9 +20,7 @@ const ajsExamples = loadExamples(join(ROOT, 'guides/examples/ajs'))
20
20
 
21
21
  describe('loadExample helper', () => {
22
22
  test('extracts metadata, title, language, and code', () => {
23
- const ex = loadExample(
24
- join(ROOT, 'guides/examples/tjs/hello-tjs.md')
25
- )
23
+ const ex = loadExample(join(ROOT, 'guides/examples/tjs/hello-tjs.md'))
26
24
  expect(ex.title).toBeTruthy()
27
25
  expect(ex.code).toBeTruthy()
28
26
  expect(ex.language).toBe('tjs')
@@ -31,9 +29,7 @@ describe('loadExample helper', () => {
31
29
  })
32
30
 
33
31
  test('extracts description', () => {
34
- const ex = loadExample(
35
- join(ROOT, 'guides/examples/ajs/hello-world.md')
36
- )
32
+ const ex = loadExample(join(ROOT, 'guides/examples/ajs/hello-world.md'))
37
33
  expect(ex.description).toContain('greeting')
38
34
  })
39
35
  })
@@ -71,13 +67,9 @@ describe('TJS examples with inline tests', () => {
71
67
 
72
68
  test(`${ex.title} tests pass`, () => {
73
69
  const result = tjs(ex.code, { runTests: 'report' })
74
- const failures = (result.testResults || []).filter(
75
- (t: any) => !t.passed
76
- )
70
+ const failures = (result.testResults || []).filter((t: any) => !t.passed)
77
71
  if (failures.length > 0) {
78
- const msgs = failures.map(
79
- (f: any) => `${f.description}: ${f.error}`
80
- )
72
+ const msgs = failures.map((f: any) => `${f.description}: ${f.error}`)
81
73
  throw new Error(`Test failures:\n${msgs.join('\n')}`)
82
74
  }
83
75
  })
@@ -60,7 +60,9 @@ export function parseExample(content: string, filePath = ''): ExampleFile {
60
60
  if (metaMatch) {
61
61
  try {
62
62
  metadata = JSON.parse(metaMatch[1])
63
- } catch {}
63
+ } catch {
64
+ /* invalid JSON metadata, ignore */
65
+ }
64
66
  }
65
67
 
66
68
  // Extract title from first # heading