Skip to content

Commit

Permalink
test(preset-vue): create tags
Browse files Browse the repository at this point in the history
  • Loading branch information
JiLiZART committed Jun 2, 2024
1 parent cf3a275 commit f2995f5
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/bbob-preset-vue/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -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<string, string>) => ({ 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' }))
})
});

0 comments on commit f2995f5

Please sign in to comment.