문제

질문

원자 편집기 확인 대화 상자와 상호 작용하는 코드에 대한 사양을 작성 해야하는 옵션은 무엇입니까?

배경

원자 용 패키지에서 작업하고 있으며 변경 사항을 삭제 한 다음 변경 사항을 서버로 푸시하는 명령을 가져야합니다. 명령의 동작을 확인하기 위해 테스트를 작성하고 있지만 확인 대화 상자에서 취소 / 괜 찮 아 요 단추를 클릭하는 좋은 방법으로 문제가 발생합니다

명령 코드는 다음과 같습니다

atom.workspaceView.command "mavensmate:delete-file-from-server", =>
  # do setup stuff (build the params object)
  atom.confirm
    message: "You sure?"
    buttons:
      Cancel: => # nothing to do here, just let the window close
      Delete: => # run the delete handler
        @mm.run(params).then (result) =>
          @mmResponseHandler(params, result)
.

필자는 취소 또는 삭제를 취소하거나 삭제하여 사양에서 실행하는 방법입니다. 나는 모든 원자 사양을 파고 들었고 Google을 수색했지만 아무 것도 오지 않는 것 같습니다. 나는 화면을 발행하고자하는 콜백의 인덱스로 돌아가는 것을 설정하지만 My Delete 버튼 콜백이 결코 호출되지 않습니다.

# Delete the metadata in the active pane from the server
describe 'Delete File from Server', ->
  filePath = ''

  beforeEach ->
    # set up the workspace with a fake apex class
    directory = temp.mkdirSync()
    atom.project.setPath(directory)
    filePath = path.join(directory, 'MyClass.cls')
    spyOn(mm, 'run').andCallThrough()

    waitsForPromise ->
      atom.workspace.open(filePath)

  it 'should invoke mavensmate:delete-file-from-server if confirmed', ->
    spyOn(atom, 'confirm').andReturn(1)
    atom.workspaceView.trigger 'mavensmate:delete-file-from-server'
    expect(mm.run).toHaveBeenCalled()
.

사용자가 확인 대화 상자에서 버튼을 클릭하는 사용자를 모방하는 더 좋은 방법이 있습니까? 이 테스트를받는 해결 방법이 있습니까?

도움이 되었습니까?

해결책

버튼으로 콜백을 통과하는 경우 확인 대화 상자와의 상호 작용을 시뮬레이션하는 것이 좋지만 배열을 전달하고 명령 트리거가 해당 항목에 응답하면 다음과 같이 나타나지 않습니다.원하는대로 사양을 쓸 수 있습니다.

명령 코드는 다음과 같이 표시됩니다

atom.workspaceView.command "mavensmate:delete-file-from-server", =>
  # do setup stuff (build the params object)
  atom.confirm
    message: "You sure?"
    buttons: ["Cancel", "Delete"]
  if answer == 1
    @mm.run(params).then (result) =>
      @mmResponseHandler(params, result)
.

및 사양은 현재 버전에서 작동합니다

# Delete the metadata in the active pane from the server
describe 'Delete File from Server', ->
  filePath = ''

  beforeEach ->
    # set up the workspace with a fake apex class
    directory = temp.mkdirSync()
    atom.project.setPath(directory)
    filePath = path.join(directory, 'MyClass.cls')
    spyOn(mm, 'run').andCallThrough()

    waitsForPromise ->
      atom.workspace.open(filePath)

  it 'should invoke mavensmate:delete-file-from-server if confirmed', ->
    spyOn(atom, 'confirm').andReturn(1)
    atom.workspaceView.trigger 'mavensmate:delete-file-from-server'
    expect(mm.run).toHaveBeenCalled()
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top