Codacy style changes (minor)

This commit is contained in:
Angelos Chalaris
2018-08-02 14:10:16 +03:00
parent ca90646923
commit 5c38423805
21 changed files with 88 additions and 91 deletions

View File

@ -6,5 +6,5 @@ test('cleanObj is a Function', () => {
});
const testObj = { a: 1, b: 2, children: { a: 1, b: 2 } };
test('Removes any properties except the ones specified from a JSON object', () => {
expect(cleanObj(testObj, ['a'], 'children')).toEqual({ a: 1, children : { a: 1}});
expect(cleanObj(testObj, ['a'], 'children')).toEqual({ a: 1, children: { a: 1}});
});

View File

@ -12,8 +12,8 @@ test('When n is odd, times by 3 and add 1', () => {
});
test('Eventually reaches 1', () => {
let n = 9;
while(true){
if (n === 1){
while(true) {
if (n === 1) {
expect(n).toBe(1);
break;
}

View File

@ -9,5 +9,5 @@ let p1 = Promise.resolve(1);
let p2 = Promise.resolve(2);
let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
test('Works with multiple promises', () => {
Pall(p1, p2, p3).then(function(val){ expect(val).toBe([1,2,3]);}, function(reason){});
Pall(p1, p2, p3).then(function(val) { expect(val).toBe([1, 2, 3]);}, function(reason){});
});

View File

@ -2,11 +2,11 @@ const expect = require("expect");
const dig = require("./dig.js");
const data = {
level1:{
level2:{
level1: {
level2: {
level3: "some data",
level3f: false,
level3a: [1,2,3,4]
level3a: [1, 2, 3, 4]
}
}
};

View File

@ -3,4 +3,4 @@ const elementContains = require('./elementContains.js');
test('elementContains is a Function', () => {
expect(elementContains).toBeInstanceOf(Function);
});
});

View File

@ -3,4 +3,4 @@ const insertAfter = require('./insertAfter.js');
test('insertAfter is a Function', () => {
expect(insertAfter).toBeInstanceOf(Function);
});
});

View File

@ -3,4 +3,4 @@ const insertBefore = require('./insertBefore.js');
test('insertBefore is a Function', () => {
expect(insertBefore).toBeInstanceOf(Function);
});
});

View File

@ -11,7 +11,7 @@ test('isObject([]) is a object', () => {
expect(isObject([])).toBeTruthy();
});
test('isObject({ a:1 }) is a object', () => {
expect(isObject({ a:1 })).toBeTruthy();
expect(isObject({ a: 1 })).toBeTruthy();
});
test('isObject(true) is not a object', () => {
expect(isObject(true)).toBeFalsy();

View File

@ -1,11 +1,11 @@
const levenshteinDistance = (string1, string2) => {
const levenshteinDistance = (string1, string2) => {
if(string1.length === 0) return string2.length;
if(string2.length === 0) return string1.length;
let matrix = Array(string2.length + 1).fill(0).map((x,i) => [i]);
matrix[0] = Array(string1.length + 1).fill(0).map((x,i) => i);
for(let i = 1; i <= string2.length; i++){
for(let j = 1; j<=string1.length; j++){
if(string2[i-1] === string1[j-1]){
let matrix = Array(string2.length + 1).fill(0).map((x, i) => [i]);
matrix[0] = Array(string1.length + 1).fill(0).map((x, i) => i);
for(let i = 1; i <= string2.length; i++) {
for(let j = 1; j<=string1.length; j++) {
if(string2[i-1] === string1[j-1]) {
matrix[i][j] = matrix[i-1][j-1];
}
else{

View File

@ -3,4 +3,4 @@ const nodeListToArray = require('./nodeListToArray.js');
test('nodeListToArray is a Function', () => {
expect(nodeListToArray).toBeInstanceOf(Function);
});
});

View File

@ -6,5 +6,5 @@ test('partition is a Function', () => {
});
const users = [{ user: 'barney', age: 36, active: false }, { user: 'fred', age: 40, active: true }];
test('Groups the elements into two arrays, depending on the provided function\'s truthiness for each element.', () => {
expect(partition(users, o => o.active)).toEqual([[{ 'user': 'fred', 'age': 40, 'active': true }],[{ 'user': 'barney', 'age': 36, 'active': false }]]);
expect(partition(users, o => o.active)).toEqual([[{ 'user': 'fred', 'age': 40, 'active': true }],[{ 'user': 'barney', 'age': 36, 'active': false }]]);
});

View File

@ -9,7 +9,7 @@ test('pipeAsyncFunctions result should be 15', () => {
(x) => x + 1,
(x) => new Promise((resolve) => setTimeout(() => resolve(x + 2), 0)),
(x) => x + 3,
async (x) => await x + 4,
async(x) => await x + 4,
)
(5)).resolves.toBe(15);
});

View File

@ -3,4 +3,4 @@ const triggerEvent = require('./triggerEvent.js');
test('triggerEvent is a Function', () => {
expect(triggerEvent).toBeInstanceOf(Function);
});
});