diff --git a/packages/bbob-preset-vue/test/index.test.ts b/packages/bbob-preset-vue/test/index.test.ts index 7f4c9942..a9e75e47 100644 --- a/packages/bbob-preset-vue/test/index.test.ts +++ b/packages/bbob-preset-vue/test/index.test.ts @@ -1,24 +1,28 @@ +import type { PresetTagFunction } from "@bbob/types"; + import preset, { createTags, tagAttr } from '../src' +const tagFactory = (tag: string): PresetTagFunction => jest.fn((...args) => ({ tag })) +const createTag = (tag: string, style: Record) => ({ tag, ...tagAttr(style)}) + describe('@bbob/preset-vue', () => { test('is a function', () => { expect(preset).toBeInstanceOf(Function) }) test('createTags', () => { - const defFn = jest.fn(() => ({})) const defTags = { - b: defFn, - i: defFn, - u: defFn, - s: defFn, + b: tagFactory('b'), + i: tagFactory('i'), + u: tagFactory('u'), + s: tagFactory('s'), } const tags = createTags(defTags) const args = [{tag: 'test'}] - expect(tags.b?.({tag: 'b'}, ...args)).toEqual(tagAttr({ fontWeight: 'bold' })) - expect(tags.i?.({tag: 'i'}, ...args)).toEqual(tagAttr({ fontStyle: 'italic' })) - expect(tags.u?.({tag: 'u'}, ...args)).toEqual(tagAttr({ textDecoration: 'underline' })) - expect(tags.s?.({tag: 's'}, ...args)).toEqual(tagAttr({ textDecoration: 'line-through' })) + expect(tags.b?.({tag: 'b'}, ...args)).toEqual(createTag('b',{ fontWeight: 'bold' })) + expect(tags.i?.({tag: 'i'}, ...args)).toEqual(createTag('i',{ fontStyle: 'italic' })) + expect(tags.u?.({tag: 'u'}, ...args)).toEqual(createTag('u',{ textDecoration: 'underline' })) + expect(tags.s?.({tag: 's'}, ...args)).toEqual(createTag('s',{ textDecoration: 'line-through' })) }) });