mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2026-03-12 03:58:40 +01:00
Added more tests
This commit is contained in:
parent
02aea484a0
commit
0ffd48cef5
3 changed files with 67 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
|||
$juci.module("core")
|
||||
JUCI.app
|
||||
.directive("luciInputPort", function () {
|
||||
var plugin_root = $juci.module("core").plugin_root;
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
|
||||
|
||||
require("../../../../tests/lib-juci");
|
||||
require("./luci.input.port");
|
||||
|
||||
describe("luciInputPortController", function(){
|
||||
var $scope;
|
||||
var IP = "192.168.1.1";
|
||||
beforeEach(function() {
|
||||
$scope = { model: "100-300", portRange: 0 };
|
||||
controller("luciInputPortController", $scope);
|
||||
});
|
||||
it("should correctly read port range from model", function(){
|
||||
["1-10", "100-300", "1-4000"].map(function(range){
|
||||
$scope.portRange = 1;
|
||||
$scope.model = range;
|
||||
var parts = range.split("-");
|
||||
//console.log(JSON.stringify($scope));
|
||||
expect($scope.startPort).to.be(parts[0]);
|
||||
expect($scope.endPort).to.be(parts[1]);
|
||||
});
|
||||
});
|
||||
it("should not allow invalid port ranges", function(){
|
||||
["0-300", "1-100000", "200000-1", "10-1", "300000-400000"].map(function(range){
|
||||
$scope.portRange = 1;
|
||||
$scope.model = range;
|
||||
expect($scope.startPort).to.be("");
|
||||
expect($scope.endPort).to.be("");
|
||||
});
|
||||
});
|
||||
it("should not allow single ports out of range", function(){
|
||||
["0", "100000", "-10000", "-3000"].map(function(range){
|
||||
$scope.portRange = 0;
|
||||
$scope.model = range;
|
||||
expect($scope.port).to.be("");
|
||||
});
|
||||
});
|
||||
it("should not allow negative numbers that look like port ranges", function(){
|
||||
["-10000", "-3000"].map(function(range){
|
||||
$scope.portRange = 1;
|
||||
$scope.model = range;
|
||||
expect($scope.port).to.be("");
|
||||
expect($scope.startPort).to.be("");
|
||||
expect($scope.endPort).to.be("");
|
||||
});
|
||||
});
|
||||
it("should update port range when values change", function(){
|
||||
[["11", "35"], ["200", "400"]].map(function(parts){
|
||||
$scope.portRange = 1;
|
||||
$scope.startPort = parts[0];
|
||||
$scope.endPort = parts[1];
|
||||
expect($scope.model).to.be(parts[0]+"-"+parts[1]);
|
||||
});
|
||||
});
|
||||
it("should not allow invalid numbers to be entered in port range", function(){
|
||||
[["0", "1"], ["-1", "30"], ["100000", "400000"]].map(function(parts){
|
||||
$scope.portRange = 1;
|
||||
$scope.startPort = parts[0];
|
||||
$scope.endPort = parts[1];
|
||||
expect($scope.model).to.be("");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -110,7 +110,9 @@ function JUCIMock(){
|
|||
console.log("$scope.apply");
|
||||
}
|
||||
scope.$watch = function(name, fn){
|
||||
global.watch(this, name, fn);
|
||||
global.watch(this, name, function(){
|
||||
fn(this[name]);
|
||||
});
|
||||
}
|
||||
var args = annotate(ctrl).map(function(x){
|
||||
switch(x){
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue