Blame view

test/sms.js 836 Bytes
5ae543453   Adhidarma Hadiwinoto   Report via HTTP
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
  'use strict';
  
  /* global describe it */
  
  require('should');
  
  const sms = require('../lib/sms');
  
  describe('#sms', () => {
      describe('#extract', () => {
          const raw = '+CMGR: "REC UNREAD","+6282210008543",,"19/07/26,13:21:16+28"\r
  sudah bisa?';
          const messageParsed = sms.extract(raw);
  
          it('should return raw correctly', () => {
              messageParsed.raw.should.equal(raw);
          });
  
          it('should return correct metadata', () => {
              messageParsed.metadata.status.should.equal('REC UNREAD');
              messageParsed.metadata.from.should.equal('6282210008543');
              messageParsed.metadata.ts.should.equal('2019-07-26 13:21:16');
          });
  
          it('should return correct message', () => {
              messageParsed.message.should.equal('sudah bisa?');
          });
      });
  });