feat: more work on python scriptiong basics
This commit is contained in:
41
tests/renderer/python/abiV1.test.ts
Normal file
41
tests/renderer/python/abiV1.test.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { parseMacroContextV1 } from '../../../src/renderer/python/abiV1';
|
||||
|
||||
describe('macroContextV1Schema', () => {
|
||||
it('accepts optional env hook and source metadata', () => {
|
||||
const parsed = parseMacroContextV1({
|
||||
env: {
|
||||
isPreview: true,
|
||||
mainLanguage: 'en',
|
||||
hook: 'post:render',
|
||||
source: {
|
||||
kind: 'post',
|
||||
id: 'post-1',
|
||||
},
|
||||
},
|
||||
params: {
|
||||
title: 'Hello',
|
||||
},
|
||||
data: {
|
||||
post: {
|
||||
id: 'post-1',
|
||||
slug: 'hello',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.env.hook).toBe('post:render');
|
||||
expect(parsed.env.source).toEqual({ kind: 'post', id: 'post-1' });
|
||||
});
|
||||
|
||||
it('rejects unknown env fields', () => {
|
||||
expect(() =>
|
||||
parseMacroContextV1({
|
||||
env: {
|
||||
isPreview: true,
|
||||
unknown: 'value',
|
||||
},
|
||||
})
|
||||
).toThrow('Invalid macro context');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user