当前位置: 首页>>代码示例>>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;未经允许,请勿转载。