如何使用React / Karma / Jasmine测试window.getSelection()?

时间:2015-09-04 12:00:12

标签: reactjs jasmine karma-runner webpack

我有这个测试:

    Dim clientS As ClientSecrets = New ClientSecrets()
    clientS.ClientId = "ClientID"
    clientS.ClientSecret = "MySecret"
    Dim scopes As IList(Of String) = New List(Of String)()

    scopes.Add(DriveService.Scope.Drive)
    scopes.Add(DriveService.Scope.DriveFile)
    Dim credentials As UserCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(clientS, scopes, Me.UserEmail, System.Threading.CancellationToken.None, New FileDataStore(Me.TokensFolderPath)).Result

    Dim initializer As BaseClientService.Initializer = New BaseClientService.Initializer()
    initializer.HttpClientInitializer = credentials
    initializer.ApplicationName = "Drive API Test"

    Me.service = New DriveService(initializer)

这是我的setCaretPosition方法

  it("should allow to set the caret position", ->
    editor = TestUtils.renderIntoDocument <Editor />
    editor.setContent(lines)
    editor.setCaretPosition(6)
    selection = window.getSelection();
    expect(selection.anchorNode.outerHTML).toBe("<span>      <br /></span>");
  )

但是从setCaretPosition返回的选择将rangeCount设置为0,这意味着addRange不起作用。

我不确定是什么问题。我正在使用Webpack,React,Jasmine和Karma与Chrome Launcher。任何人都知道如何使这个测试工作?

0 个答案:

没有答案