Commit 5fe071a7 authored by Jesper Zedlitz's avatar Jesper Zedlitz

Merge branch 'master' into Horst

parents d5cd3009 a02a7106
......@@ -2,7 +2,7 @@
"name": "des-javascript",
"version": "1.0.0",
"scripts": {
"test": "node test/all.js",
"test": "./node_modules/mocha/bin/mocha",
"lint": "./node_modules/.bin/eslint src/*.js"
},
"author": "Jesper Zedlitz",
......@@ -10,11 +10,12 @@
"devDependencies": {
"eslint": "^5.12.1",
"jslint": "^0.12.1",
"mocha": "^7.1.2",
"node-qunit-phantomjs": "^2.0.0",
"phantomjs-prebuilt": "^2.1.16",
"qunit": "^2.6.0"
},
"dependencies": {
"jquery": "^3.3.1"
"jquery": "^3.5.1"
}
}
......@@ -175,3 +175,7 @@ function casifyName(obj) {
obj.saveValue = outValue;
return inValue;
}
exports._test = {
casifyName:casifyName
}
var assert = require('assert');
var qunit = require('node-qunit-phantomjs')
qunit('test/casifyName4.html');
qunit('test/desActivate.html');
qunit('test/Des-Activate.html');
qunit('test/specialCharacters.html');
qunit('test/split.html');
qunit('test/testV1.html');
describe('QUnit tests', function () {
// Capture the output of QUnit to find failing tests.
console.log = function (message) {
if (message.indexOf('Test failed') > -1) {
assert.fail('QUnit test failed.');
}
}
describe('desActivate', function () {
it('should pass QUnit tests', function () {
qunit('test/desActivate.html');
});
});
describe('Des-Activate', function () {
it('should pass QUnit tests', function () {
qunit('test/Des-Activate.html');
});
});
describe('specialCharacters', function () {
it('should pass QUnit tests', function () {
qunit('test/specialCharacters.html');
});
});
describe('split', function () {
it('should pass QUnit tests', function () {
qunit('test/split.html');
});
});
describe('testV1', function () {
it('should pass QUnit tests', function () {
qunit('test/testV1.html');
});
});
});
\ No newline at end of file
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>casifyName4</title>
<link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css">
<script src="../node_modules/qunit/qunit/qunit.js"></script>
<script src="../src/casifyName4.js"></script>
<script>
QUnit.test("casifyName4.simple", function( assert ) {
function casify(s) {
return casifyName({value: s})
}
/**
* Check that the specified input string is casified correctly
* - in unmodified form
* - after it has been converted to lower case
*/
function checkCases(s) {
assert.equal(casifyName({value: s}),s)
assert.equal(casifyName({value: s.toLowerCase()}), s )
}
checkCases("Meyer");
checkCases("Hans-Peter");
checkCases("Kai Uwe");
checkCases("Meyer, Dr.");
});
QUnit.test("casifyName4.unmodified", function( assert ) {
/**
* Assert that the specified input string is returned unmodified.
*
*/
function checkUnmodified(s) {
assert.equal(casifyName({value: s}),s)
}
checkUnmodified("Zedlitz, von");
checkUnmodified("Zedlitz, v.");
checkUnmodified("Frankfurt a. O.");
checkUnmodified("MEYER");
checkUnmodified("HANS-PETER");
checkUnmodified("KAI UWE");
});
QUnit.test("casifyName4.romanNumbers", function( assert ) {
/**
* Assert that the specified input string is returned unmodified.
*
*/
function checkUnmodified(s) {
assert.equal(casifyName({value: s}),s)
}
checkUnmodified("Meyer I");
checkUnmodified("Meyer II");
checkUnmodified("Meyer III");
checkUnmodified("Meyer IV");
checkUnmodified("Meyer V");
});
</script>
</head>
<body>
<div id="qunit"></div>
</body>
</html>
var assert = require('assert');
var casifyName4 = require('../src/casifyName4.js');
describe('casifyName4', function () {
describe('casifyName', function () {
it('should casify simple values corretly', function () {
/**
* Check that the specified input string is casified correctly
* - in unmodified form
* - after it has been converted to lower case
*/
function checkCases(s) {
assert.equal(casifyName4._test.casifyName({value: s}), s);
assert.equal(casifyName4._test.casifyName({value: s.toLowerCase()}), s);
}
checkCases("Meyer");
checkCases("Hans-Peter");
checkCases("Kai Uwe");
checkCases("Meyer, Dr.");
});
it('should leave some values unmodified', function () {
/**
* Assert that the specified input string is returned unmodified.
*
*/
function checkUnmodified(s) {
assert.equal(casifyName4._test.casifyName({value: s}), s);
}
checkUnmodified("Zedlitz, von");
checkUnmodified("Zedlitz, v.");
checkUnmodified("Frankfurt a. O.");
checkUnmodified("MEYER");
checkUnmodified("HANS-PETER");
checkUnmodified("KAI UWE");
});
it('should not mofify roman numbers', function () {
/**
* Assert that the specified input string is returned unmodified.
*
*/
function checkUnmodified(s) {
assert.equal(casifyName4._test.casifyName({value: s}), s);
}
checkUnmodified("Meyer I");
checkUnmodified("Meyer II");
checkUnmodified("Meyer III");
checkUnmodified("Meyer IV");
checkUnmodified("Meyer V");
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment