Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/node
- /*
- * Modules we need/use.
- */
- var util = require('util');
- var chai = require('chai');
- var expect = chai.expect;
- OptionalString = function(val) {
- result = (val == void(0)) || (typeof(val) == 'string');
- util.puts('OptionalString(' + util.inspect(val) + ')=' + result.toString());
- return result;
- }
- const TestData = {
- 'test1': {
- 'key1-1': 'value1-1',
- 'key1-2': 'value2-2',
- },
- 'test2': {
- 'key2-1': 'value2-1',
- 'key2-2': 'value2-2',
- },
- 'test3': {
- 'key3-1': null,
- 'key3-2': 19,
- 'key3-3': undefined,
- },
- }
- var testElt;
- var fieldVal;
- for (var testKey in TestData) {
- testElt = TestData[testKey];
- describe('Checking test key ' + testKey, function () {
- for (var fieldName in testElt) {
- fieldVal = testElt[fieldName];
- describe(testKey + '[' + fieldName + ']', function () {
- it(testKey + '[' + fieldName + '](' + fieldVal + ')', function () {
- expect(fieldVal).to.equal(fieldVal);
- expect(fieldVal).to.satisfy(OptionalString);
- });
- });
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement