Exemplo n.º 1
0
    writableStream: function (name) {
        var stream = {
            content: "",
            write: function () { this.content += join.call(arguments, " "); },
            toString: function () { return this.content; }
        };

        referee.add(name, {
            assert: function (expected) {
                return referee.match(stream.toString(), expected);
            },
            assertMessage: "${2}Expected " + name + "\n${0}\nto match\n${1}",
            refuteMessage: "${2}Expected " + name +
                "\n${0}\nnot to match\n${1}",
            values: function (expected, message) {
                return [stream.toString(), expected, message || ""];
            }
        });

        return stream;
    },
Exemplo n.º 2
0
  , async   = require('async')
  , rimraf  = require('rimraf')
  , fs      = require('fs')
  , path    = require('path')
  , delayed = require('delayed').delayed
  , levelup = require('../lib/levelup.js')
  , errors  = require('level-errors')
  , dbidx   = 0

assert(levelup.errors === errors);

referee.add('isInstanceOf', {
    assert: function (actual, expected) {
        return actual instanceof expected
    }
  , refute: function (actual, expected) {
        return !(actual instanceof expected)
    }
  , assertMessage: '${0} expected to be instance of ${1}'
  , refuteMessage: '${0} expected not to be instance of ${1}'
})

referee.add('isUndefined', {
    assert: function (actual) {
        return actual === undefined
    }
  , refute: function (actual) {
        return actual !== undefined
    }
  , assertMessage: '${0} expected to be undefined'
  , refuteMessage: '${0} expected not to be undefined'
})
Exemplo n.º 3
0
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

var referee = require('referee')

referee.add('isString', {
    assert: function (actual) {
      return typeof actual == 'string'
    }
  , assertMessage: 'expected ${0} to be a string'
})
referee.add('isArray', {
    assert: function (actual) {
      return Array.isArray(actual)
    }
  , assertMessage: 'expected ${0} to be an Array'
})
referee.add('fail', {
    assert: function () {
      return false
    }
  , assertMessage: '${0}'
})
referee.add('contains', {
Exemplo n.º 4
0
var sinonMatch = require("../lib/sinon/match");
var sinonAssert = require("../lib/sinon/assert");
var sinonClock = require("../lib/sinon/util/fake_timers");

var supportsAjax = typeof XMLHttpRequest !== "undefined" || typeof ActiveXObject !== "undefined";
var globalXHR = global.XMLHttpRequest;
var globalAXO = global.ActiveXObject;

if (!assert.stub) {
    require("./test-helper");
}

referee.add("fakeServerWithClock", {
    assert: function (obj, expected) {
        return samsam.deepEqual(obj, expected) &&
            fakeServer.create.calledOn(fakeServerWithClock);
    },
    assertMessage: "Expected object ${0} to be a fake server with clock"
});

describe("sinonSandbox", function () {
    it("inherits collection", function () {
        assert(sinonCollection.isPrototypeOf(sinonSandbox));
    });

    it("creates sandboxes", function () {
        var sandbox = sinonSandbox.create();

        assert.isObject(sandbox);
        assert(sinonSandbox.isPrototypeOf(sandbox));
    });