Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Commit a6733a6

Browse files
committed
add base symbol service
1 parent 63d2349 commit a6733a6

File tree

5 files changed

+100
-3
lines changed

5 files changed

+100
-3
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export default class BaseSymbolService {
2+
getVehicleSymbol() {
3+
throw new Error('Not implemented');
4+
}
5+
6+
getPriceSymbol() {
7+
throw new Error('Not implemented');
8+
}
9+
10+
getTripDistanceSymbol() {
11+
throw new Error('Not implemented');
12+
}
13+
14+
getDurationSymbol() {
15+
throw new Error('Not implemented');
16+
}
17+
18+
getSurgeSymbol() {
19+
throw new Error('Not implemented');
20+
}
21+
22+
getNotApplicableSymbol() {
23+
throw new Error('Not implemented');
24+
}
25+
26+
getSurgePresentSymbol() {
27+
throw new Error('Not implemented');
28+
}
29+
30+
getDestinationSymbol() {
31+
throw new Error('Not implemented');
32+
}
33+
34+
getOriginSymbol() {
35+
throw new Error('Not implemented');
36+
}
37+
38+
getMaximumDistanceSymbol() {
39+
throw new Error('Not implemented');
40+
}
41+
}

src/services/symbols/EmojiService.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import emoji from 'node-emoji';
22

3+
import BaseSymbolService from './BaseSymbolService';
34

4-
export default class EmojiService {
5+
6+
export default class EmojiService extends BaseSymbolService {
57
getVehicleSymbol() {
68
return emoji.get('oncoming_automobile');
79
}

src/services/symbols/SymbolService.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { List } from 'immutable';
22

3+
import BaseSymbolService from './BaseSymbolService';
34
import EmojiService from './EmojiService';
45
import TextSymbolService from './TextSymbolService';
56

6-
export default class SymbolService {
7+
export default class SymbolService extends BaseSymbolService {
78
constructor() {
9+
super();
810
this.client = SymbolService.areEmojisSupported() ?
911
new EmojiService() :
1012
new TextSymbolService();

src/services/symbols/TextSymbolService.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export default class TextSymbolService {
1+
import BaseSymbolService from './BaseSymbolService';
2+
3+
export default class TextSymbolService extends BaseSymbolService {
24
getVehicleSymbol() {
35
return 'Vehicle';
46
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import chai from 'chai';
2+
3+
import BaseSymbolService from '../../../src/services/symbols/BaseSymbolService';
4+
5+
const expect = chai.expect;
6+
7+
8+
describe('BaseSymbolService Test', () => {
9+
const service = new BaseSymbolService();
10+
11+
it('should throw when getting vehicle symbol', () => {
12+
expect(() => service.getVehicleSymbol()).to.throw(Error);
13+
});
14+
15+
it('should throw when getting price symbol', () => {
16+
expect(() => service.getPriceSymbol()).to.throw(Error);
17+
});
18+
19+
it('should throw when getting trip distance symbol', () => {
20+
expect(() => service.getTripDistanceSymbol()).to.throw(Error);
21+
});
22+
23+
it('should throw when getting duration symbol', () => {
24+
expect(() => service.getDurationSymbol()).to.throw(Error);
25+
});
26+
27+
it('should throw when getting surge symbol', () => {
28+
expect(() => service.getSurgeSymbol()).to.throw(Error);
29+
});
30+
31+
it('should throw when getting not applicable symbol', () => {
32+
expect(() => service.getNotApplicableSymbol()).to.throw(Error);
33+
});
34+
35+
it('should throw when getting surge present symbol', () => {
36+
expect(() => service.getSurgePresentSymbol()).to.throw(Error);
37+
});
38+
39+
it('should throw when getting destination symbol', () => {
40+
expect(() => service.getDestinationSymbol()).to.throw(Error);
41+
});
42+
43+
it('should throw when getting origin symbol', () => {
44+
expect(() => service.getOriginSymbol()).to.throw(Error);
45+
});
46+
47+
it('should throw when getting maximum distance symbol', () => {
48+
expect(() => service.getMaximumDistanceSymbol()).to.throw(Error);
49+
});
50+
});

0 commit comments

Comments
 (0)