Skip to content

Commit

Permalink
Merge pull request #67 from dtex/ledTests
Browse files Browse the repository at this point in the history
Led tests
  • Loading branch information
dtex authored Jul 11, 2020
2 parents cae504e + c56ffa7 commit e152e37
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 33 deletions.
6 changes: 0 additions & 6 deletions docs/led_index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ <h1><span class="name">led/index.js</span></h1>
isRunning: false,
value: 0,
direction: 1,
mode: null,
interval: null
};

Expand Down Expand Up @@ -170,11 +169,6 @@ <h1><span class="name">led/index.js</span></h1>
return this.#state.value;
}
},
mode: {
get: function() {
return this.#state.mode;
}
},
isOn: {
get: function() {
return !!this.#state.value;
Expand Down
26 changes: 13 additions & 13 deletions docs/module-j5e_led-LED.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ <h5>Parameters</h5>
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-58">line 58</a></p>
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-57">line 57</a></p>
</div>
</div>

Expand Down Expand Up @@ -254,7 +254,7 @@ <h4 id="on" class="function public"><span class="name">on</span><span class="sig
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-131">line 131</a></p>
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-125">line 125</a></p>
</div>
</div>

Expand Down Expand Up @@ -311,7 +311,7 @@ <h4 id="off" class="function public"><span class="name">off</span><span class="s
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-152">line 152</a></p>
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-146">line 146</a></p>
</div>
</div>

Expand Down Expand Up @@ -368,7 +368,7 @@ <h4 id="toggle" class="function public"><span class="name">toggle</span><span cl
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-173">line 173</a></p>
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-167">line 167</a></p>
</div>
</div>

Expand Down Expand Up @@ -450,7 +450,7 @@ <h5>Parameters</h5>
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-188">line 188</a></p>
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-182">line 182</a></p>
</div>
</div>

Expand Down Expand Up @@ -525,7 +525,7 @@ <h5>Parameters</h5>
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-222">line 222</a></p>
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-216">line 216</a></p>
</div>
</div>

Expand Down Expand Up @@ -600,7 +600,7 @@ <h5>Parameters</h5>
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-241">line 241</a></p>
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-235">line 235</a></p>
</div>
</div>

Expand Down Expand Up @@ -697,7 +697,7 @@ <h5>Parameters</h5>
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-262">line 262</a></p>
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-256">line 256</a></p>
</div>
</div>

Expand Down Expand Up @@ -786,7 +786,7 @@ <h5>Parameters</h5>
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-314">line 314</a></p>
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-308">line 308</a></p>
</div>
</div>

Expand Down Expand Up @@ -876,7 +876,7 @@ <h5>Parameters</h5>
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-334">line 334</a></p>
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-328">line 328</a></p>
</div>
</div>

Expand Down Expand Up @@ -965,7 +965,7 @@ <h5>Parameters</h5>
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-353">line 353</a></p>
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-347">line 347</a></p>
</div>
</div>

Expand Down Expand Up @@ -1047,7 +1047,7 @@ <h5>Parameters</h5>
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-401">line 401</a></p>
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-395">line 395</a></p>
</div>
</div>

Expand Down Expand Up @@ -1108,7 +1108,7 @@ <h4 id="stop" class="function public"><span class="name">stop</span><span class=
<div class="form-group">
<label class="col-sm-3 control-label">Source</label>
<div class="col-sm-9">
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-431">line 431</a></p>
<p class="form-control-static"><a href="led_index.js.html">led/index.js</a>, <a href="led_index.js.html#line-425">line 425</a></p>
</div>
</div>

Expand Down
6 changes: 0 additions & 6 deletions lib/led/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class LED {
isRunning: false,
value: 0,
direction: 1,
mode: null,
interval: null
};

Expand Down Expand Up @@ -74,11 +73,6 @@ class LED {
return this.#state.value;
}
},
mode: {
get: function() {
return this.#state.mode;
}
},
isOn: {
get: function() {
return !!this.#state.value;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "j5e",
"version": "0.4.6",
"version": "0.4.7",
"description": "j5e is a device framework built for ECMA TC-53's IO pattern",
"main": "index.js",
"exports": {
Expand Down
151 changes: 144 additions & 7 deletions test/led.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,74 @@ describe("LED - Digital", function() {
});

describe("Properties", function() {
// describe('someProperty', function() {
// it('should do a thing base on the property value', async function() {
// ...
// });
// [ all other tests related to someProperty ]
// });
// [ All other properties, each with it's own describe ]

describe("value", function() {

it("should return the current value", async function() {
const led = await new LED({
pin: 12,
io: Digital
});

led.on(1);
assert.equal(led.value, 1);

});
});

describe("isOn", function() {

it("should return true if the LED is on", async function() {
const led = await new LED({
pin: 12,
io: Digital
});

led.on();
assert.equal(led.isOn, true);

led.off();
assert.equal(led.isOn, false);

});
});

describe("isRunning", function() {

it("should return true if the LED is blinking", async function() {
const led = await new LED({
pin: 12,
io: Digital
});

assert.equal(led.isRunning, false);

led.blink();
assert.equal(led.isRunning, true);

led.stop();
assert.equal(led.isRunning, false);

});

it("should return true if the LED is pulsing", async function() {
const led = await new LED({
pin: 12,
io: Digital
});

assert.equal(led.isRunning, false);

led.pulse();
assert.equal(led.isRunning, true);

led.stop();
assert.equal(led.isRunning, false);

});

});

});

describe("Methods", function() {
Expand Down Expand Up @@ -166,6 +227,82 @@ describe("LED - PWM", function() {
assert.equal(led.HIGH, 1023);

});

});

describe("Properties", function() {

describe("value", function() {

it("should return the current value", async function() {
const led = await new LED({
pin: 12,
io: PWM
});

led.on();
assert.equal(led.value, 1023);

led.brightness(512);
assert.equal(led.value, 512);


});
});

describe("isOn", function() {

it("should return true if the LED is on", async function() {
const led = await new LED({
pin: 12,
io: Digital
});

led.on();
assert.equal(led.isOn, true);

led.off();
assert.equal(led.isOn, false);

});
});

describe("isRunning", function() {

it("should return true if the LED is blinking", async function() {
const led = await new LED({
pin: 12,
io: Digital
});

assert.equal(led.isRunning, false);

led.blink();
assert.equal(led.isRunning, true);

led.stop();
assert.equal(led.isRunning, false);

});

it("should return true if the LED is pulsing", async function() {
const led = await new LED({
pin: 12,
io: Digital
});

assert.equal(led.isRunning, false);

led.pulse();
assert.equal(led.isRunning, true);

led.stop();
assert.equal(led.isRunning, false);

});

});

});

describe("Methods", function() {
Expand Down

0 comments on commit e152e37

Please sign in to comment.