本文整理汇总了TypeScript中electron-updater/out/NsisUpdater.NsisUpdater.checkForUpdates方法的典型用法代码示例。如果您正苦于以下问题:TypeScript NsisUpdater.checkForUpdates方法的具体用法?TypeScript NsisUpdater.checkForUpdates怎么用?TypeScript NsisUpdater.checkForUpdates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron-updater/out/NsisUpdater.NsisUpdater
的用法示例。
在下文中一共展示了NsisUpdater.checkForUpdates方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test("cancel download with progress", async () => {
const updater = new NsisUpdater()
updater.updateConfigPath = await writeUpdateConfig({
provider: "generic",
url: "https://develar.s3.amazonaws.com/full-test",
})
tuneNsisUpdater(updater)
const progressEvents: Array<any> = []
updater.signals.progress(it => progressEvents.push(it))
let cancelled = false
updater.signals.updateCancelled(() => cancelled = true)
const checkResult = await updater.checkForUpdates()
checkResult.cancellationToken.cancel()
if (progressEvents.length > 0) {
const lastEvent = progressEvents[progressEvents.length - 1]
expect(lastEvent.percent).not.toBe(100)
expect(lastEvent.bytesPerSecond).toBeGreaterThan(1)
expect(lastEvent.transferred).not.toBe(lastEvent.total)
}
const downloadPromise = checkResult.downloadPromise as BluebirdPromise<any>
await assertThat(downloadPromise).throws()
expect(downloadPromise.isRejected()).toBe(true)
expect(cancelled).toBe(true)
})
示例2: test
test("check updates - no versions at all", async () => {
const updater = new NsisUpdater()
tuneNsisUpdater(updater)
// tslint:disable-next-line:no-object-literal-type-assertion
updater.setFeedURL({
provider: "bintray",
owner: "actperepo",
package: "no-versions",
} as BintrayOptions)
await assertThat(updater.checkForUpdates()).throws()
})
示例3: async
test.ifAll.ifWindows("invalid signature", async () => {
const updater = new NsisUpdater()
updater.updateConfigPath = await writeUpdateConfig({
provider: "github",
owner: "develar",
repo: "__test_nsis_release",
publisherName: ["Foo Bar"],
})
tuneNsisUpdater(updater)
const actualEvents = trackEvents(updater)
await assertThat(updater.checkForUpdates().then(it => it.downloadPromise)).throws()
expect(actualEvents).toMatchSnapshot()
})
示例4: checkResult
async function checkResult(updater: NsisUpdater) {
const updateCheckResult = await updater.checkForUpdates()
const downloadPromise = updateCheckResult.downloadPromise
expect(downloadPromise).not.toBeNull()
const files = await downloadPromise
const fileInfo: any = updateCheckResult.updateInfo.files[0]
// because port is random
expect(fileInfo.url).toBeDefined()
delete fileInfo.url
expect(removeUnstableProperties(updateCheckResult.updateInfo)).toMatchSnapshot()
expect(files!!.map(it => path.basename(it))).toMatchSnapshot()
}
示例5: validateDownload
async function validateDownload(updater: NsisUpdater, expectDownloadPromise = true) {
tuneNsisUpdater(updater)
const actualEvents = trackEvents(updater)
const updateCheckResult = await updater.checkForUpdates()
expect(updateCheckResult.fileInfo).toMatchSnapshot()
if (expectDownloadPromise) {
await assertThat(path.join(await updateCheckResult.downloadPromise)).isFile()
}
else {
expect(updateCheckResult.downloadPromise).toBeUndefined()
}
expect(actualEvents).toMatchSnapshot()
return updateCheckResult
}