From ad1bbc198b2e9387c5317b90466b77172f27ab56 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Tue, 26 Jul 2022 00:37:37 -0700 Subject: [PATCH] test: migrate clipboard spec to spec-main (#35059) --- .../api-clipboard-spec.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) rename spec/api-clipboard-spec.js => spec-main/api-clipboard-spec.ts (92%) diff --git a/spec/api-clipboard-spec.js b/spec-main/api-clipboard-spec.ts similarity index 92% rename from spec/api-clipboard-spec.js rename to spec-main/api-clipboard-spec.ts index fb08eb768f6d..604c8d03bfa4 100644 --- a/spec/api-clipboard-spec.js +++ b/spec-main/api-clipboard-spec.ts @@ -1,9 +1,8 @@ -const { expect } = require('chai'); -const path = require('path'); -const { Buffer } = require('buffer'); -const { ifdescribe, ifit } = require('./spec-helpers'); - -const { clipboard, nativeImage } = require('electron'); +import { expect } from 'chai'; +import * as path from 'path'; +import { Buffer } from 'buffer'; +import { ifdescribe, ifit } from './spec-helpers'; +import { clipboard, nativeImage } from 'electron/common'; // FIXME(zcbenz): Clipboard tests are failing on WOA. ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('clipboard module', () => { @@ -13,7 +12,7 @@ ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('clipboard it('returns NativeImage instance', () => { const p = path.join(fixtures, 'assets', 'logo.png'); const i = nativeImage.createFromPath(p); - clipboard.writeImage(p); + clipboard.writeImage(i); const readImage = clipboard.readImage(); expect(readImage.toDataURL()).to.equal(i.toDataURL()); }); @@ -67,7 +66,7 @@ ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('clipboard const type = process.platform === 'darwin' ? 'NSFilenamesPboardType' : 'FileNameW'; expect(() => { - const result = clipboard.read(type); + clipboard.read(type); }).to.not.throw(); }); it('can read data written with writeBuffer', () => { @@ -91,7 +90,7 @@ ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('clipboard html: 'Hi', rtf: '{\\rtf1\\utf8 text}', bookmark: 'a title', - image: p + image: i }); expect(clipboard.readText()).to.equal(text); @@ -126,7 +125,7 @@ ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('clipboard it('throws an error when a non-Buffer is specified', () => { expect(() => { - clipboard.writeBuffer('public/utf8-plain-text', 'hello'); + clipboard.writeBuffer('public/utf8-plain-text', 'hello' as any); }).to.throw(/buffer must be a node Buffer/); });