Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Commit

Permalink
Renamed Brand to Trade
Browse files Browse the repository at this point in the history
  • Loading branch information
Zenedith committed Mar 5, 2016
1 parent 88fe8fd commit 9ac0dd1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 57 deletions.
3 changes: 0 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ module.exports = {
InvalidPhoneError: require('./lib/error/invalidPhoneError').InvalidPhoneError,
InvalidTradeError: require('./lib/error/invalidTradeError').InvalidTradeError
},
converter: {
tradeConverter: require('./lib/tradeConverter').tradeConverter
},
enum: {
Trade: require('./lib/model/trade').Trade,
Currency: require('./lib/model/currency').Currency,
Expand Down
26 changes: 25 additions & 1 deletion lib/model/trade.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,33 @@ var Trade = {
PRIVATE_MEDIC_DENTAL: 'PRIVATE_MEDIC_DENTAL',
OTHER: 'OTHER',

map: {
'5602c71013287705788b4567': 'HAIRDRESSING',
'5602c71013287705788b4568': 'PRIVATE_MEDIC_DENTAL',
'': 'OTHER'
},

getTradeFromId: function getTradeFromId(id) {
if (Trade.map.hasOwnProperty(id)) {
return Trade.map[id];
}

return Trade.OTHER;
},

getIdFromTrade: function getIdFromTrade(trade) {
for (var id in Trade.map) {
if (Trade.map[id] === trade) {
return id;
}
}

return '';
},

getTrade: function (type) {

if (this.hasOwnProperty(type)) {
if (Trade.hasOwnProperty(type)) {
return Trade[type];
}

Expand Down
32 changes: 0 additions & 32 deletions lib/tradeConverter.js

This file was deleted.

16 changes: 16 additions & 0 deletions test/model/tradeTest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var chai = require('chai');
var should = chai.should();
var expect = chai.expect;
var Trade = require('../../lib/model/trade').Trade;

describe('trade enum test', function () {
Expand Down Expand Up @@ -28,4 +29,19 @@ describe('trade enum test', function () {
done();
});


it('should get trade from id', function (done) {
var trade = Trade.getTradeFromId('5602c71013287705788b4567');

expect(trade).to.be.equal(Trade.HAIRDRESSING);
done();
});

it('should get id from trade', function (done) {
var id = Trade.getIdFromTrade(Trade.PRIVATE_MEDIC_DENTAL);

expect(id).to.be.equal('5602c71013287705788b4568');
done();
});

});
21 changes: 0 additions & 21 deletions test/tradeConverterTest.js

This file was deleted.

0 comments on commit 9ac0dd1

Please sign in to comment.