3.3 KiB
3.3 KiB
id, title, localeTitle, challengeType, isRequired, forumTopicId
id | title | localeTitle | challengeType | isRequired | forumTopicId |
---|---|---|---|---|---|
bd7158d8c443edefaeb5bdef | Timestamp Microservice | Microservicio de marcas de tiempo | 4 | true | 301508 |
Description
Instructions
Tests
tests:
- text: 'Debe manejar una fecha válida y devolver la marca de tiempo de Unix correcta'
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: 'Debe manejar una fecha válida y devolver la cadena UTC correcta'
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: 'Debe manejar una fecha de Unix válida y devolver la marca de tiempo de Unix correcta'
testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/timestamp/1482624000000'').then(data => { assert.equal(data.unix, 1482624000000) ; }, xhr => { throw new Error(xhr.responseText); })'
- text: Debe devolver el mensaje de error esperado para una fecha no vá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: 'Debería aceptar un parámetro de fecha vacío y devolver la hora actual en 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: 'Debe aceptar un parámetro de fecha vacío y devolver la hora actual en 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