Ошибка: не удается разрешить все параметры для ReceivedQuickreplyMessageComponent: (?).Свойства ошибки: Object ({ngSyntaxError: true}) - PullRequest
0 голосов
/ 17 мая 2019

Я пытался сделать несколько тестов, но у меня есть некоторые проблемы, которых я не видел раньше. Мне нужно предоставить услугу, но я не знаю, что происходит.

Я использую - "@ angular / common": "^ 7.2.12",

Это мои спец.ц

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();
  });
});

Это мой .ts файл

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);
  }

}

Это мой сервис.ts

import { Injectable } from '@angular/core';
// import { HubConnectorComponent, HubConnectorRequestOptions } from 'angl-spawebbgrl';
import { parseMessage } from '../shared/parse';
import { ChatContentService } from './chat-content.service';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
import { TestLibraryService } from './test-library.service';
import { HubMessage } from '../shared/utils';
@Injectable()
export class ChatMessageService {

    public URL = `${this.api.config.URL_BASE}/${this.api.config.URL_SEND_MESSAGE}?${this.api.config.QP_APP_KEY}=${this.api.config.APP_KEY}`;
    public chatBotId = '';
    public userId = '';
    public senderId = '';

    /** Sends a message to hub and returns an observable with the response
     *  @Input HubMessage
     *  @Output HubResponse
     */
    sendMessage(message: string) {

        const body: HubMessage = {
            recipient: {
                id: 'https://consultoriabenevides.com'
            },
            sender: {
                id: this.senderId
            },
            message: {
                text: message
            },
            timestamp: new Date().getTime().toString()
        };

        this.chatService.messages$.next(this.chatService.messages$.getValue().concat(body));

        this.sendMessageHub(body).subscribe(res => {
            this.chatService.messages$.next(this.chatService.messages$.getValue().concat(parseMessage(res)));
        });

    }

    sendMessageHub(body): Observable<any> {

        this.http.post(this.URL, body, { headers: { 'channelBotIdentifier': this.chatBotId } });

    }

    setBotId(chatBotId: string) {
        this.chatBotId = chatBotId;
    }

    setSenderId(senderId: string) {
      this.senderId = senderId;
    }

    constructor(
        private http: HttpClient,
        private chatService: ChatContentService,
        private api: TestLibraryService

    ) { }

}

Я ожидаю, что мой компонент должен быть создан. Пожалуйста, помогите мне. Я несколько раз безуспешно пробовал

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...