Format all source code using Prettier

This commit is contained in:
Daniel Gasienica
2018-04-27 17:25:04 -04:00
parent b4dee3f30b
commit 1dd87ad197
149 changed files with 17847 additions and 15439 deletions
+31 -12
View File
@@ -4,8 +4,9 @@ const tmp = require('tmp');
const { assert } = require('chai');
const Attachments = require('../../app/attachments');
const { stringToArrayBuffer } = require('../../js/modules/string_to_array_buffer');
const {
stringToArrayBuffer,
} = require('../../js/modules/string_to_array_buffer');
const PREFIX_LENGTH = 2;
const NUM_SEPARATORS = 1;
@@ -30,7 +31,9 @@ describe('Attachments', () => {
'Attachments_createWriterForNew'
);
const outputPath = await Attachments.createWriterForNew(tempDirectory)(input);
const outputPath = await Attachments.createWriterForNew(tempDirectory)(
input
);
const output = await fse.readFile(path.join(tempDirectory, outputPath));
assert.lengthOf(outputPath, PATH_LENGTH);
@@ -57,13 +60,16 @@ describe('Attachments', () => {
'Attachments_createWriterForExisting'
);
const relativePath = Attachments.getRelativePath(Attachments.createName());
const relativePath = Attachments.getRelativePath(
Attachments.createName()
);
const attachment = {
path: relativePath,
data: input,
};
const outputPath =
await Attachments.createWriterForExisting(tempDirectory)(attachment);
const outputPath = await Attachments.createWriterForExisting(
tempDirectory
)(attachment);
const output = await fse.readFile(path.join(tempDirectory, outputPath));
assert.equal(outputPath, relativePath);
@@ -84,16 +90,23 @@ describe('Attachments', () => {
});
it('should read file from disk', async () => {
const tempDirectory = path.join(tempRootDirectory, 'Attachments_createReader');
const tempDirectory = path.join(
tempRootDirectory,
'Attachments_createReader'
);
const relativePath = Attachments.getRelativePath(Attachments.createName());
const relativePath = Attachments.getRelativePath(
Attachments.createName()
);
const fullPath = path.join(tempDirectory, relativePath);
const input = stringToArrayBuffer('test string');
const inputBuffer = Buffer.from(input);
await fse.ensureFile(fullPath);
await fse.writeFile(fullPath, inputBuffer);
const output = await Attachments.createReader(tempDirectory)(relativePath);
const output = await Attachments.createReader(tempDirectory)(
relativePath
);
assert.deepEqual(input, output);
});
@@ -110,9 +123,14 @@ describe('Attachments', () => {
});
it('should delete file from disk', async () => {
const tempDirectory = path.join(tempRootDirectory, 'Attachments_createDeleter');
const tempDirectory = path.join(
tempRootDirectory,
'Attachments_createDeleter'
);
const relativePath = Attachments.getRelativePath(Attachments.createName());
const relativePath = Attachments.getRelativePath(
Attachments.createName()
);
const fullPath = path.join(tempDirectory, relativePath);
const input = stringToArrayBuffer('test string');
@@ -134,7 +152,8 @@ describe('Attachments', () => {
describe('getRelativePath', () => {
it('should return correct path', () => {
const name = '608ce3bc536edbf7637a6aeb6040bdfec49349140c0dd43e97c7ce263b15ff7e';
const name =
'608ce3bc536edbf7637a6aeb6040bdfec49349140c0dd43e97c7ce263b15ff7e';
assert.lengthOf(Attachments.getRelativePath(name), PATH_LENGTH);
});
});
+37 -25
View File
@@ -26,7 +26,7 @@ describe('app/logging', () => {
basePath = tmpDir.name;
});
afterEach((done) => {
afterEach(done => {
// we need the unsafe option to recursively remove the directory
tmpDir.removeCallback(done);
});
@@ -149,9 +149,11 @@ describe('app/logging', () => {
].join('\n');
const target = path.join(basePath, 'log.log');
const files = [{
path: target,
}];
const files = [
{
path: target,
},
];
fs.writeFileSync(target, contents);
@@ -172,9 +174,11 @@ describe('app/logging', () => {
].join('\n');
const target = path.join(basePath, 'log.log');
const files = [{
path: target,
}];
const files = [
{
path: target,
},
];
fs.writeFileSync(target, contents);
@@ -187,11 +191,16 @@ describe('app/logging', () => {
describe('#fetchLog', () => {
it('returns error if file does not exist', () => {
const target = 'random_file';
return fetchLog(target).then(() => {
throw new Error('Expected an error!');
}, (error) => {
expect(error).to.have.property('message').that.match(/random_file/);
});
return fetchLog(target).then(
() => {
throw new Error('Expected an error!');
},
error => {
expect(error)
.to.have.property('message')
.that.match(/random_file/);
}
);
});
it('returns empty array if file has no valid JSON lines', () => {
const contents = 'line 1\nline2\n';
@@ -200,7 +209,7 @@ describe('app/logging', () => {
fs.writeFileSync(target, contents);
return fetchLog(target).then((result) => {
return fetchLog(target).then(result => {
expect(result).to.deep.equal(expected);
});
});
@@ -222,21 +231,24 @@ describe('app/logging', () => {
}),
'',
].join('\n');
const expected = [{
level: 1,
time: 2,
msg: 3,
}, {
level: 2,
time: 3,
msg: 4,
}];
const expected = [
{
level: 1,
time: 2,
msg: 3,
},
{
level: 2,
time: 3,
msg: 4,
},
];
const target = path.join(basePath, 'test.log');
fs.writeFileSync(target, contents);
return fetchLog(target).then((result) => {
return fetchLog(target).then(result => {
expect(result).to.deep.equal(expected);
});
});
@@ -244,7 +256,7 @@ describe('app/logging', () => {
describe('#fetch', () => {
it('returns single entry if no files', () => {
return fetch(basePath).then((results) => {
return fetch(basePath).then(results => {
expect(results).to.have.length(1);
expect(results[0].msg).to.match(/Loaded this list/);
});
@@ -263,7 +275,7 @@ describe('app/logging', () => {
fs.writeFileSync(path.join(basePath, 'first.log'), first);
fs.writeFileSync(path.join(basePath, 'second.log'), second);
return fetch(basePath).then((results) => {
return fetch(basePath).then(results => {
expect(results).to.have.length(4);
expect(results[0].msg).to.equal(1);
expect(results[1].msg).to.equal(2);
+4 -3
View File
@@ -3,7 +3,6 @@ const { assert } = require('chai');
const SignalMenu = require('../../app/menu');
const { load: loadLocale } = require('../../app/locale');
const PLATFORMS = [
{
label: 'macOS',
@@ -37,7 +36,7 @@ describe('SignalMenu', () => {
describe('createTemplate', () => {
PLATFORMS.forEach(({ label, platform, fixtures }) => {
context(label, () => {
INCLUDE_SETUP_OPTIONS.forEach((includeSetup) => {
INCLUDE_SETUP_OPTIONS.forEach(includeSetup => {
const prefix = includeSetup ? 'with' : 'without';
context(`${prefix} setup options`, () => {
it('should return correct template', () => {
@@ -65,7 +64,9 @@ describe('SignalMenu', () => {
const { messages } = loadLocale({ appLocale, logger });
const actual = SignalMenu.createTemplate(options, messages);
const fixturePath = includeSetup ? fixtures.setup : fixtures.default;
const fixturePath = includeSetup
? fixtures.setup
: fixtures.default;
// eslint-disable-next-line global-require, import/no-dynamic-require
const fixture = require(fixturePath);
assert.deepEqual(actual, fixture);