add-robot.component.spec.ts 1.96 KB
Newer Older
1
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
2 3
import { ClarityModule } from '@clr/angular';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
4
import { AddRobotComponent } from './add-robot.component';
5 6 7 8 9
import { FormsModule } from '@angular/forms';
import { RobotService } from "../robot-account.service";
import { of } from "rxjs";
import { MessageHandlerService } from "../../../shared/message-handler/message-handler.service";
import { TranslateModule, TranslateService } from '@ngx-translate/core';
AllForNothing's avatar
AllForNothing committed
10
import { AppConfigService } from "../../../services/app-config.service";
11
import { ErrorHandler } from "../../../../lib/utils/error-handler";
12 13 14 15

describe('AddRobotComponent', () => {
  let component: AddRobotComponent;
  let fixture: ComponentFixture<AddRobotComponent>;
16 17 18 19 20 21 22 23 24 25 26 27
  let fakeRobotService = {
    listRobotAccount: function () {
      return of([{
        name: "robot$" + 1
      }, {
        name: "abc"
      }]);
    }
  };
  let fakeMessageHandlerService = {
    showSuccess: function() {}
  };
Yogi_Wang's avatar
Yogi_Wang committed
28 29 30 31 32 33 34
  let fakeAppConfigService = {
    getConfig: function() {
      return {
        with_chartmuseum: true
      };
    }
  };
35

36
  beforeEach(waitForAsync(() => {
37
    TestBed.configureTestingModule({
38 39 40 41 42 43 44 45 46 47 48 49 50
      declarations: [AddRobotComponent],
      schemas: [
        CUSTOM_ELEMENTS_SCHEMA
      ],
      imports: [
        ClarityModule,
        TranslateModule.forRoot(),
        FormsModule
      ],
      providers: [
        TranslateService,
        ErrorHandler,
        { provide: MessageHandlerService, useValue: fakeMessageHandlerService },
Yogi_Wang's avatar
Yogi_Wang committed
51
        { provide: AppConfigService, useValue: fakeAppConfigService },
52 53 54
        { provide: RobotService, useValue: fakeRobotService }
      ]
    }).compileComponents();
55 56 57 58 59 60 61 62 63 64 65 66
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(AddRobotComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});