🎨 add tests & refactor

- add test for getting all tags
- add test for transforming resources
- output.json -> mockOutput.json
This commit is contained in:
Kevin Van Der Werff
2019-10-22 15:28:11 +02:00
committed by Unknown
parent 330612ea4c
commit 8273955316
4 changed files with 29 additions and 14 deletions

View File

@@ -1,7 +1,7 @@
/*eslint-disable */
import * as R from 'ramda'
/// Types
/// TYPES ///
// const Category = {
// title: String,
// slug: String,
@@ -17,7 +17,7 @@ import * as R from 'ramda'
// tags: [String],
// }
/// Functions
/// FUNCTIONS ///
// isNotEmpty [a] -> Bool
export const isNotEmpty = R.compose(R.not, R.isEmpty)
@@ -54,11 +54,19 @@ export const partiallyIncludesElOf = R.curry((list1, list2) =>
)
// addCleanTitleAndPath :: Object -> Resource
export const addCleanTitleAndPath = R.curry((slug, obj) => {
const addCleanTitleAndPath = R.curry((slug, obj) => {
const cleanTitle = cleanStringAndRemoveSpaces(obj.title)
return {
...obj,
cleanTitle,
path: `${slug}?card=${cleanTitle}`,
}
})
})
// transformToResources :: [Object] -> [Resource]
export const transformToResources = categories => {
const resourcesLens = R.lens(R.prop('resources'), R.assoc('resources'))
return R.map(category =>
R.over(resourcesLens, R.map(addCleanTitleAndPath(category.slug)), category),
categories)
}