我无法理解管道测试的不正确之处。
这是一个用于从数组创建MatTableDataSource的管道。
这是我的烟斗:
import { Pipe, PipeTransform } from '@angular/core';
import { MatTableDataSource } from '@angular/material';
@Pipe({
name: 'dataSource'
})
export class DataSourcePipe implements PipeTransform {
transform(array: any[]): any {
return array ? new MatTableDataSource(array) : new MatTableDataSource([]);
}
}
测试用于检查数组是否为空,它返回一个空的matTableDataSource
import { TestBed, async, inject } from '@angular/core/testing';
import { DataSourcePipe } from './datasource-pipe.pipe';
import { MatTableDataSource } from '@angular/material';
describe('Pipe: Datasource', () => {
let pipe: DataSourcePipe;
beforeEach(() => {
pipe = new DataSourcePipe();
});
describe('Tests', () => {
it('providing an empty array returns empty matTableDatasource', () => {
expect(pipe.transform([])).toEqual(new MatTableDataSource([]));
});
});
});
此测试失败:
PhantomJS 2.1.1 (Linux 0.0.0) Pipe: Datasource Tests providing an empty array returns empty matTableDatasource FAILED
Expected $._filter.observers[0]._parent._parent._parent._parent._parent._parent._parent._parent._parent.destination._next = Function to equal Function.
Expected $._filter.observers[0]._parent._parent._parent._parent._parent._parent._parent._parent.project = Function to equal Function.
Expected $._filter.observers[0]._parent._parent._parent._parent._parent._parent._parent.observables[0].destination.destination.array[0].operator.project = Function to equal Function.
Expected $._filter.observers[0]._parent._parent._parent._parent._parent._parent._parent.observables[0].operator.project = Function to equal Function.
Expected $._filter.observers[0]._parent._parent._parent._parent._parent.project = Function to equal Function.
Expected $._filter.observers[0]._parent._parent.project = Function to equal Function.
Expected $.sortingDataAccessor = Function to equal Function.
Expected $.sortData = Function to equal Function.
Expected $.filterPredicate = Function to equal Function.
我无法理解为什么,我也控制台记录“toEqual”的两个部分并且是相同的。
有人可以告诉我,我做错了什么吗?