Advertisement
Guest User

Untitled

a guest
May 19th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const forms = {
  2.   travel: TravelForms,
  3.   realty: RealtyForms,
  4.   life: LifeForms
  5. }
  6.  
  7. const insurers = [Insurer1, Insurer2, Insurer3, Insurer4, Insurer5, Insurer6, Insurer7];
  8.  
  9. Object.keys(forms).map((key) => {
  10.   let insurersForType = insurers.reduce((acc, Insurer) => {
  11.     if (Insurer.acceptableTypes.includes(key)) {
  12.       acc.push(Insurer);
  13.     }
  14.     return acc;
  15.   }, []);
  16.   let insurersWithForm = [];
  17.   forms[key].map((form) => {
  18.     insurersForType.map((Insurer) => {
  19.       insurersWithForm.push(new Insurer(form.payload))
  20.     })
  21.   })
  22.  
  23.   describe(`${key}`, () => {
  24.     insurersWithForm.map((insurer) => {
  25.       it(`${insurer.constructor.name} cost should be above 0`, () => {
  26.         return insurer.request(`${key}`)
  27.           .then(res => (res.system.cost.value).should.be.above(0))
  28.           .catch(err => {
  29.             console.log('ERROR', err);
  30.             true.should.be.false })
  31.       })
  32.     })
  33.   })
  34. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement