@semantic-ui/reactivity
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -9,3 +9,3 @@ { | ||
"dependencies": { | ||
"@semantic-ui/utils": "^0.2.0" | ||
"@semantic-ui/utils": "^0.2.1" | ||
}, | ||
@@ -15,3 +15,3 @@ "devDependencies": { | ||
}, | ||
"version": "0.2.0" | ||
"version": "0.2.1" | ||
} |
@@ -313,3 +313,4 @@ import { describe, it, expect, vi } from 'vitest'; | ||
const arrayItems = [ | ||
// need separate copy for each test | ||
const arrayItems = () => [ | ||
{ id: 1, name: 'Item 1' }, | ||
@@ -320,3 +321,3 @@ { id: 2, name: 'Item 2' } | ||
it('setProperty should set the property of the item matching an id', () => { | ||
const items = new ReactiveVar(arrayItems); | ||
const items = new ReactiveVar(arrayItems()); | ||
items.setProperty(1, 'name', 'Updated Item 1'); | ||
@@ -330,3 +331,3 @@ expect(items.get()).toEqual([ | ||
it('getItem should get the item with matching id', () => { | ||
const items = new ReactiveVar(arrayItems); | ||
const items = new ReactiveVar(arrayItems()); | ||
const index = items.getItem(2); | ||
@@ -337,3 +338,3 @@ expect(index).toBe(1); | ||
it('replaceItem should replace an item matching an ID', () => { | ||
const items = new ReactiveVar(arrayItems); | ||
const items = new ReactiveVar(arrayItems()); | ||
items.replaceItem(1, { id: 1, name: 'Replaced Item 1' }); | ||
@@ -347,3 +348,3 @@ expect(items.get()).toEqual([ | ||
it('removeItem should remove an item matching an ID', () => { | ||
const items = new ReactiveVar(arrayItems); | ||
const items = new ReactiveVar(arrayItems()); | ||
items.removeItem(1); | ||
@@ -356,3 +357,3 @@ expect(items.get()).toEqual([ | ||
it('setProperty should set the property of the item matching a given id', () => { | ||
const items = new ReactiveVar(arrayItems); | ||
const items = new ReactiveVar(arrayItems()); | ||
items.setProperty(2, 'status', 'active'); | ||
@@ -366,3 +367,3 @@ expect(items.get()).toEqual([ | ||
it('setArrayProperty should set an object property at index', () => { | ||
const items = new ReactiveVar(arrayItems); | ||
const items = new ReactiveVar(arrayItems()); | ||
items.setArrayProperty(1, 'status', 'pending'); | ||
@@ -373,3 +374,3 @@ expect(items.get()[1].status).toBe('pending'); | ||
it('setArrayProperty should set all object properties when no index specified', () => { | ||
const items = new ReactiveVar(arrayItems); | ||
const items = new ReactiveVar(arrayItems()); | ||
items.setArrayProperty('status', 'active'); | ||
@@ -380,4 +381,4 @@ expect(items.get()).toEqual([ | ||
]); | ||
}); | ||
}); | ||
@@ -388,3 +389,3 @@ | ||
const innerCallback = vi.fn(); | ||
const innerVar = new ReactiveVar(1); | ||
const innerVar = new ReactiveVar(1, { allowClone: true }); | ||
@@ -414,4 +415,4 @@ const outerCallback = vi.fn(); | ||
const innerVar1 = new ReactiveVar(data1); | ||
const innerVar2 = new ReactiveVar(data2); | ||
const innerVar1 = new ReactiveVar(data1, { allowClone: true }); | ||
const innerVar2 = new ReactiveVar(data2, { allowClone: true }); | ||
@@ -418,0 +419,0 @@ innerVar1.subscribe(innerCallback1); |
42911
904
Updated@semantic-ui/utils@^0.2.1