我正在单元测试一个可观察的对象,并检查它是否包含?要素数据来源如下。
虽然两个expect都运行正常,但我不相信expect检查的结果是什么?做记号
我不需要检查完整的元素{name:'?',isAlive:false},
当我安慰的时候。记录结果,如图所示
[Object{name:'Test',isAlive:true},Object{name:'Test2',isAlive:false},Object{name:'Test3',isAlive:false},Object{name:'Test4',isAlive:false},Object{name:'Test5',isAlive:false}]
export const TestModelObjectMock: any[] = [
{ name: 'Test', isAlive: false },
{ name: 'Test2', isAlive: false },
{ name: 'Test3', isAlive: false },
{ name: '?', isAlive: false },
{ name: 'Test4', isAlive: true },
{ name: 'Test5', isAlive: false }
];
const testModelObject = TestModelObjectMock;
it('should call the title service and filter questionmark', fakeAsync(() => {
mockTestService.extend({ getTitles: () => of(testModelObject ) });
setupComponent();
flush();
expect(component.titleService.getNames().subscribe(result => expect(result).not.toContain('?')));
expect(component.titleNames$.subscribe(result => {expect(result.length).toEqual(5),
console.log(result)}));