Created
July 6, 2018 13:08
-
-
Save lupomontero/5eff8bb2572fed7dd82a7364e8afef47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { uniq, pluck, extractCampus } = require('./'); | |
describe('uniq', () => { | |
it('debería retornar un nuevo array sin elementos repetidos', () => { | |
expect(uniq(['a', 'a', 'z', 'a', true, 0])).toEqual(['a', 'z', true, 0]); | |
expect(uniq([1, 1, 1])).toEqual([1]); | |
}); | |
}); | |
describe('pluck', () => { | |
it('debería crear un nuevo arreglo con los valores de la propiedad especificada de cada objeto', () => { | |
expect(pluck([ | |
{ name: 'lulu' }, | |
{ name: 'amalia' }, | |
{ name: 'steph' }, | |
], 'name')).toEqual(['lulu', 'amalia', 'steph']); | |
}); | |
}); | |
describe('extractCampus', () => { | |
it('debería extraer la parte del campus de la propiedad `id` de cada cohort', () => { | |
expect(extractCampus(pluck([ | |
{ id: 'lim-2018-05-bc-js-am' }, | |
{ id: 'lim-2018-05-bc-js-pm' }, | |
{ id: 'cdmx-2018-05-bc-js-am' }, | |
], 'id'))).toEqual(['lim', 'lim', 'cdmx']); | |
}); | |
it('debería poder combinarse con `uniq`', () = { | |
expect(uniq(extractCampus(pluck([ | |
{ id: 'lim-2018-05-bc-js-am' }, | |
{ id: 'lim-2018-05-bc-js-pm' }, | |
{ id: 'cdmx-2018-05-bc-js-am' }, | |
], 'id')))).toEqual(['lim', 'cdmx']); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment