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的更多相关文章

  1. [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 ...

  2. Unit Testing a zend-mvc application

    Unit Testing a zend-mvc application A solid unit test suite is essential for ongoing development in ...

  3. C/C++ unit testing tools (39 found)---reference

    http://www.opensourcetesting.org/unit_c.php API Sanity AutoTest Description: An automatic generator ...

  4. Unit Testing PowerShell Code with Pester

    Summary: Guest blogger, Dave Wyatt, discusses using Pester to analyze small pieces of Windows PowerS ...

  5. C# Note36: .NET unit testing framework

    It’s usually good practice to have automated unit tests while developing your code. Doing so helps y ...

  6. Unit Testing with NSubstitute

    These are the contents of my training session about unit testing, and also have some introductions a ...

  7. Javascript单元测试Unit Testing之QUnit

    body{ font: 16px/1.5em 微软雅黑,arial,verdana,helvetica,sans-serif; }           QUnit是一个基于JQuery的单元测试Uni ...

  8. [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 ...

  9. Unit Testing of Spring MVC Controllers: Configuration

    Original Link: http://www.petrikainulainen.net/programming/spring-framework/unit-testing-of-spring-m ...

随机推荐

  1. mybatis与spring的整合

    今天是mybatis的最后一天,也是最为重要的一天,mybatis与spring整合,(spring相关知识我会抽一个大的模块进行讲解). 首先加入Spring的依赖 <dependency&g ...

  2. C#,.net获取字符串中指定字符串的个数、所在位置与替换字符串

    方法一: public static int indexOf (字符串/字符,int从第几位开始,int共查几位) string tests = "1absjjkcbfka2rsbcfak2 ...

  3. OD: First Step

    开始学习 0Day 了,前进了小小一步:<0Day 安全:软件漏洞分析艺术>第一篇末尾的 crack_me 实验成功了. 纪念一下. 几个概念: PE:    Portable Execu ...

  4. Sass函数--数字函数

    数字函数简介 Sass 中的数字函数提要针对数字方面提供一系列的函数功能: percentage($value):将一个不带单位的数转换成百分比值: round($value):将数值四舍五入,转换成 ...

  5. Sass混合宏、继承、占位符

    混合宏-声明混合宏如果你的整个网站中有几处小样式类似,比如颜色,字体等,在 Sass 可以使用变量来统一处理,那么这种选择还是不错的.但当你的样式变得越来越复杂,需要重复使用大段的样式时,使用变量就无 ...

  6. xp sp3安装 iis5.1

    1.依次打开左下角的 "开始" 菜单----控制面板----选择 "添加/删除程序", 点击窗体左侧 "添加/删除Windows组件"(A) ...

  7. 截取字符串 substring substr slice

    截取字符串   substring 方法用于提取字符串中介于两个指定下标之间的字符  substring(start,end) 开始和结束的位置,从零开始的索引 参数     描述 start     ...

  8. JSP Servlet SQL 三者之间数据传递

    前言: 最近一直在做WEB开发,现总结一下这一段时间的体会和感触. 切记,web开发重点在于前台数据交互,页面美化而不要太沉溺于底层数据. 浏览器时代来到,向我们召唤出更炫.更简洁.更方便.更大气的网 ...

  9. Objective-C中instancetype和id的区别

    要区分instancetype和id,首先要弄清楚什么是关联返回类型(Related Result Type). 关联返回类型即一个方法的返回类型就是调用这个方法的调用者的类型.具有下列条件的方法具有 ...

  10. php 函数strtr 替换函数实例解析 strtr 速度比较快

    先来看看这个php字符串替换函数 PHP字符串替换函数strtr()的两种状态 strtr(string,from,to) 或者strtr(string,array) 首先针对PHP字符串替换函数st ...