Skip to content

Instantly share code, notes, and snippets.

@davidharting
Created April 14, 2017 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidharting/7efcf1b30fe7316c16157534d9d1e574 to your computer and use it in GitHub Desktop.
Save davidharting/7efcf1b30fe7316c16157534d9d1e574 to your computer and use it in GitHub Desktop.
Trouble with yayson presenter
describe('weird that this fails', () => {
const yayson = require.requireActual('yayson')
it.only('should be able to render multiple times', () => {
const jsonApi = yayson({ adapter: 'default' })
const presenter = new jsonApi.Presenter()
presenter.type = 'people'
console.log(presenter)
/*
* Presenter { scope: {}, type: 'people' }
*/
presenter.render({ firstName: 'david', lastName: 'harting' })
console.log(presenter)
/*
* Presenter {
* scope: { data: { type: 'people', attributes: [Object] } },
* type: 'people' }
*/
presenter.render({ firstName: 'blake', lastName: 'hair' })
/*
* Error thrown:
* TypeError: this.scope.data.push is not a function
*/
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment