Skip to content
This repository has been archived by the owner on Dec 16, 2018. It is now read-only.

Commit

Permalink
standard --fix (patch)
Browse files Browse the repository at this point in the history
  • Loading branch information
zrrrzzt committed Dec 15, 2018
1 parent 5c319af commit 3ef2b85
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -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 })
}
4 changes: 2 additions & 2 deletions lib/reduce-factors.js
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/lib/custom-calculate-result-test.js
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion test/lib/facet-test.js
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions test/lib/score-10-item-middle-test.js
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions test/lib/score-20-item-middle-test.js
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion test/lib/score-50-test.js
Expand Up @@ -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')
Expand Down
8 changes: 4 additions & 4 deletions test/modules/input-test.js
Expand Up @@ -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)
Expand Down

0 comments on commit 3ef2b85

Please sign in to comment.