build: enable JS semicolons (#22783)
This commit is contained in:
parent
24e21467b9
commit
5d657dece4
354 changed files with 21512 additions and 21510 deletions
|
@ -1,146 +1,146 @@
|
|||
const { expect } = require('chai')
|
||||
const path = require('path')
|
||||
const { Buffer } = require('buffer')
|
||||
const { expect } = require('chai');
|
||||
const path = require('path');
|
||||
const { Buffer } = require('buffer');
|
||||
|
||||
const { clipboard, nativeImage } = require('electron')
|
||||
const { clipboard, nativeImage } = require('electron');
|
||||
|
||||
describe('clipboard module', () => {
|
||||
const fixtures = path.resolve(__dirname, 'fixtures')
|
||||
const fixtures = path.resolve(__dirname, 'fixtures');
|
||||
|
||||
// FIXME(zcbenz): Clipboard tests are failing on WOA.
|
||||
beforeEach(function () {
|
||||
if (process.platform === 'win32' && process.arch === 'arm64') {
|
||||
this.skip()
|
||||
this.skip();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
describe('clipboard.readImage()', () => {
|
||||
it('returns NativeImage instance', () => {
|
||||
const p = path.join(fixtures, 'assets', 'logo.png')
|
||||
const i = nativeImage.createFromPath(p)
|
||||
clipboard.writeImage(p)
|
||||
expect(clipboard.readImage().toDataURL()).to.equal(i.toDataURL())
|
||||
})
|
||||
})
|
||||
const p = path.join(fixtures, 'assets', 'logo.png');
|
||||
const i = nativeImage.createFromPath(p);
|
||||
clipboard.writeImage(p);
|
||||
expect(clipboard.readImage().toDataURL()).to.equal(i.toDataURL());
|
||||
});
|
||||
});
|
||||
|
||||
describe('clipboard.readText()', () => {
|
||||
it('returns unicode string correctly', () => {
|
||||
const text = '千江有水千江月,万里无云万里天'
|
||||
clipboard.writeText(text)
|
||||
expect(clipboard.readText()).to.equal(text)
|
||||
})
|
||||
})
|
||||
const text = '千江有水千江月,万里无云万里天';
|
||||
clipboard.writeText(text);
|
||||
expect(clipboard.readText()).to.equal(text);
|
||||
});
|
||||
});
|
||||
|
||||
describe('clipboard.readHTML()', () => {
|
||||
it('returns markup correctly', () => {
|
||||
const text = '<string>Hi</string>'
|
||||
const markup = process.platform === 'darwin' ? "<meta charset='utf-8'><string>Hi</string>" : process.platform === 'linux' ? '<meta http-equiv="content-type" ' + 'content="text/html; charset=utf-8"><string>Hi</string>' : '<string>Hi</string>'
|
||||
clipboard.writeHTML(text)
|
||||
expect(clipboard.readHTML()).to.equal(markup)
|
||||
})
|
||||
})
|
||||
const text = '<string>Hi</string>';
|
||||
const markup = process.platform === 'darwin' ? "<meta charset='utf-8'><string>Hi</string>" : process.platform === 'linux' ? '<meta http-equiv="content-type" ' + 'content="text/html; charset=utf-8"><string>Hi</string>' : '<string>Hi</string>';
|
||||
clipboard.writeHTML(text);
|
||||
expect(clipboard.readHTML()).to.equal(markup);
|
||||
});
|
||||
});
|
||||
|
||||
describe('clipboard.readRTF', () => {
|
||||
it('returns rtf text correctly', () => {
|
||||
const rtf = '{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\nThis is some {\\b bold} text.\\par\n}'
|
||||
clipboard.writeRTF(rtf)
|
||||
expect(clipboard.readRTF()).to.equal(rtf)
|
||||
})
|
||||
})
|
||||
const rtf = '{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\nThis is some {\\b bold} text.\\par\n}';
|
||||
clipboard.writeRTF(rtf);
|
||||
expect(clipboard.readRTF()).to.equal(rtf);
|
||||
});
|
||||
});
|
||||
|
||||
describe('clipboard.readBookmark', () => {
|
||||
before(function () {
|
||||
if (process.platform === 'linux') {
|
||||
this.skip()
|
||||
this.skip();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
it('returns title and url', () => {
|
||||
clipboard.writeBookmark('a title', 'https://electronjs.org')
|
||||
clipboard.writeBookmark('a title', 'https://electronjs.org');
|
||||
expect(clipboard.readBookmark()).to.deep.equal({
|
||||
title: 'a title',
|
||||
url: 'https://electronjs.org'
|
||||
})
|
||||
});
|
||||
|
||||
clipboard.writeText('no bookmark')
|
||||
clipboard.writeText('no bookmark');
|
||||
expect(clipboard.readBookmark()).to.deep.equal({
|
||||
title: '',
|
||||
url: ''
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('clipboard.write()', () => {
|
||||
it('returns data correctly', () => {
|
||||
const text = 'test'
|
||||
const rtf = '{\\rtf1\\utf8 text}'
|
||||
const p = path.join(fixtures, 'assets', 'logo.png')
|
||||
const i = nativeImage.createFromPath(p)
|
||||
const markup = process.platform === 'darwin' ? "<meta charset='utf-8'><b>Hi</b>" : process.platform === 'linux' ? '<meta http-equiv="content-type" ' + 'content="text/html; charset=utf-8"><b>Hi</b>' : '<b>Hi</b>'
|
||||
const bookmark = { title: 'a title', url: 'test' }
|
||||
const text = 'test';
|
||||
const rtf = '{\\rtf1\\utf8 text}';
|
||||
const p = path.join(fixtures, 'assets', 'logo.png');
|
||||
const i = nativeImage.createFromPath(p);
|
||||
const markup = process.platform === 'darwin' ? "<meta charset='utf-8'><b>Hi</b>" : process.platform === 'linux' ? '<meta http-equiv="content-type" ' + 'content="text/html; charset=utf-8"><b>Hi</b>' : '<b>Hi</b>';
|
||||
const bookmark = { title: 'a title', url: 'test' };
|
||||
clipboard.write({
|
||||
text: 'test',
|
||||
html: '<b>Hi</b>',
|
||||
rtf: '{\\rtf1\\utf8 text}',
|
||||
bookmark: 'a title',
|
||||
image: p
|
||||
})
|
||||
});
|
||||
|
||||
expect(clipboard.readText()).to.equal(text)
|
||||
expect(clipboard.readHTML()).to.equal(markup)
|
||||
expect(clipboard.readRTF()).to.equal(rtf)
|
||||
expect(clipboard.readImage().toDataURL()).to.equal(i.toDataURL())
|
||||
expect(clipboard.readText()).to.equal(text);
|
||||
expect(clipboard.readHTML()).to.equal(markup);
|
||||
expect(clipboard.readRTF()).to.equal(rtf);
|
||||
expect(clipboard.readImage().toDataURL()).to.equal(i.toDataURL());
|
||||
|
||||
if (process.platform !== 'linux') {
|
||||
expect(clipboard.readBookmark()).to.deep.equal(bookmark)
|
||||
expect(clipboard.readBookmark()).to.deep.equal(bookmark);
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('clipboard.read/writeFindText(text)', () => {
|
||||
before(function () {
|
||||
if (process.platform !== 'darwin') {
|
||||
this.skip()
|
||||
this.skip();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
it('reads and write text to the find pasteboard', () => {
|
||||
clipboard.writeFindText('find this')
|
||||
expect(clipboard.readFindText()).to.equal('find this')
|
||||
})
|
||||
})
|
||||
clipboard.writeFindText('find this');
|
||||
expect(clipboard.readFindText()).to.equal('find this');
|
||||
});
|
||||
});
|
||||
|
||||
describe('clipboard.writeBuffer(format, buffer)', () => {
|
||||
it('writes a Buffer for the specified format', function () {
|
||||
if (process.platform !== 'darwin') {
|
||||
// FIXME(alexeykuzmin): Skip the test.
|
||||
// this.skip()
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
const buffer = Buffer.from('writeBuffer', 'utf8')
|
||||
clipboard.writeBuffer('public.utf8-plain-text', buffer)
|
||||
expect(clipboard.readText()).to.equal('writeBuffer')
|
||||
})
|
||||
const buffer = Buffer.from('writeBuffer', 'utf8');
|
||||
clipboard.writeBuffer('public.utf8-plain-text', buffer);
|
||||
expect(clipboard.readText()).to.equal('writeBuffer');
|
||||
});
|
||||
|
||||
it('throws an error when a non-Buffer is specified', () => {
|
||||
expect(() => {
|
||||
clipboard.writeBuffer('public.utf8-plain-text', 'hello')
|
||||
}).to.throw(/buffer must be a node Buffer/)
|
||||
})
|
||||
})
|
||||
clipboard.writeBuffer('public.utf8-plain-text', 'hello');
|
||||
}).to.throw(/buffer must be a node Buffer/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('clipboard.readBuffer(format)', () => {
|
||||
before(function () {
|
||||
if (process.platform !== 'darwin') {
|
||||
this.skip()
|
||||
this.skip();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
it('returns a Buffer of the content for the specified format', () => {
|
||||
const buffer = Buffer.from('this is binary', 'utf8')
|
||||
clipboard.writeText(buffer.toString())
|
||||
expect(buffer.equals(clipboard.readBuffer('public.utf8-plain-text'))).to.equal(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
const buffer = Buffer.from('this is binary', 'utf8');
|
||||
clipboard.writeText(buffer.toString());
|
||||
expect(buffer.equals(clipboard.readBuffer('public.utf8-plain-text'))).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue