|
1 |
| -import { beforeEach, afterEach, describe, test, expect } from 'bun:test' |
| 1 | +import { beforeEach, afterEach, describe, test, expect } from 'vitest' |
2 | 2 | import { collection, instance, PlexusCollectionInstance } from '@plexusjs/core'
|
3 | 3 | import {
|
4 | 4 | appointments,
|
@@ -428,6 +428,29 @@ describe('testing collection groups', () => {
|
428 | 428 | expect(uniqueGroups.getGroup('group1').value.length).toBe(0)
|
429 | 429 | expect(uniqueGroups.getGroup('group2').value.length).toBe(0)
|
430 | 430 | })
|
| 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 | + }) |
431 | 454 | })
|
432 | 455 | describe('testing collection selectors', () => {
|
433 | 456 | test('Do Selectors Work?', () => {
|
|
0 commit comments