update(test): remove pinia from tests

* update tests to succeed with new "store"

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-12-04 15:42:18 +01:00
parent 3c9840cc50
commit 55e738f6bf
2 changed files with 4 additions and 8 deletions
@@ -1,11 +1,11 @@
import { getElements } from '../../../examples/Stress/utils' import { getElements } from '../../../examples/Stress/utils'
import { useStore } from '~/composables' import { useStore } from '~/composables'
import { FlowStore } from '~/types' import { Elements, FlowStore } from '~/types'
import { isGraphEdge, isGraphNode } from '~/utils' import { isGraphEdge, isGraphNode } from '~/utils'
describe('test store action setElements', () => { describe('test store action setElements', () => {
const setElements = async (store: FlowStore) => { const setElements = async (store: FlowStore) => {
const elements = [ const elements: Elements = [
{ id: '1', type: 'input', data: { label: 'Node 1' }, position: { x: 250, y: 5 } }, { id: '1', type: 'input', data: { label: 'Node 1' }, position: { x: 250, y: 5 } },
{ id: '2', data: { label: 'Node 2' }, position: { x: 100, y: 100 } }, { id: '2', data: { label: 'Node 2' }, position: { x: 100, y: 100 } },
{ id: 'e1-2', source: '1', target: '2', animated: true }, { id: 'e1-2', source: '1', target: '2', animated: true },
@@ -17,7 +17,6 @@ describe('test store action setElements', () => {
const store = useStore() const store = useStore()
await setElements(store) await setElements(store)
expect(store.elements).to.have.length(3) expect(store.elements).to.have.length(3)
store.$dispose()
}) })
context('elements pre-set', () => { context('elements pre-set', () => {
@@ -26,7 +25,6 @@ describe('test store action setElements', () => {
store = useStore() store = useStore()
await setElements(store) await setElements(store)
}) })
afterEach(() => store.$dispose())
it('adds elements', () => { it('adds elements', () => {
store.addElements([{ id: '4', data: { label: 'Node 4' }, position: { x: 500, y: 500 } }]) store.addElements([{ id: '4', data: { label: 'Node 4' }, position: { x: 500, y: 500 } }])
+2 -4
View File
@@ -5,15 +5,14 @@ describe('test store state', () => {
let store: FlowStore let store: FlowStore
beforeEach(() => (store = useStore())) beforeEach(() => (store = useStore()))
afterEach(() => store.$dispose())
it('has any initial state', () => { it('has any initial state', () => {
expect(store.$state).to.exist expect(store.state).to.exist
}) })
it('has default initial state', () => { it('has default initial state', () => {
const initial = initialState() const initial = initialState()
Object.keys(store.$state).forEach((state) => { Object.keys(store.state).forEach((state) => {
const storedState = store[<keyof FlowState>state] const storedState = store[<keyof FlowState>state]
const initialVal = initial[<keyof FlowState>state] const initialVal = initial[<keyof FlowState>state]
expect(JSON.stringify(storedState)).to.eq(JSON.stringify(initialVal)) expect(JSON.stringify(storedState)).to.eq(JSON.stringify(initialVal))
@@ -32,7 +31,6 @@ describe('test store state', () => {
zoomOnScroll: false, zoomOnScroll: false,
}) })
expect(store.zoomOnScroll).to.eq(false) expect(store.zoomOnScroll).to.eq(false)
store.$dispose()
}) })
it('gets custom node types', () => { it('gets custom node types', () => {