App-Netdisco

 view release on metacpan or  search on metacpan

xt/js/qunit-tap.js  view on Meta::CPAN

        if (!shouldRender || typeof fieldValue === 'undefined') {
            return;
        }
        render(desc, fieldName, fieldValue, formatter);
    }

    function formatTestLine (testLine, rest) {
        if (!rest) {
            return testLine;
        }
        return testLine + ' - ' + escapeLineEndings(rest);
    }

    var extractDetailsFrom = (function () {
        var detailsExtractor;

        function setupExtractor (logArguments) {
            switch (logArguments.length) {
            case 1:  // details
                detailsExtractor = function (args) { return args[0]; };
                break;
            case 2:  // result, message(with tags)
                detailsExtractor = function (args) { return {result: args[0], message: stripTags(args[1])}; };
                break;
            case 3:  // result, message, details
                detailsExtractor = function (args) { return args[2]; };
                break;
            default:
                throw new Error('QUnit-TAP does not support QUnit#log arguments like this.');
            }
        }

        return function (logArguments) {
            if (detailsExtractor) {
                return detailsExtractor(logArguments);
            }
            setupExtractor(logArguments);
            return detailsExtractor(logArguments);
        };
    })();

    var createCallbackAppenderFor = function (qu) {
        // detect QUnit's multipleCallbacks feature. see jquery/qunit@34f6bc1
        var isMultipleLoggingCallbacksSupported =
                (typeof qu.config !== 'undefined' &&
                 typeof qu.config.log !== 'undefined' &&
                 typeof qu.config.done !== 'undefined' &&
                 typeof qu.config.testDone !== 'undefined' &&
                 typeof qu.config.moduleStart !== 'undefined' &&
                 typeof qu.config.testStart !== 'undefined');
        return function (subject, observer, event) {
            var originalLoggingCallback = subject[event],
                callback;
            if (isMultipleLoggingCallbacksSupported) {
                callback = function () {
                    // make listener methods (moduleStart,testStart,log, ...) overridable.
                    observer[event].apply(observer, slice.apply(arguments));
                };
                originalLoggingCallback(callback);
            } else if (typeof originalLoggingCallback === 'function') {
                // do not overwrite old-style logging callbacks
                callback = function () {
                    var args = slice.apply(arguments);
                    originalLoggingCallback.apply(subject, args);
                    observer[event].apply(observer, args);
                };
                subject[event] = callback;
            }
            return callback;
        };
    };


    /**
     * QUnit-TAP - A TAP Output Producer Plugin for QUnit
     * @param qunitObject QUnit object reference.
     * @param printLikeFunction print-like function for TAP output (assumes line-separator is added by this function for each call).
     * @param options configuration options to customize default behavior.
     * @return object to provide QUnit-TAP API and customization subject.
     */
    function qunitTap(qunitObject, printLikeFunction, options) {
        if (!qunitObject) {
            throw new Error('should pass QUnit object reference. Please check QUnit\'s "require" path if you are using Node.js (or any CommonJS env).');
        } else if (typeof printLikeFunction !== 'function') {
            throw new Error('should pass print-like function');
        }

        var qu = qunitObject,
            tap = {},
            jsDumpExists = (typeof qu.jsDump !== 'undefined' && typeof qu.jsDump.parse === 'function'),
            explain = (jsDumpExists ? function explain (obj) { return qu.jsDump.parse(obj); } : noop),
            deprecateOption = function deprecateOption (optionName, fallback) {
                // option deprecation and fallback function
                if (!options || typeof options !== 'object') {
                    return;
                }
                if (typeof options[optionName] === 'undefined') {
                    return;
                }
                printLikeFunction('# WARNING: Option "' + optionName + '" is deprecated and will be removed in future version.');
                fallback(options[optionName]);
            },
            targetEvents = [
                'moduleStart',
                'testStart',
                'log',
                'testDone',
                'done'
            ],
            registeredCallbacks = {};


        tap.config = extend(
            {
                initialCount: 1,
                showModuleNameOnFailure: true,
                showTestNameOnFailure: true,
                showExpectationOnFailure: true,
                showSourceOnFailure: true
            },
            options



( run in 1.139 second using v1.01-cache-2.11-cpan-39bf76dae61 )