hashicorp / structure

Structure (aka "PDS") [deprecated]
https://hashicorp-structure.vercel.app
Mozilla Public License 2.0
24 stars 5 forks source link

change config to always be an array and test out filterComponents method #4

Closed johncowen closed 4 years ago

johncowen commented 4 years ago

This PR mainly tests out the filterComponents method. In order to do this easier I made the filterComponents method accept a Funnel-like class as a third method, which if not passed it defaults to the real Funnel class. (I'm not sure if the node version we are targeting here supports default args but we can swap that out if not)

Secondly I've included some tests to understand/prove what filterComponents does, pretty much which regular expression it will use depending on what you pass to it. The most important thing I found from doing this was that having an config.include prop as ['components/st-single-component'] would use the default (/components\/) regular expression (see lines 89-92 of index-test.js)

Lastly I tested that when I pass config.include prop as ['components/st-single-component'] to the exclusionFn method when using the default regular expression that it doesn't exclude it - i.e. the exclusionFn method returns false (see lines 184 - 187 of index-test.js) - I would like this component to be included but no others. I've commented these lines out for the moment as they don't pass.

I'm honestly not sure if I'm testing this right or what is expected here, so I thought I'd PR it anyway and we can catch up whenever see if I've done this completely wrong and we can close this PR or we need to tweak the behaviour.

meirish commented 4 years ago

@johncowen based on what we talked about, I updated the logic so that:

and updated the tests to match this. How's that all look to you?

johncowen commented 4 years ago

Hey Matthew!

Yeah I defo prefer the 'it's always an array thing'. So yeah this looks good to me, so I'd say merge it as is. I think either of us can merge yeah? So feel free to merge in.

meirish commented 4 years ago

@johncowen awesome, thanks for bringing this up and adding those tests! And agreed re: always being an array and giving users more feedback (if they're looking at their server output 😬).