Atom Package Specでの確認ダイアログと対話する方法
-
21-12-2019 - |
質問
質問
Atom Editor確認ダイアログと対話するコードの仕様書を書く必要がありますか?
背景
私はAtomのパッケージに取り組んでおり、ファイルを削除するコマンドを持っているファイルをサーバーにプッシュします。コマンドの動作を検証するためのテストを書いてみたいのですが、確認ダイアログ
のキャンセル/大丈夫ボタンをクリックするとシミュレートするための良い方法で起こるのに問題があります。コマンドコードはこの
のように見えます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)
.
私が見つけることができないものは、キャンセルを取得するか、コールバックを削除するか、スペックで実行する方法です。私はすべてのAtom SpecsとGoogleの精練を掘ってきましたが、何も起きていないようです。私が発射したいコールバックのインデックスに戻ることを設定することを願っていたが、私の削除ボタンコールバックは呼び出されることはありません。
# 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()
. 所属していません StackOverflow