@@ -64,6 +64,41 @@ describe('cache-base', function() {
6464 } ) ;
6565 } ) ;
6666
67+ describe ( '.union()' , function ( ) {
68+ it ( 'should union a string value' , function ( ) {
69+ app . union ( 'a' , 'b' ) ;
70+ assert . deepEqual ( app . get ( 'a' ) , [ 'b' ] ) ;
71+ } ) ;
72+
73+ it ( 'should union multiple string values' , function ( ) {
74+ app . union ( 'a' , 'b' ) ;
75+ app . union ( 'a' , 'c' ) ;
76+ app . union ( 'a' , 'd' ) ;
77+ assert . deepEqual ( app . get ( 'a' ) , [ 'b' , 'c' , 'd' ] ) ;
78+ } ) ;
79+
80+ it ( 'should union multiple arrays' , function ( ) {
81+ app . union ( 'a' , [ 'b' ] ) ;
82+ app . union ( 'a' , [ 'c' ] ) ;
83+ app . union ( 'a' , [ 'd' ] ) ;
84+ assert . deepEqual ( app . get ( 'a' ) , [ 'b' , 'c' , 'd' ] ) ;
85+ } ) ;
86+
87+ it ( 'should union nested string values' , function ( ) {
88+ app . union ( 'a.b' , 'b' ) ;
89+ app . union ( 'a.b' , 'c' ) ;
90+ app . union ( 'a.b' , 'd' ) ;
91+ assert . deepEqual ( app . get ( 'a' ) , { b : [ 'b' , 'c' , 'd' ] } ) ;
92+ } ) ;
93+
94+ it ( 'should union and uniquify arrays' , function ( ) {
95+ app . union ( 'a.b' , [ 'b' , 'foo' ] ) ;
96+ app . union ( 'a.b' , [ 'c' , 'foo' ] ) ;
97+ app . union ( 'a.b' , [ 'd' , 'foo' ] ) ;
98+ assert . deepEqual ( app . get ( 'a' ) , { b : [ 'b' , 'foo' , 'c' , 'd' ] } ) ;
99+ } ) ;
100+ } ) ;
101+
67102 describe ( '.set()' , function ( ) {
68103 it ( 'should set a value' , function ( ) {
69104 app . set ( 'a' , 'b' ) ;
0 commit comments