diff --git a/plugins/plugin-md-power/__test__/cleanMarkdownEnv.spec.ts b/plugins/plugin-md-power/__test__/cleanMarkdownEnv.spec.ts new file mode 100644 index 00000000..7ccfed08 --- /dev/null +++ b/plugins/plugin-md-power/__test__/cleanMarkdownEnv.spec.ts @@ -0,0 +1,37 @@ +import { describe, expect, it } from 'vitest' +import { cleanMarkdownEnv, type CleanMarkdownEnv } from '../src/node/utils/cleanMarkdownEnv.js' + +describe('cleanMarkdownEnv', () => { + const env: CleanMarkdownEnv = { + base: 'base', + filePath: 'filePath', + filePathRelative: 'filePathRelative', + references: 'references', + abbreviations: 'abbreviations', + annotations: 'annotations', + // @ts-expect-error should be ignored + foo: 'foo', + bar: 'bar', + } + it('should clean markdown env', () => { + const result = cleanMarkdownEnv(env) + expect(result).toEqual({ + base: 'base', + filePath: 'filePath', + filePathRelative: 'filePathRelative', + references: 'references', + abbreviations: 'abbreviations', + annotations: 'annotations', + }) + }) + + it('should clean markdown env with excludes', () => { + const result = cleanMarkdownEnv(env, ['references', 'abbreviations']) + expect(result).toEqual({ + base: 'base', + filePath: 'filePath', + filePathRelative: 'filePathRelative', + annotations: 'annotations', + }) + }) +}) diff --git a/plugins/plugin-md-power/__test__/stringifyAttrs.spec.ts b/plugins/plugin-md-power/__test__/stringifyAttrs.spec.ts index 0f4b01d8..fdea1283 100644 --- a/plugins/plugin-md-power/__test__/stringifyAttrs.spec.ts +++ b/plugins/plugin-md-power/__test__/stringifyAttrs.spec.ts @@ -45,6 +45,10 @@ describe('stringifyAttrs', () => { expect(stringifyAttrs({ id: '{ "foo": "bar", baz: 1 }', class: '["a", "b"]' })).toBe(' :id="{ \'foo\': \'bar\', baz: 1 }" :class="[\'a\', \'b\']"') }) + it('should handle like json string values with force stringify', () => { + expect(stringifyAttrs({ id: '{ "foo": "bar", baz: 1 }', class: '["a", "b"]' }, false, ['class'])).toBe(' :id="{ \'foo\': \'bar\', baz: 1 }" class="[\'a\', \'b\']"') + }) + it('should handle kebabCase keys', () => { expect(stringifyAttrs({ 'data-foo': 'bar', 'data-baz': 1, 'fooBaz': 'bar' })).toBe(' data-foo="bar" :data-baz="1" foo-baz="bar"') })