<commit_before>"use strict";

var referee = require("../referee");
var assert = require("assert");

describe("assert.isWeakSet", function() {
    it("should pass for WeakSet", function() {
        referee.assert.isWeakSet(new WeakSet()); // eslint-disable-line ie11/no-weak-collections
    });
    it("should fail for Set", function() {
        assert.throws(
            function() {
                referee.assert.isWeakSet(new Set());
            },
            function(error) {
                assert.equal(error.code, "ERR_ASSERTION");
                assert.equal(
                    error.message,
                    "[assert.isWeakSet] Expected Set {} to be a WeakSet"
                );
                assert.equal(error.name, "AssertionError");
                assert.equal(error.operator, "assert.isWeakSet");
                return true;
            }
        );
    });
    it("should fail for Array", function() {
        assert.throws(
            function() {
                referee.assert.isWeakSet([]);
            },
            function(error) {
                assert.equal(error.code, "ERR_ASSERTION");
                assert.equal(
                    error.message,
                    "[assert.isWeakSet] Expected [] to be a WeakSet"
                );
                assert.equal(error.name, "AssertionError");
                assert.equal(error.operator, "assert.isWeakSet");
                return true;
            }
        );
    });
    it("should fail for object", function() {
        assert.throws(
            function() {
                referee.assert.isWeakSet({});
            },
            function(error) {
                assert.equal(error.code, "ERR_ASSERTION");
                assert.equal(
                    error.message,
                    "[assert.isWeakSet] Expected {} to be a WeakSet"
                );
                assert.equal(error.name, "AssertionError");
                assert.equal(error.operator, "assert.isWeakSet");
                return true;
            }
        );
    });
    it("should fail for object with a custom message", function() {
        assert.throws(
            function() {
                referee.assert.isWeakSet({}, "Nope");
            },
            function(error) {
                assert.equal(error.code, "ERR_ASSERTION");
                assert.equal(
                    error.message,
                    "[assert.isWeakSet] Nope: Expected {} to be a WeakSet"
                );
                assert.equal(error.name, "AssertionError");
                assert.equal(error.operator, "assert.isWeakSet");
                return true;
            }
        );
    });
});<commit_msg>Convert tests for isWeakSet to unit tests<commit_after>/* eslint-disable ie11/no-weak-collections */
"use strict";

var assert = require("assert");
var proxyquire = require("proxyquire").noCallThru();
var sinon = require("sinon");

describe("isWeakSet factory", function() {
    before(function() {
        if (typeof WeakSet === "undefined") {
            this.skip();
        }
    });

    beforeEach(function() {
        this.fakeActualMessageValues = "f9f4851c-7a48-4712-ae23-a2502d8ee159";

        this.factory = proxyquire("./is-weak-set", {
            "../actual-message-values": this.fakeActualMessageValues
        });

        this.fakeReferee = {
            add: sinon.fake()
        };

        this.factory(this.fakeReferee);

        this.options = this.fakeReferee.add.args[0][1];
    });

    it("calls referee.add with 'isWeakSet' as name", function() {
        assert(this.fakeReferee.add.calledWith("isWeakSet"));
    });

    describe(".assert", function() {
        context("when called with a WeakSet instance", function() {
            it("returns true", function() {
                var result = this.options.assert(new WeakSet());

                assert.equal(result, true);
            });
        });

        context("when called with a non-WeakSet instance", function() {
            it("retunrns false", function() {
                var t = this;
                var nonWeakSetValues = [
                    [],
                    {},
                    Set,
                    WeakSet,
                    new WeakMap(),
                    new Set(),
                    new Map()
                ];

                nonWeakSetValues.forEach(function(value) {
                    assert.equal(t.options.assert(value), false);
                });
            });
        });
    });

    describe(".assertMessage", function() {
        it("is '${customMessage}Expected ${actual} to be a WeakSet'", function() {
            assert.equal(
                this.options.assertMessage,
                "${customMessage}Expected ${actual} to be a WeakSet"
            );
        });
    });

    describe(".refuteMessage", function() {
        it("is '${customMessage}Expected ${actual} not to be a WeakSet'", function() {
            assert.equal(
                this.options.refuteMessage,
                "${customMessage}Expected ${actual} not to be a WeakSet"
            );
        });
    });

    describe(".expectation", function() {
        it("is 'toBeWeakSet'", function() {
            assert.equal(this.options.expectation, "toBeWeakSet");
        });
    });

    describe(".values", function() {
        it("delegates to '../actual-message-values'", function() {
            assert.equal(this.options.values, this.fakeActualMessageValues);
        });
    });
});
{'fraction_non_alphanumeric': 0.13569482288828338, 'fraction_numerical': 0.0050862851952770205, 'mean_word_length': 1.5373271889400921, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6699854', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1415, 'n_words': 274}