Skip to content

Instantly share code, notes, and snippets.

@traverse
Last active October 12, 2016 09:51
Show Gist options
  • Save traverse/51e26d2dfb9b935a71df to your computer and use it in GitHub Desktop.
Save traverse/51e26d2dfb9b935a71df to your computer and use it in GitHub Desktop.
Learning unit testing with Mocha
var strings = require("./strings");
var assert = require("assert");
describe("strings module", function() {
it("should dash separate camelCase string with one capital", function() {
var camel = "sampleString";
var expected = "sample-string";
var dashed = strings.dashSeparated(camel);
assert.equal(dashed, expected);
});
it("should dash separate camelCase string with multiple capitals", function() {
var camel = "sampleStringWithMultipleCapitals";
var expected = "sample-string-with-multiple-capitals";
var dashed = strings.dashSeparated(camel);
assert.equal(dashed, expected);
});
it("should dash separate camelCase string with numbers", function() {
var camel = "sampleString1234";
var expected = "sample-string-1234";
var dashed = strings.dashSeparated(camel);
assert.equal(dashed, expected);
});
it("should dash seperate camelCase string with numbers in the middle", function() {
var camel = "sample1234String";
var expected = "sample-1234-string";
var dashed = strings.dashSeparated(camel);
assert.equal(dashed, expected);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment