mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-29 03:09:53 -05:00
update dialog.showOpenDialog to promisified
This commit is contained in:
@@ -15,10 +15,7 @@ module.exports = {
|
||||
properties: ["openDirectory"]
|
||||
}
|
||||
|
||||
new Promise (resolve, reject) ->
|
||||
dialog.showOpenDialog props, (paths = []) ->
|
||||
process.nextTick ->
|
||||
## return the first path since there can only ever
|
||||
## be a single directory selection
|
||||
resolve(paths[0])
|
||||
dialog.showOpenDialog(props)
|
||||
.then ({ filePaths }) ->
|
||||
return filePaths[0]
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ Windows = require("#{root}../lib/gui/windows")
|
||||
describe "gui/dialog", ->
|
||||
context ".show", ->
|
||||
beforeEach ->
|
||||
@showOpenDialog = electron.dialog.showOpenDialog = sinon.stub()
|
||||
@showOpenDialog = electron.dialog.showOpenDialog = sinon.stub().resolves({
|
||||
filePaths: []
|
||||
})
|
||||
|
||||
it "calls dialog.showOpenDialog with args", ->
|
||||
dialog.show()
|
||||
@@ -16,13 +18,13 @@ describe "gui/dialog", ->
|
||||
})
|
||||
|
||||
it "resolves with first path", ->
|
||||
@showOpenDialog.yields(["foo", "bar"])
|
||||
@showOpenDialog.resolves({
|
||||
filePaths: ["foo", "bar"]
|
||||
})
|
||||
|
||||
dialog.show().then (ret) ->
|
||||
expect(ret).to.eq("foo")
|
||||
|
||||
it "handles null paths", ->
|
||||
@showOpenDialog.yields(null)
|
||||
|
||||
dialog.show().then (ret) ->
|
||||
expect(ret).to.eq(undefined)
|
||||
|
||||
Reference in New Issue
Block a user