Skip to content

Commit

Permalink
fix(parser): Fix isTz
Browse files Browse the repository at this point in the history
  • Loading branch information
lgaticaq committed Sep 6, 2016
1 parent 4335ca6 commit c61e416
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const parse = raw => {

const isTz = raw => {
const pattern = Object.keys(patterns).map(x => patterns[x]).find(x => x.test(raw.toString()));
return pattern !== 'undefined';
return typeof pattern !== 'undefined';
};

const getRebootCommand = password => `*${password || '000000'},991#`;
Expand Down
6 changes: 6 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ describe('tz-parzer', () => {
expect(data).to.be.a.true;
});

it('should return true for valid tz data', () => {
const raw = new Buffer('$$A138,862170013556541,AAA,35,7.092076,79.960473,140412132808,A,10,9,57,275,1,14,5783799,7403612,413|1|F6E0|3933,0000,000B|0009||02D8|0122,*EE\r\n');
const data = tz.isTz(raw);
expect(data).to.be.a.false;
});

it('should return raw command set password', () => {
const data = {
instruction: 'set_password',
Expand Down

0 comments on commit c61e416

Please sign in to comment.