单元测试打字稿类型

时间:2018-11-01 00:37:21

标签: angular typescript jasmine typescript-typings

我的一个模块中具有以下导出功能:

tmp <- dt[,list(par1=par1[which.max(perf)],par2=par2[which.max(perf)],perf=max(perf)),by=list(ticker,row_names)]
    res <- tmp[,list(perf=mean(perf),par1= paste(par1,collapse=","),par2=paste(par2,collapse=",")),by=row_names]

我正在尝试找出测试data.table的最佳方法,以确保它是我定义的类型。例如:

row_names

当然,上述操作不起作用,因为我使用> res row_names perf par1 par2 1: M 0.010413549 2,2 2,1 2: N 0.009508122 2,2 1,1 3: O 0.009314068 1,1 2,1 4: P 0.008883106 2,1 2,2 5: Q 0.009316006 2,2 2,2 作为变量。关于如何实现上述目标的任何想法?

对于上下文,我使用的是角,ngrx和茉莉花。

1 个答案:

答案 0 :(得分:0)

我没有用工会尝试过,但是您可能想尝试jasmine.any(Type)。在这种情况下,您上面的代码将是:

it('should have the correct types', () => {
  expect(Action1).toEqual(jasmine.any(ActionsUnion));
  expect(Action2).toEqual(jasmine.any(ActionsUnion));
});

详细信息在这里: https://jasmine.github.io/2.0/introduction.html#section-Matching_Anything_with_%3Ccode%3Ejasmine.any%3C/code%3E

相关问题