test-utils

primitive assert-methods for unit-testing

Tính đến 30-08-2016. Xem phiên bản mới nhất.

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greatest.deepsurf.us/scripts/22762/144806/test-utils.js

// ==UserScript==
// @name            test-utils
// @name:de         test-utils
// @namespace       dannysaurus.camamba
// @version         0.1
// @license         MIT License
// @description     primitive assert-methods for unit-testing
// @description:de  primitive assert-methods for unit-testing
// ==/UserScript==
var LIB = LIB || {};
/**
 * @type {{assertTrue}}
 */
LIB.testUtils = (function() {
    'use strict';
    return {
        /**
         * Throws an error if assertion fails
         * @param {boolean} condition - condition to be checked</br><code>true</code> has the assertion succeed </br>false has the assertion fail (and throws an Error)
         * @param {string} [message] - debug-message to display if the assertion fails
         */
        assertTrue: function(condition, message) {
            message = message || "Assertion failed";
            if (!condition) {
                throw new Error(message);
            }
        }
    };
})();