test.js
1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"use strict";
const should = require("should");
const reverseParser = require('./reverse-parser');
describe('#reverse-parser', function() {
describe('#parseMessage', function() {
describe('test with valid message', function () {
const msg = 'IDPEL:2017-01-30 16:58:19,1BNS2550C539F5B40545,ERRY-FEBRIANTO,32024560198,32024560198,R1M/900,Rp ,kWh 24.40,Stroom/Token 4260-5779-4249-2925-9618,SUKSES';
const data = reverseParser.parseMessage(msg);
it('should to have correct nama pelanggan', function() {
data.namapel.should.equal('ERRY-FEBRIANTO');
})
it('should to have correct tarif daya', function() {
data.tarifdaya.should.equal('R1M/900VA');
})
it('should to have correct tarif', function() {
data.tarif.should.equal('R1M');
})
it('should to have correct daya', function() {
data.daya.should.equal('900VA');
})
it('should to have correct jumlah kwh', function() {
data.jumlahkwh.should.equal('24.40');
})
})
describe('test with invalid message', function () {
const msg = '';
const data = reverseParser.parseMessage(msg);
it('should to have correct nama pelanggan', function() {
should(data.namapel).not.be.ok();
})
it('should to have correct tarif daya', function() {
should(data.tarifdaya).not.be.ok();
})
it('should to have correct tarif', function() {
should(data.tarif).not.be.ok();
})
it('should to have correct daya', function() {
should(data.daya).not.be.ok();
})
it('should to have correct jumlah kwh', function() {
should(data.jumlahkwh).not.be.ok();
})
})
})
})