@@ -1438,6 +1438,57 @@ describe('ListWatchCache', () => {
14381438 expect ( reqOpts . qs . labelSelector ) . to . equal ( APP_LABEL_SELECTOR ) ;
14391439 } ) ;
14401440
1441+ it ( 'should send field selector' , async ( ) => {
1442+ const APP_FIELD_SELECTOR = 'metadata.name=name1' ;
1443+
1444+ const list : V1Namespace [ ] = [
1445+ {
1446+ metadata : {
1447+ name : 'name1' ,
1448+ } as V1ObjectMeta ,
1449+ } as V1Namespace ,
1450+ {
1451+ metadata : {
1452+ name : 'name2' ,
1453+ } as V1ObjectMeta ,
1454+ } as V1Namespace ,
1455+ ] ;
1456+ const listObj = {
1457+ metadata : {
1458+ resourceVersion : '12345' ,
1459+ } as V1ListMeta ,
1460+ items : list ,
1461+ } as V1NamespaceList ;
1462+
1463+ const listFn : ListPromise < V1Namespace > = function ( ) : Promise < {
1464+ response : http . IncomingMessage ;
1465+ body : V1NamespaceList ;
1466+ } > {
1467+ return new Promise < { response : http . IncomingMessage ; body : V1NamespaceList } > (
1468+ ( resolve , reject ) => {
1469+ resolve ( { response : { } as http . IncomingMessage , body : listObj } ) ;
1470+ } ,
1471+ ) ;
1472+ } ;
1473+
1474+ const kc = new KubeConfig ( ) ;
1475+ Object . assign ( kc , fakeConfig ) ;
1476+ const fakeRequestor = mock . mock ( DefaultRequest ) ;
1477+ const watch = new Watch ( kc , mock . instance ( fakeRequestor ) ) ;
1478+
1479+ const fakeRequest = new FakeRequest ( ) ;
1480+ mock . when ( fakeRequestor . webRequest ( mock . anything ( ) ) ) . thenReturn ( fakeRequest ) ;
1481+
1482+ const informer = new ListWatch ( '/some/path' , watch , listFn , false , undefined , APP_FIELD_SELECTOR ) ;
1483+
1484+ await informer . start ( ) ;
1485+
1486+ mock . verify ( fakeRequestor . webRequest ( mock . anything ( ) ) ) ;
1487+ const [ opts ] = mock . capture ( fakeRequestor . webRequest ) . last ( ) ;
1488+ const reqOpts : request . OptionsWithUri = opts as request . OptionsWithUri ;
1489+ expect ( reqOpts . qs . fieldSelector ) . to . equal ( APP_FIELD_SELECTOR ) ;
1490+ } ) ;
1491+
14411492 it ( 'should ignore request errors after it is aborted' , async ( ) => {
14421493 const fakeWatch = mock . mock ( Watch ) ;
14431494 const list : V1Pod [ ] = [ ] ;
0 commit comments