Skip to content

Commit a9caba4

Browse files
committed
Fixed a bug causing unique groups to toggle
1 parent cab671d commit a9caba4

21 files changed

+56
-36
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
"docs:generate:ref": "bun write-documentation.ts",
1919
"postdocs:generate:ref": "bun format --all",
2020
"bootstrap": "lerna bootstrap --use-workspaces",
21-
"build": "bunx --bun lerna run build",
21+
"build": "lerna run build",
2222
"postbuild": "bun docs:generate:ref",
23-
"dev": "bunx --bun lerna run build && bunx --bun lerna watch -- lerna run build --scope=$LERNA_PACKAGE_NAME",
23+
"dev": "lerna run build && lerna watch -- lerna run build --scope=$LERNA_PACKAGE_NAME",
2424
"prereleaseOnly": "pinst --disable && echo '🚀 Publishing...'",
2525
"release-canary": "lerna run build && lerna publish --preid canary --no-private --yes --force-publish --canary",
2626
"release-stable": "lerna run build && lerna publish --preid canary --no-private --yes --force-publish",

packages/plexus-core/src/collection/collection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ export class CollectionInstance<
698698
for (const key of keys) {
699699
const currentGroups = this.getGroupsOf(key, {
700700
excludeDefault: true,
701+
exclude: [groupName],
701702
})
702703
this.instance().runtime.log(
703704
'debug',

packages/plexus-core/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"lib": ["dom"],
55
"types": ["bun-types"],
66
"rootDir": "./src",
7-
"outDir": "./dist",
8-
"emitDeclarationOnly": true
7+
"outDir": "./dist"
98
},
109
"include": ["./src/**/*"]
1110
}

tests/action.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeEach, afterEach, describe, test, expect } from 'bun:test'
1+
import { beforeEach, afterEach, describe, test, expect } from 'vitest'
22

33
import {
44
batchAction,

tests/api.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeEach, afterEach, describe, test, expect } from 'bun:test'
1+
import { beforeEach, afterEach, describe, test, expect } from 'vitest'
22
import { api, PlexusApi } from '@plexusjs/api'
33
// only imported here to make sure it works in testing environment (node), not needed by user
44
import 'isomorphic-fetch'

tests/basic.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeEach, describe, expect, test } from 'bun:test'
1+
import { beforeEach, describe, expect, test } from 'vitest'
22
import {
33
DEFAULT_DECAY_RATE,
44
arrayState,

tests/collection.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeEach, afterEach, describe, test, expect } from 'bun:test'
1+
import { beforeEach, afterEach, describe, test, expect } from 'vitest'
22
import { collection, instance, PlexusCollectionInstance } from '@plexusjs/core'
33
import {
44
appointments,
@@ -428,6 +428,29 @@ describe('testing collection groups', () => {
428428
expect(uniqueGroups.getGroup('group1').value.length).toBe(0)
429429
expect(uniqueGroups.getGroup('group2').value.length).toBe(0)
430430
})
431+
432+
test('Unique Groups should not toggle', () => {
433+
uniqueGroups.collect(
434+
[
435+
{ firstName: 'Jack', userId: '0' },
436+
{ firstName: 'Doe', userId: '1' },
437+
{ firstName: 'Kane', userId: '2' },
438+
],
439+
'dynamic'
440+
)
441+
// should only add to one group
442+
uniqueGroups.addToGroups('0', 'group2')
443+
console.log(uniqueGroups.getGroupsOf('0'))
444+
// two is default and group2 (last group in the array) and
445+
expect(uniqueGroups.getGroupsOf('0').length).toBe(2)
446+
expect(uniqueGroups.getGroup('dynamic').value.length).toBe(2)
447+
expect(uniqueGroups.getGroup('group2').value.length).toBe(1)
448+
// recollect the data
449+
uniqueGroups.collect([{ firstName: 'Jack', userId: '0' }], 'group2')
450+
expect(uniqueGroups.getGroupsOf('0').length).toBe(2)
451+
expect(uniqueGroups.getGroup('dynamic').value.length).toBe(2)
452+
expect(uniqueGroups.getGroup('group2').value.length).toBe(1)
453+
})
431454
})
432455
describe('testing collection selectors', () => {
433456
test('Do Selectors Work?', () => {

tests/computed.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeEach, afterEach, describe, test, expect } from 'bun:test'
1+
import { beforeEach, afterEach, describe, test, expect } from 'vitest'
22

33
import {
44
collection,

tests/controller.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeEach, afterEach, describe, test, expect } from 'bun:test'
1+
import { beforeEach, afterEach, describe, test, expect } from 'vitest'
22

33
import {
44
batchAction,

tests/edgecases.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeEach, afterEach, describe, test, expect } from 'bun:test'
1+
import { beforeEach, afterEach, describe, test, expect } from 'vitest'
22

33
import {
44
batchAction,
@@ -89,7 +89,7 @@ describe('Collection Relations', () => {
8989
)
9090

9191
test('Batching race condition with selectors', () => {
92-
batch(() => {})
92+
batch(() => { })
9393
})
9494
})
9595

0 commit comments

Comments
 (0)