在Angular2单元测试中取代了已弃用的内容?

时间:2016-07-07 17:02:25

标签: angular

我正在为我的Angular 2应用程序编写单元测试并模拟注入的服务,我们使用提供来告诉测试使用我们的模拟类而不是后面的代码。但是在IntelliJ中,我不断收到警告,告诉我提供已被弃用,而且我不应该使用它。然而,文档并不存在,无论我搜索多么困难,我都无法找到其他人提出这个问题或使用其他任何内容。

那么取而代之的是什么?

Function IsInArray(stringToBeFound As String, ByVal arr As Range) As Boolean
  IsInArray = (UBound(Filter(arr, stringToBeFound)) > -1)
End Function

LR = Range("C1500").End(xlUp).Row
ReDim acheck(1 To LR)

For i = 2 To LR
    aCheck_Row = aCheck_Row + 1
    acheck(aCheck_Row, 1) = CStr(cells(i, cA))    
Next i

For Each cell In aSelection
  If IsInArray(cell.Value, aSelection) Then
    cell.Style = "Accent1"
  End If
Next cell

1 个答案:

答案 0 :(得分:4)

而不是

  provide(ProjectService, {
    useClass: MockProjectService
  })

使用对象文字语法:

  {
    provide: ProjectService, 
    useClass: MockProjectService
  }
相关问题