added test component containing the old test setup with two buttons for websocket and rest api testing respectively
This commit is contained in:
0
src/app/test/test.component.css
Normal file
0
src/app/test/test.component.css
Normal file
15
src/app/test/test.component.html
Normal file
15
src/app/test/test.component.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<div>
|
||||
<div class="card-container">
|
||||
<div class="card card-small" (click)="onClickSocket()" tabindex="0">
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
||||
|
||||
<span>Send test message</span>
|
||||
</div>
|
||||
|
||||
<div class="card card-small" (click)="onClickApi()" tabindex="0">
|
||||
<svg class="material-icons" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
||||
|
||||
<span>Call rest api</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
25
src/app/test/test.component.spec.ts
Normal file
25
src/app/test/test.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TestComponent } from './test.component';
|
||||
|
||||
describe('TestComponent', () => {
|
||||
let component: TestComponent;
|
||||
let fixture: ComponentFixture<TestComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ TestComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
29
src/app/test/test.component.ts
Normal file
29
src/app/test/test.component.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import {SocketService} from '../socket/socket.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-test',
|
||||
templateUrl: './test.component.html',
|
||||
styleUrls: ['./test.component.css']
|
||||
})
|
||||
export class TestComponent implements OnInit {
|
||||
|
||||
onClickSocket() {
|
||||
this.socketService.send('test', {'user': 'USERNAME', 'payload': 'PAYLOAD TEST'})
|
||||
}
|
||||
|
||||
onClickApi() {
|
||||
this.httpService.get('http://localhost:5005/').subscribe(response => {
|
||||
console.log('REST API call returned: ', response);
|
||||
});
|
||||
}
|
||||
|
||||
constructor(private httpService: HttpClient,
|
||||
private socketService: SocketService,
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user