freeCodeCamp/curriculum/challenges/portuguese/05-apis-and-microservices/apis-and-microservices-proj.../timestamp-microservice.port...

3.3 KiB

id title localeTitle challengeType isRequired
bd7158d8c443edefaeb5bdef Timestamp Microservice Microservice de registro de data e hora 4 true

Description

Crie um aplicativo JavaScript de pilha completa que seja funcionalmente semelhante a este: https://curse-arrow.glitch.me/ . Trabalhar neste projeto envolverá você escrevendo seu código no Glitch em nosso projeto inicial. Depois de concluir este projeto, você pode copiar sua URL de falha pública (para a página inicial do seu aplicativo) nesta tela para testá-lo! Opcionalmente, você pode optar por escrever seu projeto em outra plataforma, mas deve estar publicamente visível para nossos testes. iniciar este projeto em Glitch usando este link ou clonar este repositório no GitHub! Se você usa o Glitch, lembre-se de salvar o link do seu projeto em algum lugar seguro!

Instructions

Tests

tests:
  - text: 'Ele deve manipular uma data válida e retornar o registro de data e hora correto do unix'
    testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp/2016-12-25'').then(data => { assert.equal(data.unix, 1482624000000, ''Should be a valid unix timestamp''); }, xhr => { throw new Error(xhr.responseText); })'
  - text: 'Ele deve manipular uma data válida e retornar a string UTC correta'
    testString: 'getUserInput => $.get(getUserInput(''url'')+ ''/api/timestamp/2016-12-25'').then(data => { assert.equal(data.utc, ''Sun, 25 Dec 2016 00:00:00 GMT'', ''Should be a valid UTC date string''); }, xhr => { throw new Error(xhr.responseText); })'
  - text: 'Ele deve manipular uma data unix válida e retornar o registro de data e hora correto do unix'
    testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp/1482624000000'').then(data => { assert.equal(data.unix, 1482624000000) ;  }, xhr => { throw new Error(xhr.responseText); })'
  - text: Deve devolver a mensagem de erro esperada para uma data inválida
    testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp/this-is-not-a-date'').then(data => { assert.equal(data.error.toLowerCase(), ''invalid date'');}, xhr => { throw new Error(xhr.responseText); })'
  - text: 'Ele deve manipular um parâmetro de data vazio e retornar a hora atual no formato unix'
    testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp'').then(data => { var now = Date.now(); assert.approximately(data.unix, now, 20000) ;}, xhr => { throw new Error(xhr.responseText); })'
  - text: 'Ele deve manipular um parâmetro de data vazio e retornar a hora atual no formato UTC'
    testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp'').then(data => { var now = Date.now(); var serverTime = (new Date(data.utc)).getTime(); assert.approximately(serverTime, now, 20000) ;}, xhr => { throw new Error(xhr.responseText); })'

Challenge Seed

Solution

// solution required