These are chat archives for canjs/canjs

Feb 2015
Luis Merino
Feb 19 2015 10:17
Yeah, I understand what you're saying and I've written my tests accordingly, the problem is that the template in this case is <some-component> with ALL the other subcomponents inside, it's like the master HTML template. So when I append it to the fixture container a lot of unwanted initialization happens in all these subcomponents. I could just write a custom template for the test, but then my test's template and the real template I use for the app could diff at some point.
This is more of a philosophcal debate rather, I know how I can sort this out logically, but I wanted to know more about your take on this
Theoretically I have a few options:
  • Remove from the view subcomponent tags before I append them to the body (still dirty, still problematic if init: function is present in any subcomponent).
  • Stub component's prototype (if that's easy to do)
  • Use component's 'inserted' event to add another subcomponent (instead of using a template directly), which would allow me to stub the view's function avoiding this (given I precompile my templates in a JST object)
  • ...
Luis Merino
Feb 19 2015 10:28
I guess I'm writing templates in tests for these cases, that contain only the component I want to test, I don't see which other "elegant" way is there to accomplish it