[Unit Testing] Based on input value, spyOn function
describe( 'Forgot Password: with username', ()=> {
let dirElementInput;
beforeEach( ()=> {
// Find the input control:
dirElementInput = directiveElem.find('input');
// Set some text!
angular.element(dirElementInput).val('ahto.simakuutio@gmail.com').trigger('input');
$scope.$apply();
} );
it( 'should have username', ()=> {
expect(directiveCtrl.user.username ).toEqual('ahto.simakuutio@gmail.com');
} );
it('should call UserService\'s forgotPassword function', ()=>{
spyOn(UserService, 'forgotPassword');
angular.element( directiveElem.find( 'button' )[ 2 ] )
.click();
expect(UserService.forgotPassword).toHaveBeenCalled();
});
} );
describe('Forgot password: without username', ()=>{
let dirElementInput;
beforeEach( ()=> {
dirElementInput = directiveElem.find('input');
angular.element(dirElementInput).val('').trigger('input');
$scope.$apply();
});
it('should have empty username value', ()=>{
expect(directiveCtrl.user.username).toBeUndefined();
});
it('should not call UserService\'s ForgotPassword function', ()=>{
spyOn(UserService, 'forgotPassword');
angular.element( directiveElem.find( 'button' )[ 2 ] )
.click();
expect(UserService.forgotPassword).not.toHaveBeenCalled();
})
});
[Unit Testing] Based on input value, spyOn function的更多相关文章
- [Unit Testing] Unit Test a Function that Invokes a Callback with a Sinon Spy
Unit testing functions that invoke callbacks can require a lot of setup code. Using sinon.spy to cre ...
- Unit Testing a zend-mvc application
Unit Testing a zend-mvc application A solid unit test suite is essential for ongoing development in ...
- C/C++ unit testing tools (39 found)---reference
http://www.opensourcetesting.org/unit_c.php API Sanity AutoTest Description: An automatic generator ...
- Unit Testing PowerShell Code with Pester
Summary: Guest blogger, Dave Wyatt, discusses using Pester to analyze small pieces of Windows PowerS ...
- C# Note36: .NET unit testing framework
It’s usually good practice to have automated unit tests while developing your code. Doing so helps y ...
- Unit Testing with NSubstitute
These are the contents of my training session about unit testing, and also have some introductions a ...
- Javascript单元测试Unit Testing之QUnit
body{ font: 16px/1.5em 微软雅黑,arial,verdana,helvetica,sans-serif; } QUnit是一个基于JQuery的单元测试Uni ...
- [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 ...
- Unit Testing of Spring MVC Controllers: Configuration
Original Link: http://www.petrikainulainen.net/programming/spring-framework/unit-testing-of-spring-m ...
随机推荐
- Qt install Phonon
sudo apt-get install libphonon-dev phonon-backend-gstreamer
- 使用VisualVM查看Java Heap Dump
浏览Heap Dump 可以使用VisualVM浏览heap dump文件的内容,从而快速查看在堆中分配的对象.Heap dumps在主窗口的heap dump子标签页中显示.你可以打开保存在本地的h ...
- Centos 6.x 系统下用yum安装Memcache
我们的第一步就是导入第三方软件仓库RPMForge ,首页进行centos 官网找到RPMForge下载地址 http://wiki.centos.org/AdditionalResources/Re ...
- CentOS(Linux) - SVN使用笔记(一) - 安装SVN过程及开启和关闭svn服务指令
1.安装: yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql yum remove subversion 删除旧版 ...
- IE6 png 透明 (三种解决方法)(转来的哦)
FF和IE7已经直接支持透明的png图了,下面这个主要是解决IE6下透明PNG图片有灰底的 ====================================================== ...
- C#中睡眠函数Sleep
命名空间:using System.Threading; Thread.Sleep();//睡眠500毫秒,也就是0.5秒
- 关于 VS2013监视窗口的内存面板及寄存器面板
1.插入断点,按F5调试,2.选择菜单项 debug-窗口-3.即可找到您要的监视窗口.
- DataTables给表格绑定事件
$(document).ready(function() { $('#example').dataTable(); $('#example tbody').on('click', 'tr', func ...
- STL string常用操作指令
s.insert(pos,args); 在pos之前插入args指定的字符.pos可以是一个下标或一个迭代器.接受下标的版本返回一个指向s的引用;接受迭代器的版本返回指向第一个插入字符的迭代器. s. ...
- cf B. Eight Point Sets
http://codeforces.com/contest/334/problem/B #include <cstdio> #include <cstring> #includ ...