I'm having some trouble writing the test for my serializer. I don't know how to create the 'record' or the 'snapshot' in order to execute "serializer.serialize(trade._createSnapshot())". This is how far I went. Help! :)
import {expect} from 'chai';
import {describeModule, it} from 'ember-mocha';
import {describe} from 'mocha';
import DS from 'ember-data';
import startApp from 'appG/tests/helpers/start-app';
describeModule(
'serializer:trade',
'Unit | Serializer | trade ',
{
needs: ['model:trade', 'model:offer']
},
function() {
describe('#serialize', function(){
let offer = this.store.createRecord('offer', {
condition: 'good',
expiresAt: new Date('4/13/16'),
});
let trade = this.store.createRecord('trade', {
firstName: "Cats",
lastName: "Meow",
streetName1: "123 street",
streetName2: "apt 503",
city: "boston",
state: "ma",
zipcode: "02210",
telephone: "1231231234",
email: "meow@cats.com",
offer: offer
});
it ('turns the data to what the api needs', function() {
let serializer = this.subject();
let serializeJson = serializer.serialize(trade._createSnapshot());
expect(serializeJson).to.eql(
{
"cart": [
{
"product_id": "1",
"condition": "good"
}
],
"payment_information": {
"first_name": "Cats",
"last_name": "Meow",
"street_name1": "123 street",
"street_name2": "apt 503",
"city": "Chicago",
"state": "ma",
"zipcode": "02210",
"telephone": '9999999'
},
"shipping_information": {
"first_name": "Cats",
"last_name": "Meow",
"street_name1": "123 street",
"street_name2": "apt 101",
"city": "Chicago",
"state": "ma",
"zipcode": "02210"
},
"email": "meow@cats.com",
})
})
})
}
)
Aucun commentaire:
Enregistrer un commentaire