feat(core): Added Pattern.getLogs() and updated Pattern.getRenderProps()
The data returned by `Pattern.getRenderProps()` was not serializable as we were returning `this` all over the place, thereby including marcors, log methods, cyclic object references, and so on. This commit changes that by implementing a `.asRenderProp()` method on all of the various objects (stack, part, path, point, snippet, attributes, svg) and only including data that can be serialized. In addition, we no longer include the logs in the renderProps because they are not related to rendering the pattern. Instead, the new method `Pattern.getLogs()` gives you the logs.
This commit is contained in:
parent
fa437b9b16
commit
a2800dddda
11 changed files with 119 additions and 51 deletions
|
@ -15,24 +15,15 @@ describe('Pattern Rendering', () => {
|
|||
}
|
||||
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design({})
|
||||
const props = pattern.draft().getRenderProps()
|
||||
const pattern = new design({}).draft()
|
||||
const props = pattern.getRenderProps()
|
||||
const logs = pattern.getLogs()
|
||||
|
||||
it('Should not include hidden parts', () => {
|
||||
expect(props.parts[0]).not.to.have.property('test')
|
||||
})
|
||||
it('Should log that it has skipped a hidden part', () => {
|
||||
expect(props.logs.sets[0].info).to.include(
|
||||
'Part test is hidden in set 0. Not adding to render props'
|
||||
)
|
||||
})
|
||||
it('Should not include hidden stacks', () => {
|
||||
expect(props.stacks).not.to.have.property('test')
|
||||
})
|
||||
it('Should log that it has skipped a hidden stack', () => {
|
||||
expect(props.logs.pattern.info).to.include(
|
||||
'Stack test is hidden. Skipping in render props.'
|
||||
)
|
||||
expect(logs.pattern.info).to.include('Stack test is hidden. Skipping in render props.')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue