Skip to content

Commit

Permalink
Avoid using "should in test"
Browse files Browse the repository at this point in the history
  • Loading branch information
zuazo committed Nov 15, 2014
1 parent f560fd2 commit d287579
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 72 deletions.
8 changes: 4 additions & 4 deletions test/adapters/helpers/conversions.js
Expand Up @@ -36,13 +36,13 @@ describe("conversions", function() {
var param = value[0];
var javaClass = value[1];

it("should return \"" + javaClass + "\" for argument value \"" + param + "\" and typeof \"" + typeof param + "\"", function() {
it("returns \"" + javaClass + "\" for argument value \"" + param + "\" and typeof \"" + typeof param + "\"", function() {
assert.strictEqual(conversions.v8ToJavaClass(param), javaClass);
});

});

it("should throw an exception when the object cannot be converted", function() {
it("throws an exception when the object cannot be converted", function() {
assert.throws(
function() {
conversions.v8ToJavaClass(undefined);
Expand All @@ -65,7 +65,7 @@ describe("conversions", function() {
"boolean",
"char"
].forEach(function(className) {
it("should return true for \"" + className + "\"", function() {
it("returns true for \"" + className + "\"", function() {
assert.strictEqual(conversions.isJavaPrimitiveClass(className), true);
});
});
Expand All @@ -82,7 +82,7 @@ describe("conversions", function() {
"java.lang.Object",
java.newInstanceSync("javax.management.Attribute", "name", "value").getClassSync().getNameSync()
].forEach(function(className) {
it("should return false for \"" + className + "\"", function() {
it("returns false for \"" + className + "\"", function() {
assert.strictEqual(conversions.isJavaPrimitiveClass(className), false);
});
});
Expand Down
12 changes: 6 additions & 6 deletions test/adapters/helpers/jmxServiceUrlBuilder.js
Expand Up @@ -6,37 +6,37 @@ var assert = require("assert"),

describe("JmxServiceUrlBuilder", function() {

it("should accept service name as first argument", function() {
it("accepts service name as first argument", function() {
var service = JmxServiceUrlBuilder("service:jmx:rmi://jndi/rmi://localhost:3000/jmxrmi");
assert.strictEqual(service.getClassSync().getNameSync(), "javax.management.remote.JMXServiceURL");
assert.strictEqual(service.toStringSync(), "service:jmx:rmi://jndi/rmi://localhost:3000/jmxrmi");
});

it("should accept host name and port as arguments", function() {
it("accepts host name and port as arguments", function() {
var service = JmxServiceUrlBuilder("localhost", 3000);
assert.strictEqual(service.getClassSync().getNameSync(), "javax.management.remote.JMXServiceURL");
assert.strictEqual(service.toStringSync(), "service:jmx:rmi://localhost:3000/jndi/rmi://localhost:3000/jmxrmi");
});

it("should accept host name and port in string form as arguments", function() {
it("accepts host name and port in string form as arguments", function() {
var service = JmxServiceUrlBuilder("localhost", "3000");
assert.strictEqual(service.getClassSync().getNameSync(), "javax.management.remote.JMXServiceURL");
assert.strictEqual(service.toStringSync(), "service:jmx:rmi://localhost:3000/jndi/rmi://localhost:3000/jmxrmi");
});

it("should accept protocol as third argument", function() {
it("accepts protocol as third argument", function() {
var service = JmxServiceUrlBuilder("localhost", 3000, "proto1");
assert.strictEqual(service.getClassSync().getNameSync(), "javax.management.remote.JMXServiceURL");
assert.strictEqual(service.toStringSync(), "service:jmx:proto1://localhost:3000/jndi/proto1://localhost:3000/jmxproto1");
});

it("should accept urlPath as fourth argument", function() {
it("accepts urlPath as fourth argument", function() {
var service = JmxServiceUrlBuilder("localhost", 3000, "rmi", "/myUrl");
assert.strictEqual(service.getClassSync().getNameSync(), "javax.management.remote.JMXServiceURL");
assert.strictEqual(service.toStringSync(), "service:jmx:rmi://localhost:3000/myUrl");
});

it("should throw an exception when the first argument is not a string", function() {
it("throws an exception when the first argument is not a string", function() {
assert.throws(
function() {
JmxServiceUrlBuilder(null);
Expand Down
6 changes: 3 additions & 3 deletions test/adapters/javaReflection.js
Expand Up @@ -20,7 +20,7 @@ describe("JavaReflection", function() {
});
}

it("should be able to call java methods with no arguments", function(done) {
it("is able to call java methods with no arguments", function(done) {
var obj = java.newInstanceSync("javax.management.Attribute", "attributeName1", "value1");
var paramsClass = [];
var params = [];
Expand All @@ -31,7 +31,7 @@ describe("JavaReflection", function() {
});
});

it("should be able to call java methods with arguments", function(done) {
it("is able to call java methods with arguments", function(done) {
var obj1 = java.newInstanceSync("javax.management.Attribute", "attributeName1", "value1");
var obj2 = java.newInstanceSync("javax.management.Attribute", "attributeName2", "value2");
var paramsClass = [ "java.lang.Object" ];
Expand All @@ -43,7 +43,7 @@ describe("JavaReflection", function() {
});
});

it("should emit an error when the object method does not exist", function(done) {
it("emits an error when the object method does not exist", function(done) {
var obj1 = java.newInstanceSync("javax.management.Attribute", "attributeName1", "value1");
var paramsClass = [];
var params = [];
Expand Down
22 changes: 11 additions & 11 deletions test/adapters/mbeanServerConnection.js
Expand Up @@ -28,12 +28,12 @@ describe("MBeanServerConnection", function() {
};
});

it("should receive URI as argument", function() {
it("receives URI as argument", function() {
var mbeanServerConnection = new MBeanServerConnection("uri2");
assert.strictEqual(mbeanServerConnection.jmxServiceUrl, "uri2");
});

it("should subscribe to javaReflector error events", function() {
it("subscribes to javaReflector error events", function() {
mbeanServerConnection.javaReflection.emit("error");
assert.deepEqual(emitted, [ "error" ]);
});
Expand All @@ -42,7 +42,7 @@ describe("MBeanServerConnection", function() {

describe("#connect", function() {

it("should emit connect event when connected", function(done) {
it("emits connect event when connected", function(done) {
mbeanServerConnection.emit = function(ev) {
if (ev === "connect") {
done();
Expand All @@ -51,12 +51,12 @@ describe("MBeanServerConnection", function() {
mbeanServerConnection.connect();
});

it("should receive URI as argument", function() {
it("receives URI as argument", function() {
mbeanServerConnection.connect("uri2");
assert.strictEqual(mbeanServerConnection.jmxServiceUrl, "uri2");
});

it("should generate authentication credentials when required", function(done) {
it("generates authentication credentials when required", function(done) {
mbeanServerConnection.username = "username1";
mbeanServerConnection.password = "password2";
mbeanServerConnection.JMXConnectorFactory.connect = function(jmxServiceUrl, map, callback) {
Expand All @@ -79,14 +79,14 @@ describe("MBeanServerConnection", function() {
};
});

it("should try to close de connection when called", function(done) {
it("tries to close de connection when called", function(done) {
mbeanServerConnection.jmxConnector.close = function() {
done();
};
mbeanServerConnection.close();
});

it("should emit disconnect event when connected", function(done) {
it("emits disconnect event when connected", function(done) {
mbeanServerConnection.emit = function(ev) {
if (ev === "disconnect") {
done();
Expand Down Expand Up @@ -119,7 +119,7 @@ describe("MBeanServerConnection", function() {
};
}

it("should return the correct MBeans", function(done) {
it("returns the correct MBeans", function(done) {
testOnConnected(function() {
stubQueryMBeans();
mbeanServerConnection.queryMBeans(null, "MBean1:type=MBean1", function(instance, callback) {
Expand All @@ -129,7 +129,7 @@ describe("MBeanServerConnection", function() {
});
});

it("should accept empty query", function(done) {
it("accepts empty query", function(done) {
testOnConnected(function() {
stubQueryMBeans();
mbeanServerConnection.queryMBeans(null, null, function(instance, callback) {
Expand All @@ -139,7 +139,7 @@ describe("MBeanServerConnection", function() {
});
});

it("should call the final callback function when done", function(done) {
it("calls the final callback function when done", function(done) {
testOnConnected(function() {
stubQueryMBeans();
mbeanServerConnection.queryMBeans(null, "MBean1:type=MBean1", function(instance,callback) {
Expand All @@ -151,7 +151,7 @@ describe("MBeanServerConnection", function() {
});
});

it("should emit error on premature disconnections", function(done) {
it("emits error on premature disconnections", function(done) {
testOnConnected(function() {
mbeanServerConnection.emit = function(ev, err) {
if (ev === "error" && /Premature disconnect/.test(err)) {
Expand Down
10 changes: 5 additions & 5 deletions test/client.js
Expand Up @@ -7,12 +7,12 @@ describe("Client", function() {

describe("#Client", function() {

it("should return a Client object passing the correct arguments", function() {
it("returns a Client object passing the correct arguments", function() {
var client = new Client("localhost", 3000);
assert.ok(client instanceof Client);
});

it("should throw the correct exception when no argument is passed", function() {
it("throws the correct exception when no argument is passed", function() {
assert.throws(
function() {
new Client();
Expand All @@ -21,13 +21,13 @@ describe("Client", function() {
);
});

it("should accept username and password as arguments", function() {
it("accepts username and password as arguments", function() {
var client = new Client("localhost", 3000, undefined, undefined, "username", "password");
assert.strictEqual(client.username, "username");
assert.strictEqual(client.password, "password");
});

describe("should subscribe to JavaJmx events", function() {
describe("subscribes to JavaJmx events", function() {
var client;
var emitted;
beforeEach(function() {
Expand All @@ -53,7 +53,7 @@ describe("Client", function() {

});

describe("Methods that should call javaJmx directly and with the correct arguments", function() {
describe("Methods that calls javaJmx directly and with the correct arguments", function() {
this.timeout(100);
var client;
var method;
Expand Down
20 changes: 10 additions & 10 deletions test/helpers/error.js
Expand Up @@ -12,7 +12,7 @@ describe("error", function() {

describe("#debug", function() {

it("should have an empty/nop debug function by default", function() {
it("has an empty/nop debug function by default", function() {
var debug;

var old_node_debug = process.env.NODE_DEBUG;
Expand All @@ -27,7 +27,7 @@ describe("error", function() {
assert.strictEqual(debug(), undefined);
});

it("should not print to console by default", function() {
it("does not print to console by default", function() {
var old_node_debug = process.env.NODE_DEBUG;
process.env.NODE_DEBUG = "other-node-module";
var debug = require_debug_reload();
Expand All @@ -53,7 +53,7 @@ describe("error", function() {
assert.strictEqual(count, 0);
});

it("should print to console when debug is enabled", function() {
it("prints to console when debug is enabled", function() {
var old_node_debug = process.env.NODE_DEBUG;
process.env.NODE_DEBUG = "jmx";
var debug = require_debug_reload();
Expand Down Expand Up @@ -82,7 +82,7 @@ describe("error", function() {

});

it("should return without error when console.error does not exist", function() {
it("returns without error when console.error does not exist", function() {
var old_node_debug = process.env.NODE_DEBUG;
process.env.NODE_DEBUG = "jmx";
var debug = require_debug_reload();
Expand All @@ -100,11 +100,11 @@ describe("error", function() {

describe("when no object is passed as argument", function() {

it("should return false when there is no error", function() {
it("returns false when there is no error", function() {
assert.strictEqual(checkError(undefined, undefined), false);
});

it("should throw an exception when there is an error", function() {
it("throws an exception when there is an error", function() {
assert.throws(
function() {
checkError("One important error", undefined);
Expand All @@ -126,21 +126,21 @@ describe("error", function() {
emitCount = 0;
});

it("should emit no error when there is no error", function() {
it("emits no error when there is no error", function() {
checkError(undefined, obj);
assert.strictEqual(emitCount, 0);
});

it("should emit an error when there is an error", function() {
it("emits an error when there is an error", function() {
checkError("One important error", obj);
assert.strictEqual(emitCount, 1);
});

it("should return false when there is no error", function() {
it("returns false when there is no error", function() {
assert.strictEqual(checkError(undefined, obj), false);
});

it("should return true when there is an error", function() {
it("returns true when there is an error", function() {
assert.strictEqual(checkError("One important error", obj), true);
});

Expand Down

0 comments on commit d287579

Please sign in to comment.