feat(test): Add cypress for testing

This commit is contained in:
Braks
2021-11-27 16:53:24 +01:00
committed by GitHub
parent 43b68c1699
commit 796c60431f
15 changed files with 1120 additions and 124 deletions
@@ -0,0 +1,51 @@
import { useStore } from '~/composables'
import { initialState } from '~/utils'
import { FlowState, FlowStore } from '~/types'
describe('test store state', () => {
let store: FlowStore
beforeEach(() => (store = useStore()))
afterEach(() => store.$dispose())
it('has any initial state', () => {
expect(store.$state).to.exist
})
it('has default initial state', () => {
const initial = initialState()
Object.keys(store.$state).forEach((state) => {
const storedState = store[<keyof FlowState>state]
const initialVal = initial[<keyof FlowState>state]
expect(JSON.stringify(storedState)).to.eq(JSON.stringify(initialVal))
})
})
it('sets state', () => {
store.setState({
zoomOnScroll: false,
})
expect(store.zoomOnScroll).to.eq(false)
})
it('takes initial options', () => {
const store = useStore({
zoomOnScroll: false,
})
expect(store.zoomOnScroll).to.eq(false)
store.$dispose()
})
it('gets custom node types', () => {
store.setState({
nodeTypes: ['custom'],
})
expect(Object.keys(store.getNodeTypes)).to.contain('custom')
})
it('gets custom edge types', () => {
store.setState({
edgeTypes: ['custom'],
})
expect(Object.keys(store.getEdgeTypes)).to.contain('custom')
})
})