Greasy Fork is available in English.

test-utils

primitive assert-methods for unit-testing

2016-08-30 일자. 최신 버전을 확인하세요.

이 스크립트는 직접 설치해서 쓰는 게 아닙니다. 다른 스크립트가 메타 명령 // @require https://update.greasyfork.org/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);
            }
        }
    };
})();