3.3 KiB
3.3 KiB
id | title | localeTitle | challengeType | isRequired |
---|---|---|---|---|
bd7158d8c443edefaeb5bdef | Timestamp Microservice | Microservice de registro de data e hora | 4 | true |
Description
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