test: migrate clipboard spec to spec-main (#35059)
This commit is contained in:
parent
2c51a81e85
commit
ad1bbc198b
1 changed files with 9 additions and 10 deletions
|
@ -1,9 +1,8 @@
|
||||||
const { expect } = require('chai');
|
import { expect } from 'chai';
|
||||||
const path = require('path');
|
import * as path from 'path';
|
||||||
const { Buffer } = require('buffer');
|
import { Buffer } from 'buffer';
|
||||||
const { ifdescribe, ifit } = require('./spec-helpers');
|
import { ifdescribe, ifit } from './spec-helpers';
|
||||||
|
import { clipboard, nativeImage } from 'electron/common';
|
||||||
const { clipboard, nativeImage } = require('electron');
|
|
||||||
|
|
||||||
// FIXME(zcbenz): Clipboard tests are failing on WOA.
|
// FIXME(zcbenz): Clipboard tests are failing on WOA.
|
||||||
ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('clipboard module', () => {
|
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', () => {
|
it('returns NativeImage instance', () => {
|
||||||
const p = path.join(fixtures, 'assets', 'logo.png');
|
const p = path.join(fixtures, 'assets', 'logo.png');
|
||||||
const i = nativeImage.createFromPath(p);
|
const i = nativeImage.createFromPath(p);
|
||||||
clipboard.writeImage(p);
|
clipboard.writeImage(i);
|
||||||
const readImage = clipboard.readImage();
|
const readImage = clipboard.readImage();
|
||||||
expect(readImage.toDataURL()).to.equal(i.toDataURL());
|
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';
|
const type = process.platform === 'darwin' ? 'NSFilenamesPboardType' : 'FileNameW';
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
const result = clipboard.read(type);
|
clipboard.read(type);
|
||||||
}).to.not.throw();
|
}).to.not.throw();
|
||||||
});
|
});
|
||||||
it('can read data written with writeBuffer', () => {
|
it('can read data written with writeBuffer', () => {
|
||||||
|
@ -91,7 +90,7 @@ ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('clipboard
|
||||||
html: '<b>Hi</b>',
|
html: '<b>Hi</b>',
|
||||||
rtf: '{\\rtf1\\utf8 text}',
|
rtf: '{\\rtf1\\utf8 text}',
|
||||||
bookmark: 'a title',
|
bookmark: 'a title',
|
||||||
image: p
|
image: i
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(clipboard.readText()).to.equal(text);
|
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', () => {
|
it('throws an error when a non-Buffer is specified', () => {
|
||||||
expect(() => {
|
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/);
|
}).to.throw(/buffer must be a node Buffer/);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue