Skip to content

Commit

Permalink
Fixes #7
Browse files Browse the repository at this point in the history
Refactorizar test
  • Loading branch information
cdiaz committed Mar 31, 2018
1 parent 68af670 commit a48e73f
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
var test = require('tape')
var trmcol = require('./../index')
var trmcol = require('../src')

test('Valor actual', function (t) {
t.plan(3)

trmcol.query(function (err, trm1) {
t.error(err)
var d = new Date()
d.setTime(d.getTime() - 300 * 60000) // Forzar hora colombiana
trmcol.query(d.toISOString().slice(0, 10), function (err, trm2) {
t.error(err)
t.equal(trm1.value, trm2.value)
t.plan(1)

trmcol.query()
.then(trm1 => {
var d = new Date()
d.setTime(d.getTime() - 300 * 60000) // Forzar hora colombiana
trmcol.query(d.toISOString().slice(0, 10))
.then(trm2 => {
t.equal(trm1.value, trm2.value)
})
.catch(err => {
t.error(err)
})
})
})
})

test('Fechas Válidas', function (t) {
t.plan(4)

trmcol.query('2015-01-01', function (err, trm) {
t.error(err)
t.equal(trm.value, '2392.46')
})
trmcol.query('2016-01-01', function (err, trm) {
t.error(err)
t.equal(trm.value, '3149.47')
})
test('Fechas Válidas', (t) => {
t.plan(2)

trmcol.query('2015-01-01')
.then(trm => t.equal(trm.value, '2392.46'))
.catch(err => t.error(err))

trmcol.query('2016-01-01')
.then(trm => t.equal(trm.value, '3149.47'))
.catch(err => t.error(err))
})

test('Fechas inválidas', function (t) {
test('Fechas inválidas', (t) => {
t.plan(2)

trmcol.query('15-01-01', function (err, trm) {
t.ok(err, 'Existe error')
})
trmcol.query('2016-13-01', function (err, trm) {
t.ok(err, 'Existe error')
})
trmcol.query('15-01-01')
.then()
.catch(err => t.ok(err, 'Existe error'))

trmcol.query('2016-13-01')
.then()
.catch(err => t.ok(err, 'Existe error'))
})

0 comments on commit a48e73f

Please sign in to comment.