freeCodeCamp/curriculum/challenges/portuguese/06-quality-assurance/quality-assurance-and-testi.../use-assert.isok-and-assert....

2.7 KiB

id title challengeType forumTopicId dashedName
587d824b367417b2b2512c48 Usar Assert.isOK e Assert.isNotOK 2 301607 use-assert-isok-and-assert-isnotok

--description--

Lembrando que este projeto está sendo construído a partir do Replit, ou pode ser clonado no GitHub.

isOk() testará se um valor é verdadeiro e isNotOk() testará se um valor é falso.

Para saber mais sobre valores verdadeiros e falsos, experimente nosso desafio Remover falsos.

--instructions--

Em tests/1_unit-tests.js, no teste classificado como #3 e na suíte Basic Assertions, modifique cada assert para assert.isOk() ou para assert.isNotOk(), de maneira que cada teste passe (seja avaliado como true). Não altere os argumentos passados às afirmações.

--hints--

Todos os testes devem passar.

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(
    (data) => {
      assert.equal(data.state, 'passed');
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

Você deve escolher o método correto para a primeira afirmação - isOk ou isNotOk.

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(
    (data) => {
      assert.equal(data.assertions[0].method, 'isNotOk', 'Null is falsy');
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

Você deve escolher o método correto para a segunda afirmação - isOk ou isNotOk.

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(
    (data) => {
      assert.equal(data.assertions[1].method, 'isOk', 'A string is truthy');
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

Você deve escolher o método correto para a terceira afirmação - isOk ou isNotOk.

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(
    (data) => {
      assert.equal(data.assertions[2].method, 'isOk', 'true is truthy');
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

--solutions--

/**
  Backend challenges don't need solutions, 
  because they would need to be tested against a full working project. 
  Please check our contributing guidelines to learn more.
*/