@@ -13,7 +13,7 @@ describe('Parameter decorators', () => {
1313 const meta = Reflect . getMetadata ( PARAMETER_TOKEN , Test , 'index' ) ;
1414 expect ( Array . isArray ( meta ) ) . toBe ( true ) ;
1515 expect ( meta ) . toHaveLength ( 1 ) ;
16- expect ( meta ) . toMatchObject ( expect . arrayContaining ( [ { index : 0 , location : 'body' } ] ) ) ;
16+ expect ( meta ) . toMatchObject ( expect . arrayContaining ( [ expect . objectContaining ( { index : 0 , location : 'body' } ) ] ) ) ;
1717 } ) ;
1818
1919 it ( 'Header should be set.' , ( ) => {
@@ -26,13 +26,26 @@ describe('Parameter decorators', () => {
2626 expect ( meta ) . toHaveLength ( 2 ) ;
2727 expect ( meta ) . toMatchObject (
2828 expect . arrayContaining ( [
29- { index : 0 , location : 'header' , name : 'Content-Type' } ,
30- { index : 1 , location : 'header' , name : 'Referer' }
29+ expect . objectContaining ( { index : 0 , location : 'header' , name : 'Content-Type' } ) ,
30+ expect . objectContaining ( { index : 1 , location : 'header' , name : 'Referer' } )
3131 ] )
3232 ) ;
3333 } ) ;
3434
35- it ( 'Header should be set.' , ( ) => {
35+ it ( 'Query should be set for the whole query string.' , ( ) => {
36+ class Test {
37+ public index ( @Query ( ) query : any ) { }
38+ }
39+
40+ const meta = Reflect . getMetadata ( PARAMETER_TOKEN , Test , 'index' ) ;
41+ expect ( Array . isArray ( meta ) ) . toBe ( true ) ;
42+ expect ( meta ) . toHaveLength ( 1 ) ;
43+ expect ( meta ) . toMatchObject (
44+ expect . arrayContaining ( [ expect . objectContaining ( { index : 0 , location : 'query' , name : undefined } ) ] )
45+ ) ;
46+ } ) ;
47+
48+ it ( 'Query parameters should be set.' , ( ) => {
3649 class Test {
3750 public index (
3851 @Query ( 'firstName' ) firstName : string ,
@@ -46,9 +59,9 @@ describe('Parameter decorators', () => {
4659 expect ( meta ) . toHaveLength ( 3 ) ;
4760 expect ( meta ) . toMatchObject (
4861 expect . arrayContaining ( [
49- { index : 0 , location : 'query' , name : 'firstName' } ,
50- { index : 1 , location : 'query' , name : 'lastName' } ,
51- { index : 2 , location : 'query' , name : 'city' }
62+ expect . objectContaining ( { index : 0 , location : 'query' , name : 'firstName' } ) ,
63+ expect . objectContaining ( { index : 1 , location : 'query' , name : 'lastName' } ) ,
64+ expect . objectContaining ( { index : 2 , location : 'query' , name : 'city' } )
5265 ] )
5366 ) ;
5467 } ) ;
@@ -61,7 +74,7 @@ describe('Parameter decorators', () => {
6174 const meta = Reflect . getMetadata ( PARAMETER_TOKEN , Test , 'index' ) ;
6275 expect ( Array . isArray ( meta ) ) . toBe ( true ) ;
6376 expect ( meta ) . toHaveLength ( 1 ) ;
64- expect ( meta ) . toMatchObject ( expect . arrayContaining ( [ { index : 0 , location : 'request' } ] ) ) ;
77+ expect ( meta ) . toMatchObject ( expect . arrayContaining ( [ expect . objectContaining ( { index : 0 , location : 'request' } ) ] ) ) ;
6578 } ) ;
6679
6780 it ( 'Res should be set.' , ( ) => {
@@ -72,7 +85,7 @@ describe('Parameter decorators', () => {
7285 const meta = Reflect . getMetadata ( PARAMETER_TOKEN , Test , 'index' ) ;
7386 expect ( Array . isArray ( meta ) ) . toBe ( true ) ;
7487 expect ( meta ) . toHaveLength ( 1 ) ;
75- expect ( meta ) . toMatchObject ( expect . arrayContaining ( [ { index : 0 , location : 'response' } ] ) ) ;
88+ expect ( meta ) . toMatchObject ( expect . arrayContaining ( [ expect . objectContaining ( { index : 0 , location : 'response' } ) ] ) ) ;
7689 } ) ;
7790
7891 it ( 'Request and Response should be set.' , ( ) => {
@@ -85,8 +98,8 @@ describe('Parameter decorators', () => {
8598 expect ( meta ) . toHaveLength ( 2 ) ;
8699 expect ( meta ) . toMatchObject (
87100 expect . arrayContaining ( [
88- { index : 0 , location : 'request' } ,
89- { index : 1 , location : 'response' }
101+ expect . objectContaining ( { index : 0 , location : 'request' } ) ,
102+ expect . objectContaining ( { index : 1 , location : 'response' } )
90103 ] )
91104 ) ;
92105 } ) ;
0 commit comments