Skip to content

Commit

Permalink
Move node list generation tests into new file
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelistik committed Dec 3, 2015
1 parent 1056872 commit 91b26e3
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 117 deletions.
118 changes: 118 additions & 0 deletions spec/nodeListTransformSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
var assert = require("chai").assert
var nodeListTransform = require("../www/js/nodeListTransform.js")

describe("Wifi Analyzer alias list", function () {
it("should list a simple node", function () {
var result = nodeListTransform({
nodes: {
c423523487: {
nodeinfo: {
hostname: "host-one",
network: {
mesh: {
bat0: {
interfaces: {
wireless: ["99:ee:ee:ee:01:01"]
}
}
}
}
}
}
}
});
assert.include(result, "99:ee:ee:ee:01:01|host-one (99:ee:ee:ee:01:01)");
});

it("should filter out nodes without hostname", function () {
var result = nodeListTransform({
nodes: {
c423523487: {
nodeinfo: {
network: {
mesh: {
bat0: {
interfaces: {
wireless: ["99:ee:ee:ee:01:01"]
}
}
}
}
}
}
}
});
assert.notInclude(result.join(), "undefined");
});

it("should filter out nodes without interfaces", function () {
var result = nodeListTransform({
nodes: {
c423523487: {
nodeinfo: {
hostname: "host-one",
network: {
mesh: {
bat0: {}
}
}
}
}
}
});

assert.notInclude(result.join(), "undefined");
});

it("should list a node with multiple macs", function () {
var result = nodeListTransform({
nodes: {
c423523487: {
nodeinfo: {
hostname: "host-one",
network: {
mesh: {
bat0: {
interfaces: {
wireless: [
"99:ee:ee:ee:01:01",
"11:ee:ee:ee:01:01"
]
}
}
}
}
}
}
}
});

assert.include(result, "99:ee:ee:ee:01:01|host-one (99:ee:ee:ee:01:01)");
assert.include(result, "11:ee:ee:ee:01:01|host-one (11:ee:ee:ee:01:01)");
});

it("should add the next and previous mac", function () {
var result = nodeListTransform({
nodes: {
c423523487: {
nodeinfo: {
hostname: "host-one",
network: {
mesh: {
bat0: {
interfaces: {
wireless: ["99:ee:ee:ee:01:01"]
}
}
}
}
}
}
}
});

assert.include(result, "99:ee:ee:ee:01:01|host-one (99:ee:ee:ee:01:01)");
assert.include(result, "99:ef:ee:ee:01:01|host-one (99:ef:ee:ee:01:01)");
assert.include(result, "99:ed:ee:ee:01:01|host-one (99:ed:ee:ee:01:01)");
});
});
117 changes: 0 additions & 117 deletions spec/test.js
Original file line number Diff line number Diff line change
@@ -1,127 +1,10 @@
var rewire = require("rewire");
var assert = require("chai").assert
var sinon = require("sinon")
var nodeListTransform = require("../www/js/nodeListTransform.js")
var models = rewire("../www/js/models.js");
var FfAliasList = rewire("../www/js/models.js").FfAliasList;
var domainListFromFreifunkApi = rewire("../www/js/domainListFromFreifunkApi");

describe("Wifi Analyzer alias list", function () {
it("should list a simple node", function () {
var result = nodeListTransform({
nodes: {
c423523487: {
nodeinfo: {
hostname: "host-one",
network: {
mesh: {
bat0: {
interfaces: {
wireless: ["99:ee:ee:ee:01:01"]
}
}
}
}
}
}
}
});
assert.include(result, "99:ee:ee:ee:01:01|host-one (99:ee:ee:ee:01:01)");
});

it("should filter out nodes without hostname", function () {
var result = nodeListTransform({
nodes: {
c423523487: {
nodeinfo: {
network: {
mesh: {
bat0: {
interfaces: {
wireless: ["99:ee:ee:ee:01:01"]
}
}
}
}
}
}
}
});
assert.notInclude(result.join(), "undefined");
});

it("should filter out nodes without interfaces", function () {
var result = nodeListTransform({
nodes: {
c423523487: {
nodeinfo: {
hostname: "host-one",
network: {
mesh: {
bat0: {}
}
}
}
}
}
});

assert.notInclude(result.join(), "undefined");
});

it("should list a node with multiple macs", function () {
var result = nodeListTransform({
nodes: {
c423523487: {
nodeinfo: {
hostname: "host-one",
network: {
mesh: {
bat0: {
interfaces: {
wireless: [
"99:ee:ee:ee:01:01",
"11:ee:ee:ee:01:01"
]
}
}
}
}
}
}
}
});

assert.include(result, "99:ee:ee:ee:01:01|host-one (99:ee:ee:ee:01:01)");
assert.include(result, "11:ee:ee:ee:01:01|host-one (11:ee:ee:ee:01:01)");
});

it("should add the next and previous mac", function () {
var result = nodeListTransform({
nodes: {
c423523487: {
nodeinfo: {
hostname: "host-one",
network: {
mesh: {
bat0: {
interfaces: {
wireless: ["99:ee:ee:ee:01:01"]
}
}
}
}
}
}
}
});

assert.include(result, "99:ee:ee:ee:01:01|host-one (99:ee:ee:ee:01:01)");
assert.include(result, "99:ef:ee:ee:01:01|host-one (99:ef:ee:ee:01:01)");
assert.include(result, "99:ed:ee:ee:01:01|host-one (99:ed:ee:ee:01:01)");
});
});

describe("App view model", function () {
var app;

Expand Down

0 comments on commit 91b26e3

Please sign in to comment.