Skip to content

Commit

Permalink
Adds a nested array to the model attributes to raise an error
Browse files Browse the repository at this point in the history
  • Loading branch information
rdiazv committed Jun 30, 2017
1 parent 282286d commit ece3b14
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions __tests__/Model.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,18 @@ describe('Model', () => {
}

beforeEach(() => {
item = { id: 1, name: 'miles', album: 'kind of blue' }
item = {
id: 1,
name: 'miles',
album: 'kind of blue',
tracks: [
{ name: 'So What' },
{ name: 'Freddie Freeloader' },
{ name: 'Blue in Green' },
{ name: 'All Blues' },
{ name: 'Flamenco Sketches' }
]
}
collection = new MyCollection([item])
model = collection.at(0)
})
Expand Down Expand Up @@ -152,14 +163,17 @@ describe('Model', () => {

it('sends merged attributes on the request', () => {
const adapter = apiClient()
const attributes = { ...item }

delete attributes.id

spy = jest.spyOn(adapter, 'post')
model.save({ name })

expect(spy).toHaveBeenCalledTimes(1)
expect(spy.mock.calls[0][1]).toEqual({
name: 'dylan',
album: 'kind of blue'
...attributes,
name: 'dylan'
})
})
})
Expand All @@ -171,14 +185,17 @@ describe('Model', () => {

it('sends merged attributes on the request', () => {
const adapter = apiClient()
const attributes = { ...item }

delete attributes.id

spy = jest.spyOn(adapter, 'post')
model.save({ name })

expect(spy).toHaveBeenCalledTimes(1)
expect(spy.mock.calls[0][1]).toEqual({
name: 'dylan',
album: 'kind of blue'
...attributes,
name: 'dylan'
})
})

Expand Down

0 comments on commit ece3b14

Please sign in to comment.