Skip to content

Commit

Permalink
Add parseCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
lgaticaq committed Mar 15, 2016
1 parent 22ee78b commit 07d2711
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,17 @@ const parse = (raw, options = {}) => {
});
};

const parseCommand = (data) => {
let command = null;
if (data.device === 'tz') {
command = tz.parseCommand(data);
}
return command;
};

module.exports = {
getImei: getImei,
setCache: setCache,
parse: parse
parse: parse,
parseCommand: parseCommand
};
10 changes: 10 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,14 @@ describe('tracking-parzer', () => {
done(err);
});
});

it('should return TZ raw command', () => {
const data = {
instruction: 'reboot',
password: 897463,
device: 'tz'
};
const raw = tracking.parseCommand(data);
expect(raw).to.eql('*897463,991#');
});
});

0 comments on commit 07d2711

Please sign in to comment.