Commit 49f13ac4 authored by Vladislav Bogac's avatar Vladislav Bogac

fixed

parent a37242ac
......@@ -10,7 +10,7 @@ import { AttendeeService } from '../../../service/attendee/attendee.service';
import { FooterBarService } from '../../../service/footer-bar/footer-bar.service';
import { QuizService } from '../../../service/quiz/quiz.service';
import { UserService } from '../../../service/user/user.service';
import {BonusTokenService} from 'src/app/service/user/shared/bonus-token.service';
import {BonusTokenService} from 'src/app/service/user/bonus-token/bonus-token.service';
@Component({
selector: 'app-nickname-input',
......
......@@ -12,7 +12,7 @@ import { CustomMarkdownService } from '../../../service/custom-markdown/custom-m
import { FooterBarService } from '../../../service/footer-bar/footer-bar.service';
import { QuizService } from '../../../service/quiz/quiz.service';
import { UserService } from '../../../service/user/user.service';
import {BonusTokenService} from '../../../service/user/shared/bonus-token.service';
import {BonusTokenService} from '../../../service/user/bonus-token/bonus-token.service';
@Component({
selector: 'app-nickname-select',
......
......@@ -8,7 +8,7 @@ import { IMemberSerialized } from '../../lib/interfaces/entities/Member/IMemberS
import { MemberApiService } from '../api/member/member-api.service';
import { QuizService } from '../quiz/quiz.service';
import { StorageService } from '../storage/storage.service';
import {BonusTokenService} from '../user/shared/bonus-token.service';
import {BonusTokenService} from '../user/bonus-token/bonus-token.service';
@Injectable({ providedIn: 'root' })
export class AttendeeService {
......
import { TestBed } from '@angular/core/testing';
import { BonusTokenService } from './bonus-token.service';
import { BonusTokenService } from '../bonus-token/bonus-token.service';
import {HttpClient, HttpHandler} from '@angular/common/http';
import {JWT_OPTIONS, JwtHelperService, JwtModule} from '@auth0/angular-jwt';
import {jwtOptionsFactory} from '../../../lib/jwt.factory';
import {PLATFORM_ID} from '@angular/core';
import {StorageService} from '../../storage/storage.service';
import {RouterTestingModule} from '@angular/router/testing';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {TranslateService} from '@ngx-translate/core';
import {TranslateServiceMock} from '../../../../_mocks/_services/TranslateServiceMock';
import {StorageServiceMock} from '../../storage/storage.service.mock';
import {UserService} from '../user.service';
import {QuizService} from '../../quiz/quiz.service';
import {QuizMockService} from '../../quiz/quiz-mock.service';
import {AuthorizeApiService} from '../../api/authorize/authorize-api.service';
import {AuthorizeApiServiceMock} from '../../../../_mocks/_services/AuthorizeApiServiceMock';
describe('BonusTokenService', () => {
let service: BonusTokenService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [PLATFORM_ID, StorageService],
},
}), RouterTestingModule, HttpClientTestingModule
],
providers: [
{
provide: BonusTokenService
provide: StorageService,
useClass: StorageServiceMock,
}, UserService, {
provide: QuizService,
useClass: QuizMockService,
}, {
provide: AuthorizeApiService,
useClass: AuthorizeApiServiceMock,
},
HttpClient, HttpHandler, JwtHelperService,
{
provide: TranslateService,
useClass: TranslateServiceMock
}
]
});
......@@ -20,7 +55,4 @@ describe('BonusTokenService', () => {
expect(service).toBeTruthy();
});
it('should return a String', () => {
expect(typeof this.bonusToken === 'string').toBeTruthy();
});
});
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {UserService} from '../user.service';
import {UserService} from '../../user/user.service';
import {DefaultSettings} from '../../../lib/default.settings';
import {Observable} from 'rxjs';
import {StorageKey} from '../../../lib/enums/enums';
@Injectable({
providedIn: 'root'
})
export class BonusTokenService {
public bonusToken: string;
private configUrl: string;
constructor(private http: HttpClient, private userService: UserService) {
}
constructor(private http: HttpClient) {
this.bonusToken = 'afsml8';
this.configUrl = 'https://staging.arsnova.click/backend/api/v1/member/token';
this.http.get(this.configUrl).subscribe(data => {
this.bonusToken += data['status'];
public getBonusToken(): Observable<string> {
return this.http.get<string>(`${DefaultSettings.httpApiEndpoint}/member/token/bonus`, {
headers: {authorization: sessionStorage.getItem(StorageKey.QuizToken)},
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment