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. C#自定义List类

    代码如下: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespac ...

  2. (转)【已解决】关于SQL2008 “不允许保存更改。您所做的更改要求删除并重新创建以下表。您对无法重新创建的标进行了更改或者启用了‘阻止保存要求重新创建表的更改’” 解决方案

    近日在使用sql2008的过程中,要对已经创建完成的表结构进行修改,却一直提示弹出如下提示: “ 不允许保存更改.您所做的更改要求删除并重新创建以下表.您对无法重新创建的标进行了更改或者启用了“阻止保 ...

  3. SignalR2.0开发实例之——负载均衡

    SignalR 2.0作为一个新的而且强大的通信工具,发布博客之后得到了很多人的支持,谢谢...也有人对性能和架设等问题提出了各种质疑..真的很感谢.. 我特意下载了SignalR 2.0的源码硬着头 ...

  4. [C#] 后端post的请求方法

    C# 模拟post请求方法 方法1: /// <summary> /// 模拟Post请求 /// </summary> /// <param name="ur ...

  5. Fling!

    算法:深搜 很不错的一道题!!! Fling is a kind of puzzle games available on phone. This game is played on a board ...

  6. HDU 2896 病毒侵袭 (AC自动机)

    这题模板题.............但是竟然要去重........调试了半天才发现.................... #include <cstdio> #include <i ...

  7. 自定义 Preference Header 布局

    1. Preference Header 概述: 对于什么是 Preference Header,以及何时使用 Preference Header,请参考我的另一篇博文: 何时使用 Preferenc ...

  8. Jade学习笔记

    初学nodejs,折腾过用handlebars做模板,后来隔了一段重新学习,用了jade,真心简洁……记录一些学习笔记,以备复习. jade是基于缩进的,所以tab与space不能混用: 属性的设置: ...

  9. 解决ie6显示透明图的问题

    在我们设置png透明图片时,其他浏览器都显示很正常,唯独只有ie6看着不是透明的状态. 第一种办法是:单独设置ie6的样式.例: _background: none; _filter:progid:D ...

  10. laravel实现第三方登录(qq登录)

    首先composer安装依赖: composer require socialiteproviders/qq 注册服务提供者(同时注释掉原有的Socialite提供者): 'providers' =& ...