[Angular Unit Testing] Shallow Pipe Testing
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的更多相关文章
- Unit Testing, Integration Testing and Functional Testing
转载自:https://codeutopia.net/blog/2015/04/11/what-are-unit-testing-integration-testing-and-functional- ...
- Difference Between Performance Testing, Load Testing and Stress Testing
http://www.softwaretestinghelp.com/what-is-performance-testing-load-testing-stress-testing/ Differen ...
- Go testing 库 testing.T 和 testing.B 简介
testing.T 判定失败接口 Fail 失败继续 FailNow 失败终止 打印信息接口 Log 数据流 (cout 类似) Logf format (printf 类似) SkipNow 跳过当 ...
- [Angular Unit Testing] Testing Pipe
import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'filesize' }) export class FileSi ...
- [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 ...
- [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 ...
- [Angular & Unit Testing] Automatic change detection
When you testing Component rendering, you often needs to call: fixture.detectChanges(); For example: ...
- [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 ...
- [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 ...
随机推荐
- 团队作业-Beta冲刺(3)
这个作业属于哪个课程 https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass2 这个作业要求在哪里 https://edu.cnblo ...
- 1.3 Quick Start中 Step 4: Send some messages官网剖析(博主推荐)
不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Step 4: Send some messages Step : 发送消息 Kaf ...
- Objective-C基础笔记(1)基本概念和第一个程序
一.基本概念 Objective-C(简称OC)是iOS开发的核心语言,苹果公司在维护,在开发过程中也会配合着使用C语言.C++,OC主要负责UI界面,C语言.C++可用于图形处理.C语言是面向过程的 ...
- 轻松学习Linux之用户账户管理及实例
Linux用户管理基础 (下载清晰视频:http://down.51cto.com/data/158699) 轻松学习Linux之用户账户管理的实例-跨硬盘移动数据 (此处视频不清楚下按下面地址下载清 ...
- Android 通过局域网udp广播自动建立socket连接
Android开发中经常会用到socket通讯.由于项目需要,最近研究了一下这方面的知识. 需求是想通过wifi实现android移动设备和android平台的电视之间的文件传输与控制. 毫无疑问这中 ...
- Windows 共享无线上网 无法启动ICS服务解决方法(WIN7 ICS服务启动后停止)
Windows 共享无线上网 无法启动ICS服务解决方法(WIN7 ICS服务启动后停止) ICS 即Internet Connection Sharing,internet连接共享,可以使局域网上其 ...
- 5lession-path路径相关操作
今天开始接触到了文件目录.路径方面的知识点.记录如下 先看代码 #!/usr/bin/python # -*- coding: utf-8 -*- import os import sys curre ...
- ontouch-控件添加ontouch监听事件
1,代码public class CalculatorViewPager extends ViewPager {}中 package com.android.calculator2; import a ...
- 原生js大总结四
031.数组常用的一些方法 1.push: 在数组最后添加一个或者多个元素,返回添加后数组的长度 2.pop: 从数组最后取出一个元素,返回的是数组的最后一个元素(取出的元素) 3.uns ...
- Android实践 -- Android蓝牙设置连接
使用Android Bluetooth APIs将设备通过蓝牙连接并通信,设置蓝牙,查找蓝牙设备,配对蓝牙设备 连接并传输数据,以下是Android系统提供的蓝牙相关的类和接口 BluetoothAd ...