1 | var expect = require("expect.js"),
|
2 | qrcode = require('./../lib/main'),
|
3 | sinon = require("sinon");
|
4 |
|
5 | describe('in the main module', function() {
|
6 | describe("the generate method", function () {
|
7 | describe("when not providing a callback", function () {
|
8 | beforeEach(function () {
|
9 | sinon.stub(console, "log");
|
10 | });
|
11 |
|
12 | afterEach(function () {
|
13 | sinon.sandbox.restore();
|
14 | console.log.reset();
|
15 | });
|
16 |
|
17 | it("logs to the console", function () {
|
18 | qrcode.generate("test");
|
19 | expect(console.log.called).to.be(true);
|
20 | });
|
21 | });
|
22 |
|
23 | describe("when providing a callback", function () {
|
24 | it("will call the callback", function () {
|
25 | var cb = sinon.spy();
|
26 | qrcode.generate("test", cb);
|
27 | expect(cb.called).to.be(true);
|
28 | });
|
29 |
|
30 | it("will not call the console.log method", function () {
|
31 | qrcode.generate("test", sinon.spy());
|
32 | expect(console.log.called).to.be(false);
|
33 | });
|
34 | });
|
35 | });
|
36 | });
|