@@ -116,16 +116,15 @@ describe('combineEntries() tests', () => {
116
116
} ) ;
117
117
118
118
describe ( 'difference() tests' , ( ) => {
119
- const coll1 = createCollectionFrom ( [ 'a' , 1 ] , [ 'b' , 2 ] ) ;
120
- const coll2 = createTestCollection ( ) ;
121
- const diff = createCollectionFrom ( [ 'c' , 3 ] ) ;
119
+ const coll1 = createCollectionFrom ( [ 'a' , 1 ] , [ 'b' , 2 ] , [ 'c' , 3 ] ) ;
120
+ const coll2 = createCollectionFrom ( [ 'b' , 2 ] , [ 'd' , 4 ] , [ 'e' , 5 ] ) ;
122
121
123
- test ( 'it removes entries from the bigger collection on the right ' , ( ) => {
124
- expect ( coll1 . difference ( coll2 ) ) . toStrictEqual ( diff ) ;
122
+ test ( 'it returns the difference the collections ' , ( ) => {
123
+ expect ( coll1 . difference ( coll2 ) ) . toStrictEqual ( createCollectionFrom ( [ 'a' , 1 ] , [ 'c' , 3 ] ) ) ;
125
124
} ) ;
126
125
127
- test ( 'removes the difference from the bigger collection on the left ' , ( ) => {
128
- expect ( coll2 . difference ( coll1 ) ) . toStrictEqual ( diff ) ;
126
+ test ( 'it returns the difference the collections from the opposite order ' , ( ) => {
127
+ expect ( coll2 . difference ( coll1 ) ) . toStrictEqual ( createCollectionFrom ( [ 'd' , 4 ] , [ 'e' , 5 ] ) ) ;
129
128
} ) ;
130
129
} ) ;
131
130
@@ -407,12 +406,12 @@ describe('hasAny() tests', () => {
407
406
} ) ;
408
407
} ) ;
409
408
410
- describe ( 'intersect () tests' , ( ) => {
409
+ describe ( 'intersection () tests' , ( ) => {
411
410
const coll1 = createCollectionFrom ( [ 'a' , 1 ] , [ 'b' , 2 ] ) ;
412
411
const coll2 = createCollectionFrom ( [ 'a' , 1 ] , [ 'c' , 3 ] ) ;
413
412
414
- test ( 'it returns a new collection ' , ( ) => {
415
- const c = coll1 . intersect ( coll2 ) ;
413
+ test ( 'it returns the intersection of the collections ' , ( ) => {
414
+ const c = coll1 . intersection ( coll2 ) ;
416
415
expect ( c ) . toBeInstanceOf ( Collection ) ;
417
416
expect ( c . size ) . toStrictEqual ( 1 ) ;
418
417
@@ -776,19 +775,6 @@ describe('sort() tests', () => {
776
775
} ) ;
777
776
} ) ;
778
777
779
- describe ( 'subtract() tests' , ( ) => {
780
- const coll1 = createCollectionFrom ( [ 'a' , 1 ] , [ 'b' , 2 ] , [ 'c' , 3 ] , [ 'd' , undefined ] ) ;
781
- const coll2 = createCollectionFrom ( [ 'b' , 2 ] , [ 'c' , 0 ] ) ;
782
-
783
- test ( 'it returns a new collection' , ( ) => {
784
- const c = coll1 . subtract ( coll2 ) ;
785
- expect ( c ) . toBeInstanceOf ( Collection ) ;
786
- expect ( c . size ) . toStrictEqual ( 3 ) ;
787
-
788
- expect ( c ) . toStrictEqual ( createCollectionFrom ( [ 'a' , 1 ] , [ 'c' , 3 ] , [ 'd' , undefined ] ) ) ;
789
- } ) ;
790
- } ) ;
791
-
792
778
describe ( 'sweep() test' , ( ) => {
793
779
const coll = createTestCollection ( ) ;
794
780
@@ -816,6 +802,17 @@ describe('sweep() test', () => {
816
802
} ) ;
817
803
} ) ;
818
804
805
+ describe ( 'symmetricDifference() tests' , ( ) => {
806
+ const coll1 = createCollectionFrom ( [ 'a' , 1 ] , [ 'b' , 2 ] , [ 'c' , 3 ] ) ;
807
+ const coll2 = createCollectionFrom ( [ 'b' , 2 ] , [ 'd' , 4 ] , [ 'e' , 5 ] ) ;
808
+
809
+ test ( 'it returns the symmetric difference of the collections' , ( ) => {
810
+ expect ( coll1 . symmetricDifference ( coll2 ) ) . toStrictEqual (
811
+ createCollectionFrom ( [ 'a' , 1 ] , [ 'c' , 3 ] , [ 'd' , 4 ] , [ 'e' , 5 ] ) ,
812
+ ) ;
813
+ } ) ;
814
+ } ) ;
815
+
819
816
describe ( 'tap() tests' , ( ) => {
820
817
const coll = createTestCollection ( ) ;
821
818
@@ -845,6 +842,19 @@ describe('toJSON() tests', () => {
845
842
} ) ;
846
843
} ) ;
847
844
845
+ describe ( 'union() tests' , ( ) => {
846
+ const coll1 = createCollectionFrom ( [ 'a' , 1 ] , [ 'b' , 2 ] ) ;
847
+ const coll2 = createCollectionFrom ( [ 'a' , 1 ] , [ 'c' , 3 ] ) ;
848
+
849
+ test ( 'it returns the union of the collections' , ( ) => {
850
+ const c = coll1 . union ( coll2 ) ;
851
+ expect ( c ) . toBeInstanceOf ( Collection ) ;
852
+ expect ( c . size ) . toStrictEqual ( 3 ) ;
853
+
854
+ expect ( c ) . toStrictEqual ( createCollectionFrom ( [ 'a' , 1 ] , [ 'b' , 2 ] , [ 'c' , 3 ] ) ) ;
855
+ } ) ;
856
+ } ) ;
857
+
848
858
describe ( 'random thisArg tests' , ( ) => {
849
859
const coll = createCollectionFrom ( [ 'a' , 3 ] , [ 'b' , 2 ] , [ 'c' , 1 ] ) as Collection < string , unknown > ;
850
860
0 commit comments