我一直在尝试做一些测试,但是我遇到了一些以前从未见过的问题。我需要提供服务,但我不知道发生了什么事。
我正在使用-“ @ angular / common”:“ ^ 7.2.12”,
这是我的说明
Flux<Integer> myMethod(Mono<MyClass> homeWork) {
return homeWork
.map(hw -> hw.multiplicands.stream().map(m -> m * hw.multiplier))
.flatMapMany(Flux::fromStream);
}
这是我的.ts文件
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ChatMessageService } from '../_services/chat-message.service';
import { ReceivedQuickreplyMessageComponent } from './received-quickreply-message.component';
import { ChatContentService } from '../_services/chat-content.service';
import { TestLibraryService } from '../_services/test-library.service';
describe('ReceivedQuickreplyMessageComponent', () => {
let component: ReceivedQuickreplyMessageComponent;
let fixture: ComponentFixture<ReceivedQuickreplyMessageComponent>;
beforeEach(() => {
const mockHttp = jasmine.createSpyObj('mockHttp', ['post']);
const mockChatContentService = new ChatContentService();
const mockEnvironment = {
production: false,
ORIGIN: 'https://consultoriabenevides.com',
URL_BASE: 'https://consultoriabenevides.com',
QP_APP_KEY: 'hw24',
URL_SEND_MESSAGE: 'va/v1/message',
APP_KEY: '15101988',
MOCK_URL: 'http://localhost:3000',
BASE_URL_PROTACTOR: 'http://localhost:4200/'
};
const mockTestLibraryService = new TestLibraryService(mockEnvironment);
const messageService = new ChatMessageService(mockHttp, mockChatContentService, mockTestLibraryService);
TestBed.configureTestingModule({
schemas: [NO_ERRORS_SCHEMA],
declarations: [ReceivedQuickreplyMessageComponent],
providers: [
{ provide: ChatMessageService, useValue: messageService }
]
});
fixture = TestBed.createComponent(ReceivedQuickreplyMessageComponent);
component = fixture.componentInstance;
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
这是我的服务。
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
import { ChatMessageService } from '../_services/chat-message.service';
import { transition, state, trigger, style, animate, keyframes } from '@angular/animations';
import { QuickReplyType } from '../shared/quickreply';
import { BehaviorSubject } from 'rxjs';
@Component({
selector: 'received-quickreply-message',
templateUrl: './received-quickreply-message.component.html',
styleUrls: ['./received-quickreply-message.component.scss'],
})
export class ReceivedQuickreplyMessageComponent {
@Input() message: QuickReplyType;
public allInactivated$ = new BehaviorSubject(false);
public buttonChosed$ = new BehaviorSubject(null);
constructor(public chatMessageService: ChatMessageService) { }
/**
* Send the quick reply payload to message service
* @param index
*/
replyMessage(index) {
this.allInactivated$ = new BehaviorSubject(true);
this.buttonChosed$ = new BehaviorSubject(index);
const reply_title = this.message.elements[index].title;
this.chatMessageService.sendMessage(reply_title);
}
}
我希望应该创建我的组件。请帮我。我已经尝试了几次但没有成功