@@ -670,6 +670,12 @@ describe('parsePastedLookup', () => {
670670 lookup : new QueryLookup ( { isPublic : true } ) ,
671671 required : true ,
672672 } ) ;
673+ const multiValueLookup = new QueryColumn ( {
674+ jsonType : 'string' ,
675+ caption : 'MultiValueLookupCol' ,
676+ lookup : new QueryLookup ( { isPublic : true , multiValued : 'junction' } ) ,
677+ multiValue : true ,
678+ } ) ;
673679
674680 const intLookupValues = [
675681 { display : 'A' , raw : 1 } ,
@@ -683,24 +689,20 @@ describe('parsePastedLookup', () => {
683689 ] ;
684690
685691 test ( 'empty' , ( ) => {
686- [ undefined , null , '' , ' ' ] . forEach ( val => {
692+ const emptyValues = [ undefined , null , '' , ' ' ] ;
693+ emptyValues . forEach ( val => {
687694 expect ( parsePastedLookup ( intLookupCol , intLookupValues , val ) ) . toStrictEqual ( {
688- valueDescriptors : List ( [
689- {
690- display : val ,
691- raw : val ,
692- } ,
693- ] ) ,
695+ valueDescriptors : List ( [ { display : val , raw : val } ] ) ,
694696 } ) ;
695697 } ) ;
696- [ undefined , null , '' , ' ' ] . forEach ( val => {
698+ emptyValues . forEach ( val => {
697699 expect ( parsePastedLookup ( stringLookupCol , stringLookupValues , val ) ) . toStrictEqual ( {
698- valueDescriptors : List ( [
699- {
700- display : val ,
701- raw : val ,
702- } ,
703- ] ) ,
700+ valueDescriptors : List ( [ { display : val , raw : val } ] ) ,
701+ } ) ;
702+ } ) ;
703+ emptyValues . forEach ( val => {
704+ expect ( parsePastedLookup ( multiValueLookup , stringLookupValues , val ) ) . toStrictEqual ( {
705+ valueDescriptors : List ( [ { display : val , raw : val } ] ) ,
704706 } ) ;
705707 } ) ;
706708 } ) ;
@@ -719,12 +721,11 @@ describe('parsePastedLookup', () => {
719721 valueDescriptors : List ( [ { display : 'value D' , raw : 'd' } ] ) ,
720722 } ) ;
721723 expect ( parsePastedLookup ( stringLookupCol , stringLookupValues , 'b,C,value D' ) ) . toStrictEqual ( {
722- message : undefined ,
723- valueDescriptors : List ( [
724- { display : 'b' , raw : 'B' } ,
725- { display : 'C' , raw : 'C' } ,
726- { display : 'value D' , raw : 'd' } ,
727- ] ) ,
724+ message : {
725+ message :
726+ 'Could not find "b,C,value D". Please make sure values that contain commas are properly quoted.' ,
727+ } ,
728+ valueDescriptors : List ( [ { display : 'b,C,value D' , raw : 'b,C,value D' } ] ) ,
728729 } ) ;
729730
730731 expect ( parsePastedLookup ( stringLookupCol , stringLookupValues , 'abc' ) ) . toStrictEqual ( {
@@ -734,12 +735,9 @@ describe('parsePastedLookup', () => {
734735 expect ( parsePastedLookup ( stringLookupCol , stringLookupValues , 'abc, valueD' ) ) . toStrictEqual ( {
735736 message : {
736737 message :
737- 'Could not find "abc", " valueD". Please make sure values that contain commas are properly quoted.' ,
738+ 'Could not find "abc, valueD". Please make sure values that contain commas are properly quoted.' ,
738739 } ,
739- valueDescriptors : List ( [
740- { display : 'abc' , raw : 'abc' } ,
741- { display : 'valueD' , raw : 'valueD' } ,
742- ] ) ,
740+ valueDescriptors : List ( [ { display : 'abc, valueD' , raw : 'abc, valueD' } ] ) ,
743741 } ) ;
744742 } ) ;
745743
@@ -753,12 +751,10 @@ describe('parsePastedLookup', () => {
753751 valueDescriptors : List ( [ { display : 'A' , raw : 1 } ] ) ,
754752 } ) ;
755753 expect ( parsePastedLookup ( intLookupCol , intLookupValues , 'A,B,b' ) ) . toStrictEqual ( {
756- message : undefined ,
757- valueDescriptors : List ( [
758- { display : 'A' , raw : 1 } ,
759- { display : 'b' , raw : 2 } ,
760- { display : 'b' , raw : 2 } ,
761- ] ) ,
754+ message : {
755+ message : 'Could not find "A,B,b". Please make sure values that contain commas are properly quoted.' ,
756+ } ,
757+ valueDescriptors : List ( [ { display : 'A,B,b' , raw : 'A,B,b' } ] ) ,
762758 } ) ;
763759
764760 expect ( parsePastedLookup ( intLookupCol , intLookupValues , 'abc' ) ) . toStrictEqual ( {
@@ -768,12 +764,9 @@ describe('parsePastedLookup', () => {
768764 expect ( parsePastedLookup ( intLookupCol , intLookupValues , 'abc, valueD' ) ) . toStrictEqual ( {
769765 message : {
770766 message :
771- 'Could not find "abc", " valueD". Please make sure values that contain commas are properly quoted.' ,
767+ 'Could not find "abc, valueD". Please make sure values that contain commas are properly quoted.' ,
772768 } ,
773- valueDescriptors : List ( [
774- { display : 'abc' , raw : 'abc' } ,
775- { display : 'valueD' , raw : 'valueD' } ,
776- ] ) ,
769+ valueDescriptors : List ( [ { display : 'abc, valueD' , raw : 'abc, valueD' } ] ) ,
777770 } ) ;
778771 } ) ;
779772
@@ -784,18 +777,43 @@ describe('parsePastedLookup', () => {
784777 } ) ;
785778 [ undefined , null , '' ] . forEach ( val => {
786779 expect ( parsePastedLookup ( requiredLookupCol , stringLookupValues , val ) ) . toStrictEqual ( {
787- message : {
788- message : 'ReqLookCol is required.' ,
789- } ,
790- valueDescriptors : List ( [
791- {
792- display : val ,
793- raw : val ,
794- } ,
795- ] ) ,
780+ message : { message : 'ReqLookCol is required.' } ,
781+ valueDescriptors : List ( [ { display : val , raw : val } ] ) ,
796782 } ) ;
797783 } ) ;
798784 } ) ;
785+
786+ test ( 'multi-value column' , ( ) => {
787+ expect ( parsePastedLookup ( multiValueLookup , stringLookupValues , 'A' ) ) . toStrictEqual ( {
788+ message : undefined ,
789+ valueDescriptors : List ( [ { display : 'A' , raw : 'a' } ] ) ,
790+ } ) ;
791+ expect ( parsePastedLookup ( multiValueLookup , stringLookupValues , 'a' ) ) . toStrictEqual ( {
792+ message : undefined ,
793+ valueDescriptors : List ( [ { display : 'A' , raw : 'a' } ] ) ,
794+ } ) ;
795+ expect ( parsePastedLookup ( multiValueLookup , stringLookupValues , 'value D' ) ) . toStrictEqual ( {
796+ message : undefined ,
797+ valueDescriptors : List ( [ { display : 'value D' , raw : 'd' } ] ) ,
798+ } ) ;
799+ expect ( parsePastedLookup ( multiValueLookup , stringLookupValues , 'b,C,value D' ) ) . toStrictEqual ( {
800+ message : undefined ,
801+ valueDescriptors : List ( [
802+ { display : 'b' , raw : 'B' } ,
803+ { display : 'C' , raw : 'C' } ,
804+ { display : 'value D' , raw : 'd' } ,
805+ ] ) ,
806+ } ) ;
807+ expect ( parsePastedLookup ( multiValueLookup , stringLookupValues , 'b,C,value D,404' ) ) . toStrictEqual ( {
808+ message : { message : 'Could not find "404"' } ,
809+ valueDescriptors : List ( [
810+ { display : 'b' , raw : 'B' } ,
811+ { display : 'C' , raw : 'C' } ,
812+ { display : 'value D' , raw : 'd' } ,
813+ { display : '404' , raw : '404' } ,
814+ ] ) ,
815+ } ) ;
816+ } ) ;
799817} ) ;
800818
801819describe ( 'insertPastedData' , ( ) => {
0 commit comments