mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-29 04:14:30 +00:00
refactor(monorepo): decouple api and webui into workspaces packages
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { parseFrontmatter } from './frontmatter'
|
||||
|
||||
describe('frontmatter parser', () => {
|
||||
it('should parse content with frontmatter', () => {
|
||||
const content = `---
|
||||
name: test-skill
|
||||
description: simple skill
|
||||
---
|
||||
# Body
|
||||
Hello world`
|
||||
const { frontmatter, body } = parseFrontmatter<{ name: string; description: string }>(content)
|
||||
expect(frontmatter.name).toBe('test-skill')
|
||||
expect(frontmatter.description).toBe('simple skill')
|
||||
expect(body).toBe('# Body\nHello world')
|
||||
})
|
||||
|
||||
it('should handle content without frontmatter', () => {
|
||||
const content = '# No Frontmatter\nJust text'
|
||||
const { frontmatter, body } = parseFrontmatter(content)
|
||||
expect(frontmatter).toEqual({})
|
||||
expect(body).toBe(content)
|
||||
})
|
||||
|
||||
it('should handle invalid frontmatter delimiters', () => {
|
||||
const content = `---
|
||||
no-end-delimiter
|
||||
# Body`
|
||||
const { frontmatter, body } = parseFrontmatter(content)
|
||||
expect(frontmatter).toEqual({})
|
||||
expect(body).toBe(content)
|
||||
})
|
||||
|
||||
it('should normalize newlines', () => {
|
||||
const content = '---\r\nname: win\r\n---\r\n# Body'
|
||||
const { frontmatter, body } = parseFrontmatter<{ name: string }>(content)
|
||||
expect(frontmatter.name).toBe('win')
|
||||
expect(body).toBe('# Body')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user