forked from alexbain/lirc_node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlirc_node.js
More file actions
83 lines (67 loc) · 2.63 KB
/
lirc_node.js
File metadata and controls
83 lines (67 loc) · 2.63 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
var lirc_node = require('../'),
assert = require('assert'),
sinon = require('sinon'),
q = require('q');
describe('lirc_node', function() {
describe('init', function() {
it('should exist', function() {
assert(lirc_node.init instanceof Function);
});
});
describe("Setting an internal list of Remotes", function() {
describe('#_populateRemotes', function() {
beforeEach(function() {
lirc_node.remotes = {};
});
it('should exist', function() {
assert(lirc_node._populateRemotes instanceof Function);
});
it('should set exports.remotes as an object', function() {
lirc_node._populateRemotes('', '', '');
assert(lirc_node.remotes instanceof Object);
});
it('should set exports.remotes to have keys for a single remote name', function() {
var stderr = "irsend: SonyTV";
lirc_node._populateRemotes('', '', stderr);
assert(Object.keys(lirc_node.remotes).length === 1);
assert(lirc_node.remotes["SonyTV"] instanceof Array);
});
it('should set exports.remotes to have keys for all remote names', function() {
var stderr = "irsend: Yamaha\nirsend: Arizer\nirsend: Microsoft_Xbox360";
lirc_node._populateRemotes('', '', stderr);
assert(Object.keys(lirc_node.remotes).length === 3);
assert(lirc_node.remotes["Yamaha"] instanceof Array);
assert(lirc_node.remotes["Arizer"] instanceof Array);
assert(lirc_node.remotes["Microsoft_Xbox360"] instanceof Array);
});
});
describe('#_populateCommands', function() {
beforeEach(function() {
sinon.stub(lirc_node.irsend, 'list', function() {});
});
afterEach(function() {
lirc_node.remotes = {};
lirc_node.irsend.list.restore();
});
it('should exist', function() {
assert(lirc_node._populateCommands instanceof Function);
});
});
describe('#_populateRemoteCommands', function() {
beforeEach(function() {
lirc_node.remotes = {};
});
it('should exist', function() {
assert(lirc_node._populateRemoteCommands instanceof Function);
});
it('should push commands onto the remote\'s array', function() {
var remote = 'Microsoft_Xbox360';
var stderr = 'irsend: 0000000000000bd7 OpenClose\nirsend: 0000000000000b9b XboxFancyButton';
lirc_node.remotes[remote] = [];
lirc_node._populateRemoteCommands(remote, '', '', stderr);
assert(lirc_node.remotes[remote][0] == 'OpenClose');
assert(lirc_node.remotes[remote][1] == 'XboxFancyButton');
});
});
});
});