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. linux内存机制

    ~# free -m         total used  free shared buffers cachedMem: 16086 8579 7507    0      152      800 ...

  2. javascript "非法值"检验.

    <script type="text/javascript"> function getCoord() { var x = document.getElementByI ...

  3. oracle数据库exp/imp命令详解

    转自http://wenku.baidu.com/link?url=uD_egkkh7JtUYJaRV8YM6K8CLBT6gPJS4UlSy5WKhz46D9bnychTPdgJGd7y6UxYtB ...

  4. canvas ---1

    Canvas1 (关键词:canvas)   canvas :就是html5中提供的一个标签,只是用来展示绘图的内容 canvas  标签的默认宽高:300*150 如果给canvas来设置高度和宽度 ...

  5. Flex布局摆脱float带来的布局问题

    完整文章地址http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html?utm_source=tuicool 使用浮动(float)的一个比较疑惑 ...

  6. poj3254状压DP入门

    G - 状压dp Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:65536KB     64bit ...

  7. HTML5 布局标签

    HTML5是HTML标准的下一个版本.越来越多的程序员开始HTML5来构建网站,相对HTML4,HTML5新增的带有语义化的标签可以代替div进行页面布局(与html5.js结合起来时可以放心使用 ) ...

  8. 解决APP中fragment重叠问题

    由于内存重启,导致的frgament重叠,其原因就是FragmentState没有保存Fragment的显示状态,即mHidden,导致页面重启后,该值为默认的false,即show状态,所以导致了F ...

  9. linux 下 重启apache

    重启 apache #service httpd restart

  10. python学习第十八天 --错误&异常处理

    这一章节主要讲解python的错误和异常处理 什么是错误和异常?及其区别? 错误: 1.语法错误:代码不符合解释器或者编译器语法. 2.逻辑错误:不完整或者不合法输入或者计算出现问题.   异常:执行 ...