-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from dsanchezcr/fix-npm
Fix npm
- Loading branch information
Showing
6 changed files
with
130 additions
and
3,744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,52 @@ | ||
const colonesexchangerate = require('./colonesexchangerate'); | ||
import assert from 'assert'; | ||
import colonesexchangerate from './colonesexchangerate.js'; | ||
|
||
describe('colonesexchangerate', () => { | ||
let converter; | ||
let converter = new colonesexchangerate(); | ||
|
||
beforeEach(() => { | ||
converter = new colonesexchangerate(); | ||
}); | ||
|
||
test('converts dollars to colones', async () => { | ||
const amount = 100; | ||
const result = await converter.dollarsToColones(amount); | ||
expect(Number(result)).toBeGreaterThan(0); | ||
}); | ||
|
||
test('converts colones to dollars', async () => { | ||
const amount = 1000; | ||
const result = await converter.colonesToDollars(amount); | ||
expect(Number(result)).toBeGreaterThan(0); | ||
}); | ||
|
||
test('converts dollars to euros', async () => { | ||
const amount = 100; | ||
const result = await converter.dollarsToEuros(amount); | ||
expect(Number(result)).toBeGreaterThan(0); | ||
}); | ||
|
||
test('converts euros to dollars', async () => { | ||
const amount = 100; | ||
const result = await converter.eurosToDollars(amount); | ||
expect(Number(result)).toBeGreaterThan(0); | ||
}); | ||
|
||
test('converts colones to euros', async () => { | ||
const amount = 1000; | ||
const result = await converter.colonesToEuros(amount); | ||
expect(Number(result)).toBeGreaterThan(0); | ||
}); | ||
|
||
test('converts euros to colones', async () => { | ||
async function runTests() { | ||
try { | ||
const amount = 100; | ||
const result = await converter.eurosToColones(amount); | ||
expect(Number(result)).toBeGreaterThan(0); | ||
}); | ||
|
||
test('gets dollar exchange rate', async () => { | ||
const rate = await converter.getDollarExchangeRate(); | ||
expect(rate).toHaveProperty('sale'); | ||
expect(rate).toHaveProperty('purchase'); | ||
}); | ||
|
||
test('gets euro exchange rate', async () => { | ||
const rate = await converter.getEuroExchangeRate(); | ||
expect(rate).toHaveProperty('dollars'); | ||
}); | ||
}); | ||
let result = await converter.dollarsToColones(amount); | ||
console.log(`Dollars to colones: ${result}`); | ||
assert(Number(result) > 0, 'Dollars to colones conversion result should be greater than 0'); | ||
|
||
result = await converter.colonesToDollars(amount); | ||
console.log(`Colones to dollars: ${result}`); | ||
assert(Number(result) > 0, 'Colones to dollars conversion result should be greater than 0'); | ||
|
||
result = await converter.dollarsToEuros(amount); | ||
console.log(`Dollars to euros: ${result}`); | ||
assert(Number(result) > 0, 'Dollars to euros conversion result should be greater than 0'); | ||
|
||
result = await converter.eurosToDollars(amount); | ||
console.log(`Euros to dollars: ${result}`); | ||
assert(Number(result) > 0, 'Euros to dollars conversion result should be greater than 0'); | ||
|
||
result = await converter.colonesToEuros(amount); | ||
console.log(`Colones to euros: ${result}`); | ||
assert(Number(result) > 0, 'Colones to euros conversion result should be greater than 0'); | ||
|
||
result = await converter.eurosToColones(amount); | ||
console.log(`Euros to colones: ${result}`); | ||
assert(Number(result) > 0, 'Euros to colones conversion result should be greater than 0'); | ||
|
||
let rate = await converter.getDollarExchangeRate(); | ||
console.log(`Dollar exchange rate: ${JSON.stringify(rate)}`); | ||
assert(rate.hasOwnProperty('date'), 'Dollar exchange rate should have a date property'); | ||
assert(rate.hasOwnProperty('sale'), 'Dollar exchange rate should have a sale property'); | ||
assert(rate.hasOwnProperty('purchase'), 'Dollar exchange rate should have a purchase property'); | ||
|
||
rate = await converter.getEuroExchangeRate(); | ||
console.log(`Euro exchange rate: ${JSON.stringify(rate)}`); | ||
assert(rate.hasOwnProperty('date'), 'Euro exchange rate should have a date property'); | ||
assert(rate.hasOwnProperty('dollars'), 'Euro exchange rate should have a dollars property'); | ||
assert(rate.hasOwnProperty('colones'), 'Euro exchange rate should have a colones property'); | ||
|
||
console.log('All tests passed!'); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
runTests(); |
Oops, something went wrong.