jeudi 2 juillet 2015

Multiple expect declorations with the same expected output

I'm testing the function shopify.formatRequestUrl below and each time I'm expecting that the output of the function is going to be the same. Is there any way to make this more DRY?

expect(shopify.formatRequestUrl("shop"))
  .equal("https://"+settings.shop+"/admin/shop.json")

expect(shopify.formatRequestUrl("/shop"))
  .equal("https://"+settings.shop+"/admin/shop.json")

expect(shopify.formatRequestUrl("/shop/"))
  .equal("https://"+settings.shop+"/admin/shop.json")

expect(shopify.formatRequestUrl("shop.json"))
  .equal("https://"+settings.shop+"/admin/shop.json")

expect(shopify.formatRequestUrl("/admin/shop"))
  .equal("https://"+settings.shop+"/admin/shop.json")

expect(shopify.formatRequestUrl("/admin/shop.json"))
  .equal("https://"+settings.shop+"/admin/shop.json")

Something like this: psudo code

expectAll[
  shopify.formatRequestUrl("shop"),
  shopify.formatRequestUrl("/shop"),
  shopify.formatRequestUrl("/shop/"),
  shopify.formatRequestUrl("shop.json"),
  shopify.formatRequestUrl("/admin/shop"),
  shopify.formatRequestUrl("/admin/shop.json")
]
  .equal("https://"+settings.shop+"/admin/shop.json")

Aucun commentaire:

Enregistrer un commentaire