@@ -33,6 +33,9 @@ describe('application records', () => {
3333
3434 await application . Save ( dbManager ) ;
3535
36+ //
37+ // Single item key
38+ //
3639 {
3740 const { Item } = await dbManager . ddbDocClient . get ( {
3841 TableName : TEST_TABLE_NAME ,
@@ -45,6 +48,9 @@ describe('application records', () => {
4548 expect ( Item ?. DisplayName ) . toBe ( 'Dog' ) ;
4649 }
4750
51+ //
52+ // List key
53+ //
4854 {
4955 const { Item } = await dbManager . ddbDocClient . get ( {
5056 TableName : TEST_TABLE_NAME ,
@@ -59,6 +65,96 @@ describe('application records', () => {
5965 }
6066 } ) ;
6167
68+ it . only ( 'saving an application with two extra appnames should create four records' , async ( ) => {
69+ const application = new Application ( ) ;
70+ application . AppName = 'Cat' ;
71+ application . DisplayName = 'Dog' ;
72+ application . ExtraAppNames = [ 'Kitty' , 'Kitten' ] ;
73+
74+ await application . Save ( dbManager ) ;
75+
76+ //
77+ // Single item key
78+ //
79+
80+ // Get the primary app record
81+ {
82+ const { Item } = await dbManager . ddbDocClient . get ( {
83+ TableName : TEST_TABLE_NAME ,
84+ Key : { PK : 'appname#cat' , SK : 'application' } ,
85+ } ) ;
86+ expect ( Item ) . toBeDefined ( ) ;
87+ expect ( Item ?. PK ) . toBe ( 'appname#cat' ) ;
88+ expect ( Item ?. SK ) . toBe ( 'application' ) ;
89+ expect ( Item ?. AppName ) . toBe ( 'cat' ) ;
90+ expect ( Item ?. DisplayName ) . toBe ( 'Dog' ) ;
91+ }
92+
93+ // Get the secondary app records
94+ {
95+ const { Item } = await dbManager . ddbDocClient . get ( {
96+ TableName : TEST_TABLE_NAME ,
97+ Key : { PK : 'appname#kitty' , SK : 'application' } ,
98+ } ) ;
99+ expect ( Item ) . toBeDefined ( ) ;
100+ expect ( Item ?. PK ) . toBe ( 'appname#kitty' ) ;
101+ expect ( Item ?. SK ) . toBe ( 'application' ) ;
102+ expect ( Item ?. AppName ) . toBe ( 'cat' ) ;
103+ expect ( Item ?. DisplayName ) . toBe ( 'Dog' ) ;
104+ }
105+ {
106+ const { Item } = await dbManager . ddbDocClient . get ( {
107+ TableName : TEST_TABLE_NAME ,
108+ Key : { PK : 'appname#kitten' , SK : 'application' } ,
109+ } ) ;
110+ expect ( Item ) . toBeDefined ( ) ;
111+ expect ( Item ?. PK ) . toBe ( 'appname#kitten' ) ;
112+ expect ( Item ?. SK ) . toBe ( 'application' ) ;
113+ expect ( Item ?. AppName ) . toBe ( 'cat' ) ;
114+ expect ( Item ?. DisplayName ) . toBe ( 'Dog' ) ;
115+ }
116+
117+ //
118+ // List key
119+ //
120+ {
121+ const { Item } = await dbManager . ddbDocClient . get ( {
122+ TableName : TEST_TABLE_NAME ,
123+ Key : { PK : 'applications' , SK : 'appname#cat' } ,
124+ // ProjectionExpression: 'PK,SK,AppName,DisplayName',
125+ } ) ;
126+ expect ( Item ) . toBeDefined ( ) ;
127+ expect ( Item ?. PK ) . toBe ( 'applications' ) ;
128+ expect ( Item ?. SK ) . toBe ( 'appname#cat' ) ;
129+ expect ( Item ?. AppName ) . toBe ( 'cat' ) ;
130+ expect ( Item ?. DisplayName ) . toBe ( 'Dog' ) ;
131+ }
132+ {
133+ const { Item } = await dbManager . ddbDocClient . get ( {
134+ TableName : TEST_TABLE_NAME ,
135+ Key : { PK : 'applications' , SK : 'appname#keey' } ,
136+ // ProjectionExpression: 'PK,SK,AppName,DisplayName',
137+ } ) ;
138+ expect ( Item ) . toBeDefined ( ) ;
139+ expect ( Item ?. PK ) . toBe ( 'applications' ) ;
140+ expect ( Item ?. SK ) . toBe ( 'appname#kitty' ) ;
141+ expect ( Item ?. AppName ) . toBe ( 'cat' ) ;
142+ expect ( Item ?. DisplayName ) . toBe ( 'Dog' ) ;
143+ }
144+ {
145+ const { Item } = await dbManager . ddbDocClient . get ( {
146+ TableName : TEST_TABLE_NAME ,
147+ Key : { PK : 'applications' , SK : 'appname#kitten' } ,
148+ // ProjectionExpression: 'PK,SK,AppName,DisplayName',
149+ } ) ;
150+ expect ( Item ) . toBeDefined ( ) ;
151+ expect ( Item ?. PK ) . toBe ( 'applications' ) ;
152+ expect ( Item ?. SK ) . toBe ( 'appname#kitten' ) ;
153+ expect ( Item ?. AppName ) . toBe ( 'cat' ) ;
154+ expect ( Item ?. DisplayName ) . toBe ( 'Dog' ) ;
155+ }
156+ } ) ;
157+
62158 it ( 'load function should load records' , async ( ) => {
63159 let application = new Application ( ) ;
64160 application . AppName = 'App1' ;
0 commit comments