vendredi 6 juillet 2018

error: products is array. Testing angular

I want to testing a function post in API.

I have this class:

export class Sales {
    total: number;
    client_id: number;
    desc: string;
    products: Products[];
}
export class Products {
    p_id: number;
    p_price: number
    p_prod: number
    total: number;
 }

For testing I used this code:

     it('Sales',.......... );
                    let newS = new Sale('11')
                    newS.total = 100;
                    newS.client_id = 3;
                    newS.desc = 'sdsdsdsaeds';
                    newS.products = [{ "p_id": "12", "p_price": "100", "p_prod": 1, "total":603}]             
            .............
                })))

Any idea how to write: newS.products = [{ "p_id": "12", "p_price": "100", "p_prod": 1, "total":603}] this is incorrect because products is Array

Aucun commentaire:

Enregistrer un commentaire