[AngularJS + Unit Testing] Testing a component with requiring ngModel
The component test:
describe('The component test', () => {
let component, $componentController, $controller, $injector, $scope; beforeEach(module("componennts.module"));
beforeEach(inject((_$componentController_, _$controller_, _$injector_, _$rootScope_) => {
$componentController = _$componentController_;
$controller = _$controller_;
$injector = _$injector_;
$scope = _$rootScope_.$new();
})); describe('Controller', () => {
it('should have ng-model with the correct binding', () => {
let locals = {
$scope: $scope,
$element: angular.element('<my-component ng-model="value"></my-component>'),
$attrs: { ngModel: 'value' }
};
locals.$scope.value = [];
let ngModelController = $injector.get('ngModelDirective')[].controller;
let ngModelInstance = $controller(ngModelController, locals);
$scope.$digest();
component = $componentController('myComponent', null, { ngModel: ngModelInstance });
component.$onInit();
expect(component).toBeDefined();
expect(component._selectedValues).toEqual([]); // _selectedValues = ngModel.$viewValue
});
});
});
[AngularJS + Unit Testing] Testing a component with requiring ngModel的更多相关文章
- [AngularJS Unit tesint] Testing keyboard event
HTML: <div ng-focus="vm.onFocus(month)", aria-focus="{{vm.focus == month}}", ...
- [Unit Testing] AngularJS Unit Testing - Karma
Install Karam: npm install -g karma npm install -g karma-cli Init Karam: karma init First test: 1. A ...
- [Angular & Unit Testing] Testing a RouterOutlet component
The way to test router componet needs a little bit setup, first we need to create a "router-stu ...
- [Angular & Unit Testing] Testing Component with Store
When using Ngrx, we need to know how to test the component which has Router injected. Component: imp ...
- [Angular Unit Testing] Testing Component methods
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {BrowserDynamicTestingModule ...
- [Angular + Unit] AngularJS Unit testing using Karma
http://social.technet.microsoft.com/wiki/contents/articles/32300.angularjs-unit-testing-using-karma- ...
- [Unit Testing] Angular Test component with required
export default (ngModule) => { describe('Table Item component', () => { let $compile, directiv ...
- [AngularJS + Unit Testing] Testing Directive's controller with bindToController, controllerAs and isolate scope
<div> <h2>{{vm.userInfo.number}} - {{vm.userInfo.name}}</h2> </div> 'use str ...
- Run Unit API Testing Which Was Distributed To Multiple Test Agents
Recently I am blocked by a very weird issue, from the VS installed machine, I can run performance te ...
随机推荐
- 组队赛Day1第一场 GYM 101350 G - Snake Rana (容斥)
[题意] 给一个N×M的矩阵, K个地雷的坐标.求不含地雷的所有矩形的总数. T组数据. N M都是1e4,地雷数 K ≤ 20 Input 3 2 2 1 2 2 6 6 2 5 2 2 5 100 ...
- “程序设计与算法训练”课程设计:“BP神经网络的实现”(C++类封装实现)
一 题目: 71 BP神经网络的实现: 利用C++语言实现BP神经网络, 并利用BP神经网络解决螨虫分类问题: 蠓虫分类问题:对两种蠓虫(A与B)进行鉴别,依据的资料是触角和翅膀的长度,已知了9支Af ...
- Django之url上的include,URL命名和反向解析,命名空间
include其他的URLconfs #At any point, your urlpatterns can “include” other URLconf modules. This #esse ...
- find_element——By 元素定位
• find_element(By.ID,”loginName”)• find_element(By.NAME,”SubjectName”)• find_element(By.CLASS_NAME,” ...
- 2011 Michigan Invitational Programming Contest
Crossings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463 Description ...
- Codeforces Round #407 (Div. 2) B+C!
B. Masha and geometric depression 被这个题坑了一下午,感觉很水,一直WA在第14组,我那个气啊,结束后发现第14组有点小争议,于是找出题人解释,然后出题人甩给了我一段 ...
- EasyUI 获取行ID,符合条件的添加样式
function GetTableTrID() { var p = $('#PreFixgrid').prev().find('div table:eq(1)'); var ID = $(p).fin ...
- SoapUI offen used scripts
[ Groovy Step ] //get properties from testCase, testSuite and project in groovy step def testCasePro ...
- [luoguP4035] [JSOI2008]球形空间产生器(高斯消元)
传送门 设球心的坐标为未知量 用最后一个点来表示球面到球心的距离,那么它和前n个式子相等 移项乱搞 最后高斯消元 #include <cmath> #include <cstdio& ...
- BZOJ2281 [SDOI2011]黑白棋 【dp + 组合数】
题目 小A和小B又想到了一个新的游戏. 这个游戏是在一个1*n的棋盘上进行的,棋盘上有k个棋子,一半是黑色,一半是白色. 最左边是白色棋子,最右边是黑色棋子,相邻的棋子颜色不同. 小A可以移动白色棋子 ...