From 3ef2b85159586135b9fb177282358e6d3feb103b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geir=20G=C3=A5sodden?= Date: Sat, 15 Dec 2018 23:39:13 +0100 Subject: [PATCH] standard --fix (patch) --- index.js | 2 +- lib/reduce-factors.js | 4 ++-- test/lib/custom-calculate-result-test.js | 2 +- test/lib/facet-test.js | 2 +- test/lib/score-10-item-middle-test.js | 4 ++-- test/lib/score-20-item-middle-test.js | 4 ++-- test/lib/score-50-test.js | 2 +- test/modules/input-test.js | 8 ++++---- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/index.js b/index.js index 5bfd279..c319ace 100644 --- a/index.js +++ b/index.js @@ -13,5 +13,5 @@ module.exports = data => { throw new Error('Wrong format. Data.answers must be an array') } - return reduceFactors({answers: data.answers, calculateResult: data.calculateResult}) + return reduceFactors({ answers: data.answers, calculateResult: data.calculateResult }) } diff --git a/lib/reduce-factors.js b/lib/reduce-factors.js index 9e0bed6..b3a8ab9 100644 --- a/lib/reduce-factors.js +++ b/lib/reduce-factors.js @@ -14,7 +14,7 @@ module.exports = options => { const reduceFactors = (a, b) => { if (!a[b.domain]) { - a[b.domain] = {score: 0, count: 0, result: 'neutral', facet: {}} + a[b.domain] = { score: 0, count: 0, result: 'neutral', facet: {} } } a[b.domain].score += parseInt(b.score || 0, 10) @@ -23,7 +23,7 @@ module.exports = options => { if (b.facet) { if (!a[b.domain].facet[b.facet]) { - a[b.domain].facet[b.facet] = {score: 0, count: 0, result: 'neutral'} + a[b.domain].facet[b.facet] = { score: 0, count: 0, result: 'neutral' } } a[b.domain].facet[b.facet].score += parseInt(b.score || 0, 10) a[b.domain].facet[b.facet].count += 1 diff --git a/test/lib/custom-calculate-result-test.js b/test/lib/custom-calculate-result-test.js index 1885a9c..e2c2470 100644 --- a/test/lib/custom-calculate-result-test.js +++ b/test/lib/custom-calculate-result-test.js @@ -15,7 +15,7 @@ const calculateResult = (score, count) => { return result } -const result = calculateScore({answers: answers, calculateResult: calculateResult}) +const result = calculateScore({ answers: answers, calculateResult: calculateResult }) test('validates results from custom calculateResult', t => { t.deepEqual(result, expectedResult, 'So deep, so equal') diff --git a/test/lib/facet-test.js b/test/lib/facet-test.js index 92dcd43..1cf4021 100644 --- a/test/lib/facet-test.js +++ b/test/lib/facet-test.js @@ -4,7 +4,7 @@ const test = require('ava') const calculateScore = require('../../index') const facetData = require('./data/facet-test-data.json') const facetExpected = require('./data/facet-test-result.json') -const facet = calculateScore({answers: facetData}) +const facet = calculateScore({ answers: facetData }) test('validates results', t => { t.deepEqual(facetExpected, facet, 'returns expected result') diff --git a/test/lib/score-10-item-middle-test.js b/test/lib/score-10-item-middle-test.js index 943b2a0..7df4911 100644 --- a/test/lib/score-10-item-middle-test.js +++ b/test/lib/score-10-item-middle-test.js @@ -3,10 +3,10 @@ const test = require('ava') const calculateScore = require('../../index') const answers = ['E', 'A', 'C', 'N', 'O'] - .map(letter => Array.from({length: 10}, (v, i) => i).map(num => Object.assign({domain: letter, score: 3}))) + .map(letter => Array.from({ length: 10 }, (v, i) => i).map(num => Object.assign({ domain: letter, score: 3 }))) .reduce((a, b) => a.concat(b), []) -const score = calculateScore({answers: answers}) +const score = calculateScore({ answers: answers }) test('validates results', t => { t.deepEqual(score['E'].score, 30, 'It calculates 30 for E') diff --git a/test/lib/score-20-item-middle-test.js b/test/lib/score-20-item-middle-test.js index 981f030..863d3d6 100644 --- a/test/lib/score-20-item-middle-test.js +++ b/test/lib/score-20-item-middle-test.js @@ -3,10 +3,10 @@ const test = require('ava') const calculateScore = require('../../index') const answers = ['E', 'A', 'C', 'N', 'O'] - .map(letter => Array.from({length: 20}, (v, i) => i).map(num => Object.assign({domain: letter, score: 3}))) + .map(letter => Array.from({ length: 20 }, (v, i) => i).map(num => Object.assign({ domain: letter, score: 3 }))) .reduce((a, b) => a.concat(b), []) -const score = calculateScore({answers: answers}) +const score = calculateScore({ answers: answers }) test('validates results', t => { t.deepEqual(score['E'].score, 60, 'It calculates 60 for E') diff --git a/test/lib/score-50-test.js b/test/lib/score-50-test.js index f638f52..57ea125 100644 --- a/test/lib/score-50-test.js +++ b/test/lib/score-50-test.js @@ -4,7 +4,7 @@ const test = require('ava') const calculateScore = require('../../index') const answers = require('./data/50-test-results.json') -const score = calculateScore({answers: answers}) +const score = calculateScore({ answers: answers }) test('validates results', t => { t.deepEqual(score['E'].score, 31, 'It calculates 31 for E') diff --git a/test/modules/input-test.js b/test/modules/input-test.js index 071723d..90d4329 100644 --- a/test/modules/input-test.js +++ b/test/modules/input-test.js @@ -12,19 +12,19 @@ test('throws if missing input', t => { t.is(error.message, expectedErrorMessage) }) -test('throws if not input.answers ', t => { +test('throws if not input.answers', t => { const expectedErrorMessage = 'Missing required input data.answers' const error = t.throws(() => { - calculateScore({answers: false}) + calculateScore({ answers: false }) }, Error) t.is(error.message, expectedErrorMessage) }) -test('throws if not input.answers ', t => { +test('throws if not input.answers is an array', t => { const expectedErrorMessage = 'Wrong format. Data.answers must be an array' const error = t.throws(() => { - calculateScore({answers: 'wrong'}) + calculateScore({ answers: 'wrong' }) }, Error) t.is(error.message, expectedErrorMessage)