From e7efd28706e7a958b7645758ff79c3f3fd4cb31f Mon Sep 17 00:00:00 2001 From: Ianis Date: Wed, 1 May 2019 19:55:16 +0200 Subject: [PATCH] Run through prettier --- exercises/easy/01_map.test.js | 5 ++--- exercises/easy/02_filter.test.js | 5 ++--- exercises/easy/03_uniq.test.js | 5 ++--- exercises/extra-hard/10_curry.test.js | 17 +++++++-------- exercises/extra-hard/11_debounce.test.js | 24 ++++++++++----------- exercises/hard/07_sample.test.js | 16 +++++++------- exercises/hard/08_safeGet.test.js | 9 +++----- exercises/hard/09_memoize.test.js | 18 ++++++++-------- exercises/medium/04_flatten.test.js | 9 +++----- exercises/medium/05_reduce.test.js | 5 ++--- exercises/medium/06_break.test.js | 27 ++++++++++++------------ 11 files changed, 65 insertions(+), 75 deletions(-) diff --git a/exercises/easy/01_map.test.js b/exercises/easy/01_map.test.js index 5369d69..2d7ec33 100644 --- a/exercises/easy/01_map.test.js +++ b/exercises/easy/01_map.test.js @@ -10,11 +10,10 @@ */ function map(arr, fn) { - // TODO - IMPLEMENT ME + // TODO - IMPLEMENT ME } /* =========== DON'T CHANGE THE CODE AFTER THIS LINE =============== */ test('maps an array', () => - expect(map([1, 2, 3], x => x ** 2)).toEqual([1, 4, 9]) -) \ No newline at end of file + expect(map([1, 2, 3], x => x ** 2)).toEqual([1, 4, 9])) diff --git a/exercises/easy/02_filter.test.js b/exercises/easy/02_filter.test.js index f7fc263..a5a4e65 100644 --- a/exercises/easy/02_filter.test.js +++ b/exercises/easy/02_filter.test.js @@ -8,11 +8,10 @@ */ function filter(arr, fn) { - // TODO - IMPLEMENT ME + // TODO - IMPLEMENT ME } /* =========== DON'T CHANGE THE CODE AFTER THIS LINE =============== */ test('maps an array', () => - expect(filter([-1, 0, 1, 2, 3], x => x > 0)).toEqual([1, 2, 3]) -) \ No newline at end of file + expect(filter([-1, 0, 1, 2, 3], x => x > 0)).toEqual([1, 2, 3])) diff --git a/exercises/easy/03_uniq.test.js b/exercises/easy/03_uniq.test.js index 23824d8..d27fd24 100644 --- a/exercises/easy/03_uniq.test.js +++ b/exercises/easy/03_uniq.test.js @@ -6,11 +6,10 @@ */ function uniq(arr) { - // TODO - IMPLEMENT ME + // TODO - IMPLEMENT ME } /* =========== DON'T CHANGE THE CODE AFTER THIS LINE =============== */ test('removes duplicates from an array', () => - expect(uniq([1, 1, 2, 3, 3, 1])).toEqual([1, 2, 3]) -) \ No newline at end of file + expect(uniq([1, 1, 2, 3, 3, 1])).toEqual([1, 2, 3])) diff --git a/exercises/extra-hard/10_curry.test.js b/exercises/extra-hard/10_curry.test.js index eee9212..c84a373 100644 --- a/exercises/extra-hard/10_curry.test.js +++ b/exercises/extra-hard/10_curry.test.js @@ -7,19 +7,18 @@ */ function curry(fn, arity) { - // TODO - IMPLEMENT ME + // TODO - IMPLEMENT ME } /* =========== DON'T CHANGE THE CODE AFTER THIS LINE =============== */ test('curries a function', () => - expect(curry((x, y) => x + y)(5)(10)).toEqual(15) -) + expect(curry((x, y) => x + y)(5)(10)).toEqual(15)) test('curries a function of many arguments', () => { - const sum = curry((a, b, c) => a + b + c) - expect(sum(1, 2, 3)).toEqual(6) - expect(sum(1)(2, 3)).toEqual(6) - expect(sum(1, 2)(3)).toEqual(6) - expect(sum(1)(2)(3)).toEqual(6) -}) \ No newline at end of file + const sum = curry((a, b, c) => a + b + c) + expect(sum(1, 2, 3)).toEqual(6) + expect(sum(1)(2, 3)).toEqual(6) + expect(sum(1, 2)(3)).toEqual(6) + expect(sum(1)(2)(3)).toEqual(6) +}) diff --git a/exercises/extra-hard/11_debounce.test.js b/exercises/extra-hard/11_debounce.test.js index 35ab578..7d918c6 100644 --- a/exercises/extra-hard/11_debounce.test.js +++ b/exercises/extra-hard/11_debounce.test.js @@ -7,20 +7,20 @@ */ function debounce(func, wait, immediate) { - // TODO - IMPLEMENT ME + // TODO - IMPLEMENT ME } /* =========== DON'T CHANGE THE CODE AFTER THIS LINE =============== */ test('debounce', done => { - const costlyFn = jest.fn() - const fn = debounce(costlyFn, 100) - fn() - fn() - fn() - expect(costlyFn).toHaveBeenCalledTimes(0) - setTimeout(() => { - expect(costlyFn).toHaveBeenCalledTimes(1) - done() - }, 200) -}) \ No newline at end of file + const costlyFn = jest.fn() + const fn = debounce(costlyFn, 100) + fn() + fn() + fn() + expect(costlyFn).toHaveBeenCalledTimes(0) + setTimeout(() => { + expect(costlyFn).toHaveBeenCalledTimes(1) + done() + }, 200) +}) diff --git a/exercises/hard/07_sample.test.js b/exercises/hard/07_sample.test.js index 4ceac9b..9e43c6f 100644 --- a/exercises/hard/07_sample.test.js +++ b/exercises/hard/07_sample.test.js @@ -6,16 +6,16 @@ */ function sample(arr, n) { - // TODO - IMPLEMENT ME + // TODO - IMPLEMENT ME } /* =========== DON'T CHANGE THE CODE AFTER THIS LINE =============== */ test('returns a sample from an array', () => { - const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] - for (i = 0; i < 10; i++) { - const out = sample(numbers, 3) - expect(out.length).toEqual(3) - expect(out.every(x => x >= 1 && x <= 9)).toEqual(true) - } -}) \ No newline at end of file + const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] + for (i = 0; i < 10; i++) { + const out = sample(numbers, 3) + expect(out.length).toEqual(3) + expect(out.every(x => x >= 1 && x <= 9)).toEqual(true) + } +}) diff --git a/exercises/hard/08_safeGet.test.js b/exercises/hard/08_safeGet.test.js index cdb0af9..97d3f40 100644 --- a/exercises/hard/08_safeGet.test.js +++ b/exercises/hard/08_safeGet.test.js @@ -7,17 +7,14 @@ */ function safeGet(obj, path) { - // TODO - IMPLEMENT ME + // TODO - IMPLEMENT ME } /* =========== DON'T CHANGE THE CODE AFTER THIS LINE =============== */ const obj = { a: { b: { c: 42 } } } -test('gets a value by path', () => - expect(safeGet(obj, 'a.b.c')).toEqual(42) -) +test('gets a value by path', () => expect(safeGet(obj, 'a.b.c')).toEqual(42)) test('returns null for non-existing values', () => - expect(safeGet(obj, 'a.b.c.d')).toEqual(null) -) \ No newline at end of file + expect(safeGet(obj, 'a.b.c.d')).toEqual(null)) diff --git a/exercises/hard/09_memoize.test.js b/exercises/hard/09_memoize.test.js index cc91e42..5d6b003 100644 --- a/exercises/hard/09_memoize.test.js +++ b/exercises/hard/09_memoize.test.js @@ -7,17 +7,17 @@ */ function memoize(fn) { - // TODO - IMPLEMENT ME + // TODO - IMPLEMENT ME } /* =========== DON'T CHANGE THE CODE AFTER THIS LINE =============== */ test('caches the value of a function', () => { - const costlyFn = jest.fn() - const fn = memoize(costlyFn) - fn(1) - fn(1) - fn(2) - fn(1) - expect(costlyFn).toHaveBeenCalledTimes(2) -}) \ No newline at end of file + const costlyFn = jest.fn() + const fn = memoize(costlyFn) + fn(1) + fn(1) + fn(2) + fn(1) + expect(costlyFn).toHaveBeenCalledTimes(2) +}) diff --git a/exercises/medium/04_flatten.test.js b/exercises/medium/04_flatten.test.js index da31c54..ef4cf45 100644 --- a/exercises/medium/04_flatten.test.js +++ b/exercises/medium/04_flatten.test.js @@ -5,15 +5,12 @@ */ function flatten(arr) { - // TODO - IMPLEMENT ME + // TODO - IMPLEMENT ME } /* =========== DON'T CHANGE THE CODE AFTER THIS LINE =============== */ -test('flattens an array', () => - expect(flatten([[1, 2], 3])).toEqual([1, 2, 3]) -) +test('flattens an array', () => expect(flatten([[1, 2], 3])).toEqual([1, 2, 3])) test('deeply flattens an array', () => - expect(flatten([[1], 2, [[3], 4]])).toEqual([1, 2, 3, 4]) -) \ No newline at end of file + expect(flatten([[1], 2, [[3], 4]])).toEqual([1, 2, 3, 4])) diff --git a/exercises/medium/05_reduce.test.js b/exercises/medium/05_reduce.test.js index 8107cae..c15530c 100644 --- a/exercises/medium/05_reduce.test.js +++ b/exercises/medium/05_reduce.test.js @@ -7,11 +7,10 @@ */ function reduce(arr, fn, initial) { - // TODO - IMPLEMENT ME + // TODO - IMPLEMENT ME } /* =========== DON'T CHANGE THE CODE AFTER THIS LINE =============== */ test('reduces an array', () => - expect(reduce([1, 2, 3, 4, 5], (a, b) => a + b, 0)).toEqual(15) -) \ No newline at end of file + expect(reduce([1, 2, 3, 4, 5], (a, b) => a + b, 0)).toEqual(15)) diff --git a/exercises/medium/06_break.test.js b/exercises/medium/06_break.test.js index a26bc44..0b08c3c 100644 --- a/exercises/medium/06_break.test.js +++ b/exercises/medium/06_break.test.js @@ -6,21 +6,22 @@ */ function convert(arr) { - // TODO - IMPLEMENT ME + // TODO - IMPLEMENT ME } /* =========== DON'T CHANGE THE CODE AFTER THIS LINE =============== */ test('reduces an array', () => - expect(convert([ - { name: 'John', hobbies: ['singing', 'walking', 'playing guitar'] }, - { name: 'Terry', hobbies: ['swimming', 'playing guitar'] }, - { name: 'Anna', hobbies: ['walking', 'swimming', 'playing guitar'] }, - { name: 'Paul', hobbies: ['swimming', 'singing'] } - ])).toEqual([ - { hobby: 'singing', users: ['John', 'Paul'] }, - { hobby: 'walking', users: ['John', 'Anna'] }, - { hobby: 'playing guitar', users: ['John', 'Terry', 'Anna'] }, - { hobby: 'swimming', users: ['Terry', 'Anna', 'Paul'] } - ]) -) \ No newline at end of file + expect( + convert([ + { name: 'John', hobbies: ['singing', 'walking', 'playing guitar'] }, + { name: 'Terry', hobbies: ['swimming', 'playing guitar'] }, + { name: 'Anna', hobbies: ['walking', 'swimming', 'playing guitar'] }, + { name: 'Paul', hobbies: ['swimming', 'singing'] }, + ]), + ).toEqual([ + { hobby: 'singing', users: ['John', 'Paul'] }, + { hobby: 'walking', users: ['John', 'Anna'] }, + { hobby: 'playing guitar', users: ['John', 'Terry', 'Anna'] }, + { hobby: 'swimming', users: ['Terry', 'Anna', 'Paul'] }, + ]))