當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript NsisUpdater.NsisUpdater類代碼示例

本文整理匯總了TypeScript中electron-updater/out/NsisUpdater.NsisUpdater的典型用法代碼示例。如果您正苦於以下問題:TypeScript NsisUpdater類的具體用法?TypeScript NsisUpdater怎麽用?TypeScript NsisUpdater使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了NsisUpdater類的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)
})
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:29,代碼來源:nsisUpdaterTest.ts

示例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()
})
開發者ID:jwheare,項目名稱:electron-builder,代碼行數:12,代碼來源:nsisUpdaterTest.ts

示例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()
})
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:13,代碼來源:nsisUpdaterTest.ts

示例4: test

test("file url generic - manual download", async () => {
  const updater = new NsisUpdater()
  updater.updateConfigPath = await writeUpdateConfig<GenericServerOptions>({
    provider: "generic",
    url: "https://develar.s3.amazonaws.com/test",
  })
  tuneNsisUpdater(updater)
  updater.autoDownload = false

  const actualEvents = trackEvents(updater)

  const updateCheckResult = await updater.checkForUpdates()
  expect(removeUnstableProperties(updateCheckResult.updateInfo)).toMatchSnapshot()
  expect(updateCheckResult.downloadPromise).toBeNull()
  expect(actualEvents).toMatchSnapshot()

  await assertThat(path.join((await updater.downloadUpdate())[0])).isFile()
})
開發者ID:ledinhphuong,項目名稱:electron-builder,代碼行數:18,代碼來源:nsisUpdaterTest.ts

示例5: trackEvents

function trackEvents(updater: NsisUpdater) {
  const actualEvents: Array<string> = []
  for (const eventName of ["checking-for-update", "update-available", "update-downloaded", "error"]) {
    updater.addListener(eventName, () => {
      actualEvents.push(eventName)
    })
  }
  return actualEvents
}
開發者ID:yuya-oc,項目名稱:electron-builder,代碼行數:9,代碼來源:nsisUpdaterTest.ts


注:本文中的electron-updater/out/NsisUpdater.NsisUpdater類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。