import { TestBed, ComponentFixture } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
import { FileSizePipe } from './file-size.pipe';
import {Component} from '@angular/core'; TestBed.initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
); describe('FileSizePipe', () => { describe('Shallow Pipe Testing', () => {
@Component({
template: `size: {{size | filesize:suffix}}`
})
class TestComponent {
suffix;
size = 123456789;
} let component : TestComponent;
let fixture : ComponentFixture<TestComponent>;
let el: HTMLElement; beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
FileSizePipe,
TestComponent
]
});
fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance;
el = fixture.nativeElement;
fixture.detectChanges();
}); it('should convert bytes to megabytes', () => {
expect(el.textContent).toContain('size: 117.74MB');
component.size = 1029281;
fixture.detectChanges();
expect(el.textContent).toContain('size: 0.98MB');
}); it('should use the default extension when not supplied', () => {
component.suffix = 'myExt';
fixture.detectChanges();
expect(el.textContent).toContain('size: 117.74myExt');
});
});
});

[Angular Unit Testing] Shallow Pipe Testing的更多相关文章

  1. Unit Testing, Integration Testing and Functional Testing

    转载自:https://codeutopia.net/blog/2015/04/11/what-are-unit-testing-integration-testing-and-functional- ...

  2. Difference Between Performance Testing, Load Testing and Stress Testing

    http://www.softwaretestinghelp.com/what-is-performance-testing-load-testing-stress-testing/ Differen ...

  3. Go testing 库 testing.T 和 testing.B 简介

    testing.T 判定失败接口 Fail 失败继续 FailNow 失败终止 打印信息接口 Log 数据流 (cout 类似) Logf format (printf 类似) SkipNow 跳过当 ...

  4. [Angular Unit Testing] Testing Pipe

    import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'filesize' }) export class FileSi ...

  5. [Angular + Unit Testing] Mock HTTP Requests made with Angular’s HttpClient in Unit Tests

    In a proper unit test we want to isolate external dependencies as much as possible to guarantee a re ...

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

  7. [Angular & Unit Testing] Automatic change detection

    When you testing Component rendering, you often needs to call: fixture.detectChanges(); For example: ...

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

  9. [Angular Unit Testing] Debug unit testing -- component rendering

    If sometime you want to log out the comonent html to see whether the html render correctly, you can ...

随机推荐

  1. go-web编程之处理xml

    摘抄自astaxie的开源书籍 build-web-application-with-golang 接下来的例子以下面XML描述的信息进行操作. <?xml version="1.0& ...

  2. 【AIM Tech Round 4 (Div. 2) A】Diversity

    [链接]http://codeforces.com/contest/844/problem/A [题意] 大水题 [题解] 看看不同的个数num是不是小于k,小于k,看看len-num够不够补的 [错 ...

  3. JSP页面开发规范案例

    添加 <%@ page language="java" contentType="text/html; charset=utf-8" pageEncodi ...

  4. Binary Search Algorithm

    二分查找代码: //============================================================================ // Name : Bin ...

  5. 5. Node基础编程

      基于Chrome V8引擎 单线程 使用JavaScript开发后端代码 非阻塞的IO common规范 common一定是通过module.exports={}输出 创建Http Server ...

  6. QQ群功能设计与心理学

    刚刚在一个Java技术交流群,发了个 "博客投票"的广告. 群主两眼一黑,瞬间就把我给干掉了. 看到QQ给出的系统消息,发现QQ群的一个功能做得很不错. 大家注意到,右边有个&qu ...

  7. 原生js大总结九

    81.ES6的Symbol的作用是什么?   ES6引入了一种新的原始数据类型Symbol,表示独一无二的值   82.ES6中字符串和数组新增了那些方法   字符串       1.字符串模板    ...

  8. ajax的get请求与编码

    window.onload = function(){ document.getElementById('username').onblur = function(){ var name = docu ...

  9. Android 设置背景透明度

    一些时候,我们须要为UI页面设置背景色,例如以下图所看到的: 上图已注: 背景颜色为#000000,透明度为40%: 那么.怎样在代码中表示呢? 首先须要了解: 颜色和不透明度 (alpha) 值以十 ...

  10. H5移动端IOS/Android兼容性总结,持续更新中…

    H5移动端IOS/Android兼容性总结,持续更新中… 1. IOS不识别日期 new Date("2018-07-01 08:00:00")在Android下正常显示可以直接进 ...