Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions src/utils/vueShared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,3 @@ const hyphenateRE = /\B([A-Z])/g
export const hyphenate = cacheStringFunction((str: string): string => {
return str.replace(hyphenateRE, '-$1').toLowerCase()
})

export const enum ShapeFlags {
ELEMENT = 1,
FUNCTIONAL_COMPONENT = 1 << 1,
STATEFUL_COMPONENT = 1 << 2,
TEXT_CHILDREN = 1 << 3,
ARRAY_CHILDREN = 1 << 4,
SLOTS_CHILDREN = 1 << 5,
TELEPORT = 1 << 6,
SUSPENSE = 1 << 7,
COMPONENT_SHOULD_KEEP_ALIVE = 1 << 8,
COMPONENT_KEPT_ALIVE = 1 << 9,
COMPONENT = ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.FUNCTIONAL_COMPONENT
}
2 changes: 1 addition & 1 deletion src/vue-wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentPublicInstance, nextTick, App } from 'vue'
import { ShapeFlags } from './utils/vueShared'
import { ShapeFlags } from '@vue/shared'
import { config } from './config'

import { DOMWrapper } from './dom-wrapper'
Expand Down
35 changes: 12 additions & 23 deletions tests/classes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,43 @@ import { mount } from '../src'

describe('classes', () => {
describe('DOMWrapper', () => {
it('returns array of class names if wrapper has class names', () => {
let wrapper
beforeEach(() => {
const Component = defineComponent({
render() {
return h('div', {}, [h('span', { class: 'class-a' })])
}
})

const wrapper = mount(Component)

wrapper = mount(Component)
})
it('returns array of class names if wrapper has class names', () => {
expect(wrapper.find('.class-a').classes()).toContain('class-a')
})

it('returns true if the component has the class', () => {
const Component = defineComponent({
render() {
return h('div', {}, [h('span', { class: 'class-a' })])
}
})

const wrapper = mount(Component).find('span')

expect(wrapper.classes('class-a')).toBe(true)
expect(wrapper.classes('class-b')).toBe(false)
expect(wrapper.find('span').classes('class-a')).toBe(true)
expect(wrapper.find('span').classes('class-b')).toBe(false)
})
})

describe('VueWrapper', () => {
it('returns array of class names if wrapper has class names', () => {
let wrapper
beforeEach(() => {
const Component = defineComponent({
render() {
return h('div', { class: 'class-a' }, 'some text')
}
})

const wrapper = mount(Component)
wrapper = mount(Component)
})

it('returns array of class names if wrapper has class names', () => {
expect(wrapper.classes()).toContain('class-a')
})

it('returns true if the component has the class', () => {
const Component = defineComponent({
render() {
return h('div', { class: 'class-a' }, 'some text')
}
})

const wrapper = mount(Component)

expect(wrapper.classes('class-a')).toBe(true)
expect(wrapper.classes('class-b')).toBe(false)
})
Expand Down