Skip to content

Commit

Permalink
Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
Exitare committed Jan 4, 2025
1 parent 337aac7 commit 4a628e0
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('SelectConditions integration tests', () => {
},
]) {
it(`searching an existing entity should correctly work [id: ${id}, name: ${name}]`, () => {
const { page, _component } = setup();
const { page } = setup();
querySpy.calls.reset();

// Set input values based on the test case
Expand All @@ -118,7 +118,7 @@ describe('SelectConditions integration tests', () => {
}

it('searching and selecting an existing entity from the datatable should correctly work', () => {
const { page, _fixture, _component } = setup();
const { page } = setup();
const results = [
{
id: 1,
Expand Down
14 changes: 14 additions & 0 deletions libs/shared/selectors/src/search/game-tele-search.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Injectable } from '@angular/core';
import { MysqlQueryService } from '@keira/shared/db-layer';
import { GAME_TELE_SEARCH_FIELDS, GAME_TELE_TABLE, GameTele } from '@keira/shared/acore-world-model';
import { SearchService } from '@keira/shared/base-abstract-classes';

@Injectable({
providedIn: 'root',
})
export class GameTeleSearchService extends SearchService<GameTele> {
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690
constructor(override readonly queryService: MysqlQueryService) {
super(queryService, GAME_TELE_TABLE, GAME_TELE_SEARCH_FIELDS);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';

import { CreatureSelectorBtnComponent } from './creature-selector-btn.component';
import { GameTeleSelectorBtnComponent } from './game-tele-selector-btn.component';
import { ModalModule } from 'ngx-bootstrap/modal';

describe('CreatureSelectorBtnComponent', () => {
let component: CreatureSelectorBtnComponent;
let fixture: ComponentFixture<CreatureSelectorBtnComponent>;
describe('GameTeleSelectorBtnComponent', () => {
let component: GameTeleSelectorBtnComponent;
let fixture: ComponentFixture<GameTeleSelectorBtnComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ModalModule.forRoot(), CreatureSelectorBtnComponent],
imports: [ModalModule.forRoot(), GameTeleSelectorBtnComponent],
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(CreatureSelectorBtnComponent);
fixture = TestBed.createComponent(GameTeleSelectorBtnComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';

import { CreatureSelectorModalComponent } from './creature-selector-modal.component';
import { GameTeleSelectorModalComponent } from './game-tele-selector-modal.component';
import { BaseSelectorBtnComponent } from '../base-selector/base-selector-btn.component';

@Component({
Expand All @@ -10,6 +9,6 @@ import { BaseSelectorBtnComponent } from '../base-selector/base-selector-btn.com
styleUrls: ['../base-selector/base-selector-btn.component.scss'],
standalone: true,
})
export class CreatureSelectorBtnComponent extends BaseSelectorBtnComponent {
protected readonly modalComponentClass = CreatureSelectorModalComponent;
export class GameTeleSelectorBtnComponent extends BaseSelectorBtnComponent {
protected readonly modalComponentClass = GameTeleSelectorModalComponent;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div class="modal-body">
<p class="lead text-center mb-1">Creature selector</p>
<p class="lead text-center mb-1">Game Tele selector</p>

<form [formGroup]="searchService.queryForm">
<div class="row">
<ng-container [formGroup]="searchService.fields">
<div class="form-group col-3">
<input [formControlName]="'entry'" type="number" class="form-control form-control-sm" id="entry" placeholder="Entry" />
<input [formControlName]="'id'" type="number" class="form-control form-control-sm" id="id" placeholder="Id" />
</div>
<div class="form-group col-5">
<input [formControlName]="'name'" class="form-control form-control-sm" id="name" placeholder="Name" />
Expand Down Expand Up @@ -41,7 +41,7 @@
{{ row.entry }}
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column name="name" prop="name"></ngx-datatable-column>
<ngx-datatable-column name="name" prop="name" />
</ngx-datatable>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { instance, mock } from 'ts-mockito';

import { CreatureSelectorModalComponent } from './creature-selector-modal.component';
import { GameTeleSelectorModalComponent } from './game-tele-selector-modal.component';
import { TranslateTestingModule } from '@keira/shared/test-utils';
import { CreatureSearchService } from '../../search/creature-search.service';
import { MysqlQueryService } from '@keira/shared/db-layer';
import { GameTeleSearchService } from '../../search/game-tele-search.service';

describe('CreatureSelectorModalComponent', () => {
let component: CreatureSelectorModalComponent;
let fixture: ComponentFixture<CreatureSelectorModalComponent>;
let searchService: CreatureSearchService;
describe('GameTeleSelectorModalComponent', () => {
let component: GameTeleSelectorModalComponent;
let fixture: ComponentFixture<GameTeleSelectorModalComponent>;
let searchService: GameTeleSearchService;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CreatureSelectorModalComponent, TranslateTestingModule],
imports: [GameTeleSelectorModalComponent, TranslateTestingModule],
providers: [BsModalRef, { provide: MysqlQueryService, useValue: instance(mock(MysqlQueryService)) }],
}).compileComponents();
}));

beforeEach(() => {
searchService = TestBed.inject(CreatureSearchService);
searchService = TestBed.inject(GameTeleSearchService);
searchService.query = '--mock query';

fixture = TestBed.createComponent(CreatureSelectorModalComponent);
fixture = TestBed.createComponent(GameTeleSelectorModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { GAME_TELE_ID, GameTele } from '@keira/shared/acore-world-model';
import { TranslateModule } from '@ngx-translate/core';
import { NgxDatatableModule } from '@siemens/ngx-datatable';
import { SearchSelectorModalComponent } from '../base-selector/search-selector-modal.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { GameTeleSearchService } from '../../search/game-tele-search.service';
import { HighlightjsWrapperComponent } from '@keira/shared/base-editor-components';

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'keira-game-tele-selector-modal',
templateUrl: './game-tele-selector-modal.component.html',
standalone: true,
imports: [FormsModule, ReactiveFormsModule, NgxDatatableModule, TranslateModule, HighlightjsWrapperComponent],
})
export class GameTeleSelectorModalComponent extends SearchSelectorModalComponent<GameTele> {
protected entityIdField = GAME_TELE_ID;
protected searchService = inject(GameTeleSearchService);
}

0 comments on commit 4a628e0

Please sign in to comment.