daniellmb / angular-test-patterns

A High-Quality Guide for Testing Angular 1.x
MIT License
867 stars 100 forks source link

Unit test a Controller: add a test for "controller as" use case #7

Closed yanivefraim closed 9 years ago

yanivefraim commented 9 years ago

As "controller as" becomes more and more popular, I think this should be a mandatory pattern (I am willing to add a PR for it)

daniellmb commented 9 years ago

I'd love to see another contributor to this project. I always intended that this would be a community effort.

yanivefraim commented 9 years ago

Awesome. I'll try to free-up some time and join the effort... Seems like a great idea!

daniellmb commented 9 years ago

Yeah, that's my dilemma lots of great ideas and no time :)

yanivefraim commented 9 years ago

I started working on the controller as implementation. How do you thing it will be best to ad this: As a new pattern under patterns/controller.md? as a new file, something like patterns/controlelrAs.ms? I tried adding it as a new pattern under controller.md, but I keep getting a strange error: Found 32 but expected 36 blocks. Not sure what is this - any idea?

daniellmb commented 9 years ago

Yeah, I think a new file controllerAs.md would be best since the controller is going to have things on this instead of $scope the unit tests won't look the same. As for the block count issue, unfortunatly the formatting of the md file has to follow a convention so it can be parsed into sections. That check is there to let you know it wasn't able to parse the file as expected. Check out anatomy of a test pattern section for an example of a valid section. You may also want to review the section on contributing new patterns.

daniellmb commented 9 years ago

merged! :)