2020-05-19 12:49:06 +02:00
|
|
|
import { TestBed } from '@angular/core/testing';
|
|
|
|
import { ValidationService } from './validation.service';
|
|
|
|
|
2020-05-22 09:36:50 +02:00
|
|
|
let validationService: ValidationService;
|
|
|
|
|
2020-05-19 12:49:06 +02:00
|
|
|
describe('ValidationService', () => {
|
2020-05-22 09:36:50 +02:00
|
|
|
beforeEach(() => {
|
|
|
|
TestBed.configureTestingModule({
|
|
|
|
providers: [ValidationService]
|
|
|
|
});
|
|
|
|
|
|
|
|
validationService = TestBed.inject(ValidationService);
|
|
|
|
});
|
2020-05-19 12:49:06 +02:00
|
|
|
|
|
|
|
it('should be created', () => {
|
2020-05-22 09:36:50 +02:00
|
|
|
expect(validationService).toBeTruthy();
|
2020-05-19 12:49:06 +02:00
|
|
|
});
|
2020-05-22 09:36:50 +02:00
|
|
|
|
|
|
|
it('should return true on a correct username', () => {
|
|
|
|
expect(validationService.username('abc')).toEqual({ok: true, error: ''});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return an error on an incorrect username', () => {
|
|
|
|
expect(validationService.username('abc#')).toEqual({ok: false, error: 'username must only contain a-z0-9-_.'});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return true on a correct password', () => {
|
|
|
|
expect(validationService.password('Abc123!#')).toEqual({ok: true, error: ''});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return an error on an incorrect password', () => {
|
|
|
|
expect(validationService.password('Abc123')).toEqual({ok: false, error: 'password must only contain a-zA-Z0-9!"#%&\'()*+,-./:;<=>?@[]^_`{|}~'});
|
|
|
|
});
|
|
|
|
|
2020-05-19 12:49:06 +02:00
|
|
|
});
|