import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';

@Injectable()
export class TestParameterResolve implements Resolve<string> {
    resolve(route: ActivatedRouteSnapshot): Promise<string> {
        return new Promise((resolve, reject) => {
            let testParamPropertyName: string = 'test';
            const test: string = route.params[testParamPropertyName];
            if (test == null || test === '' || test === 'test') {
                resolve(test || '');
            } else {
                reject('notfound');
            }
        });
    }
}
