test: improve unit test
This commit is contained in:
parent
5f82bdeb67
commit
29b5197c47
37
plugins/plugin-md-power/__test__/cleanMarkdownEnv.spec.ts
Normal file
37
plugins/plugin-md-power/__test__/cleanMarkdownEnv.spec.ts
Normal file
@ -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',
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -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"')
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user