Skip to content

Commit f09a3ed

Browse files
committed
tests: add tests for init with null/undefined
1 parent 94d4414 commit f09a3ed

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

test/specs/api/init.js

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,43 @@ var assert = require("chai").assert;
66

77
describe("API: .init - don't not call init when already running.", function () {
88

9-
var instance;
10-
11-
before(function (done) {
9+
it("should know the active State of BrowserSync", function (done) {
1210
browserSync.reset();
13-
var config = {
11+
browserSync({
1412
logLevel: "silent",
1513
open: false
16-
};
17-
18-
instance = browserSync(config, function () {
14+
}, function (err, bs) {
15+
var spy = require("sinon").spy(console, "log");
16+
browserSync({server: "test/fixtures"});
17+
var arg = spy.getCall(0).args[0];
18+
assert.include(arg, "browserSync.create().init()");
19+
console.log.restore();
20+
bs.cleanup();
1921
done();
2022
});
2123
});
22-
23-
after(function () {
24-
instance.cleanup();
24+
it("should init with null as second param", function (done) {
25+
browserSync.reset();
26+
var bs = browserSync({
27+
logLevel: "silent",
28+
open: false
29+
}, null);
30+
bs.emitter.on("service:running", function () {
31+
assert.ok(bs.instance.options.get("urls"));
32+
bs.cleanup();
33+
done();
34+
});
2535
});
26-
27-
it("should know the active State of BrowserSync", function () {
28-
var spy = require("sinon").spy(console, "log");
29-
browserSync({server: "test/fixtures"});
30-
var arg = spy.getCall(0).args[0];
31-
assert.include(arg, "browserSync.create().init()");
32-
console.log.restore();
36+
it("should init with undefined as second param", function (done) {
37+
browserSync.reset();
38+
var bs = browserSync({
39+
logLevel: "silent",
40+
open: false
41+
}, undefined);
42+
bs.emitter.on("service:running", function () {
43+
assert.ok(bs.instance.options.get("urls"));
44+
bs.cleanup();
45+
done();
46+
});
3347
});
3448
});

0 commit comments

Comments
 (0)