https://github.com/normandy72/testing-components
Testing AngularJS Components. Coursera course "Single Page Web Applications with AngularJS" by Yaakov Chaikin.
https://github.com/normandy72/testing-components
angular angularjs html html5 jasmine jasmine-tests javascript js testing
Last synced: about 1 month ago
JSON representation
Testing AngularJS Components. Coursera course "Single Page Web Applications with AngularJS" by Yaakov Chaikin.
- Host: GitHub
- URL: https://github.com/normandy72/testing-components
- Owner: Normandy72
- Created: 2023-01-27T12:23:35.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-01-27T12:42:53.000Z (over 2 years ago)
- Last Synced: 2025-02-11T09:42:18.853Z (3 months ago)
- Topics: angular, angularjs, html, html5, jasmine, jasmine-tests, javascript, js, testing
- Language: JavaScript
- Homepage:
- Size: 155 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Testing AngularJS Components
### beforeEach Setup
```
var $componentController;beforeEach(module('MyApp'));
beforeEach(inject(function(_$componentController_){
$componentController = _$componentController_;
}));
```
### Test Method
```
it('should update value', function(){
var bindings = {
prop1: {val: 'some val'}
};var ctrl = $componentController('myComp', {}, bindings);
var updatedVal1 = ctrl.val;
expect(updatedVal).toEqual('some val');
});
```
***
#### _Summary_
Use the following steps to test a component:
* In beforeEach:
* use mock inject function to inject `$componentController` service.
* In the test method:
* set up a bindings object with expected props (if any);
* set up objects controller expects to be injected (if any);
* create controller with `$componentController('componentName', injections, bindings)`.
***