@@ -47,6 +47,8 @@ import {
47
47
TagsByFilterRequest ,
48
48
TagsByFilterResponse ,
49
49
TagsFilter ,
50
+ GetLatestTabularDataRequest ,
51
+ GetLatestTabularDataResponse ,
50
52
} from '../gen/app/data/v1/data_pb' ;
51
53
import { DatasetService } from '../gen/app/dataset/v1/dataset_connect' ;
52
54
import {
@@ -830,6 +832,67 @@ describe('DataClient tests', () => {
830
832
expect ( testFilter ) . toEqual ( expectedFilter ) ;
831
833
} ) ;
832
834
} ) ;
835
+
836
+ describe ( 'getLatestTabularData tests' , ( ) => {
837
+ const timeCaptured = new Date ( 2024 , 1 , 1 ) ;
838
+ const timeSynced = new Date ( 2024 , 1 , 2 ) ;
839
+ const payload = { key : 'value' } ;
840
+
841
+ beforeEach ( ( ) => {
842
+ mockTransport = createRouterTransport ( ( { service } ) => {
843
+ service ( DataService , {
844
+ getLatestTabularData : ( req ) => {
845
+ capReq = req ;
846
+ return new GetLatestTabularDataResponse ( {
847
+ timeCaptured : Timestamp . fromDate ( timeCaptured ) ,
848
+ timeSynced : Timestamp . fromDate ( timeSynced ) ,
849
+ payload : Struct . fromJson ( payload ) ,
850
+ } ) ;
851
+ } ,
852
+ } ) ;
853
+ } ) ;
854
+ } ) ;
855
+
856
+ let capReq : GetLatestTabularDataRequest ;
857
+
858
+ it ( 'get latest tabular data' , async ( ) => {
859
+ const expectedRequest = new GetLatestTabularDataRequest ( {
860
+ partId : 'testPartId' ,
861
+ resourceName : 'testResource' ,
862
+ resourceSubtype : 'testSubtype' ,
863
+ methodName : 'testMethod' ,
864
+ } ) ;
865
+
866
+ const result = await subject ( ) . getLatestTabularData (
867
+ 'testPartId' ,
868
+ 'testResource' ,
869
+ 'testSubtype' ,
870
+ 'testMethod'
871
+ ) ;
872
+
873
+ expect ( capReq ) . toStrictEqual ( expectedRequest ) ;
874
+ expect ( result ) . toEqual ( [ timeCaptured , timeSynced , payload ] ) ;
875
+ } ) ;
876
+
877
+ it ( 'returns null when no data available' , async ( ) => {
878
+ mockTransport = createRouterTransport ( ( { service } ) => {
879
+ service ( DataService , {
880
+ getLatestTabularData : ( ) => {
881
+ return new GetLatestTabularDataResponse ( { } ) ;
882
+ } ,
883
+ } ) ;
884
+ } ) ;
885
+
886
+ const result = await subject ( ) . getLatestTabularData (
887
+ 'testPartId' ,
888
+ 'testResource' ,
889
+ 'testSubtype' ,
890
+ 'testMethod'
891
+ ) ;
892
+
893
+ expect ( result ) . toBeNull ( ) ;
894
+ } ) ;
895
+ } ) ;
833
896
} ) ;
834
897
835
898
describe ( 'DatasetClient tests' , ( ) => {
0 commit comments