Assertivas - TecProg-2018-2/TecProg-VoxPop-WebApp GitHub Wiki

Exemplo de Assertivas

assert = require('assert');
this.assert.ok(request.contactReason != '' && request.email != '' &&
                  request.text != '' && request.topic != '');
  this.handlePropositionsResponse(this.offset);
  this.assert.ok(!isNaN(Number(this.offset)) || !isNaN(Number(this.pages)), 'Página não encontrada');

this.tokenValue = this.token.getToken();
this.token.checkToken(this.tokenValue);

this.assert.ok(this.tokenValue == null, 'Token vazio');

this.token.filterLoginPage(this.tokenValue);
  registerUserHandler(request) {
    this.assert.notEqual(request, 'null' || 'undefined');
    request.subscribe(response => {
      const statusUser = response.status;
      /*
      * If request is successful, the route navigate to login and cookie set true login
      */
      if (this.requester.didSucceed(statusUser)) {
        this.router.navigate(['login']);
        this.cookieService.set('success', 'true');
      }
    },
      error => {
        const statusAuth = error.status;
        this.validator.errorHandler(statusAuth);
      });
  }
 isPasswordValid(password) {
    this.assert(password === '', 'A senha inserida está vazia');
    if (password.length > 5 && password.length < 50) {
      return true;
    }
    return false;
  }