<commit_before>/* globals jasmine, beforeEach, afterEach, describe, it, expect */
'use strict';
var fw = require('../src/firewyrm');
var MockWyrmHole = require('../src/mockWyrmHole');
//var ConsoleWyrmHole = require('../src/consoleWyrmHole');
var clockHelpers = require('./helpers/clock');

describe("firewyrm", function() {
    beforeEach(function() {
        jasmine.clock().install();
        clockHelpers.addFlushMethod();
    });
    afterEach(function() {
        jasmine.clock().uninstall();
    });

    describe("creating the queenling", function() {
        var mockWyrmHole, queenling, mimetype = 'application/x-bigwyrm',
            createArgs, enumProps;
        beforeEach(function() {
            createArgs = {};
            enumProps = ['intProp', 'stringProp', 'arrayProp', 'functionProp'];
            mockWyrmHole = new MockWyrmHole();
            mockWyrmHole.flushClockFn = jasmine.clock().flush; // so it can flush after responding to a message
            queenling = fw.create(mockWyrmHole, mimetype, createArgs);
        });
        it("should return a thennable", function() {
            expect(queenling).toBeThennable();
        });
        it("should immediately send the mimetype and params over the WyrmHole", function() {
            expect(mockWyrmHole.lastMessage.args).toEqual(['New', mimetype, createArgs]);
        });
        it("should send 'Enum' message with the provided spawnId after 'New' returns", function() {
            mockWyrmHole.lastMessage.respond('success', mockWyrmHole.spawnId);
            expect(mockWyrmHole.lastMessage.args).toEqual('Enum', mockWyrmHole.spawnId, 0);
        });
        it("should ultimately resolve the queenling", function() {
            mockWyrmHole.lastMessage.respond('success', mockWyrmHole.spawnId); // respond to "New"
            mockWyrmHole.lastMessage.respond('success', enumProps); // respond to "Enum"
            expect(queenling).toBeResolved();
        });
    });
});<commit_msg>Add tests to make sure the queenling sets up all the correct properties<commit_after>/* globals jasmine, beforeEach, afterEach, describe, it, expect */
'use strict';
var _ = require('underscore');
var clockHelpers = require('./helpers/clock');
var fw = require('../src/firewyrm');
var MockWyrmHole = require('../src/mockWyrmHole');
//var ConsoleWyrmHole = require('../src/consoleWyrmHole');

describe("firewyrm", function() {
    beforeEach(function() {
        jasmine.clock().install();
        clockHelpers.addFlushMethod();
    });
    afterEach(function() {
        jasmine.clock().uninstall();
    });

    describe("creating the queenling", function() {
        var mockWyrmHole, queenling, mimetype = 'application/x-bigwyrm',
            createArgs, enumProps;
        beforeEach(function() {
            createArgs = {};
            enumProps = ['intProp', 'stringProp', 'arrayProp', 'functionProp'];
            mockWyrmHole = new MockWyrmHole();
            mockWyrmHole.flushClockFn = jasmine.clock().flush; // so it can flush after responding to a message
            queenling = fw.create(mockWyrmHole, mimetype, createArgs);
        });
        it("should return a thennable", function() {
            expect(queenling).toBeThennable();
        });
        it("should immediately send the mimetype and params over the WyrmHole", function() {
            expect(mockWyrmHole.lastMessage.args).toEqual(['New', mimetype, createArgs]);
        });
        it("should send 'Enum' message with the provided spawnId after 'New' returns", function() {
            mockWyrmHole.lastMessage.respond('success', mockWyrmHole.spawnId);
            expect(mockWyrmHole.lastMessage.args).toEqual('Enum', mockWyrmHole.spawnId, 0);
        });
        it("should ultimately resolve the queenling", function() {
            mockWyrmHole.lastMessage.respond('success', mockWyrmHole.spawnId); // respond to "New"
            mockWyrmHole.lastMessage.respond('success', enumProps); // respond to "Enum"
            expect(queenling).toBeResolved();
        });
        describe("after the queenling is resolved", function() {
            beforeEach(function() {
                mockWyrmHole.lastMessage.respond('success', mockWyrmHole.spawnId); // respond to "New"
                mockWyrmHole.lastMessage.respond('success', enumProps); // respond to "Enum"
                queenling.then(function(alienWyrmling) {
                    queenling = alienWyrmling; // this is the final resolved AlienWyrmling from initial contact
                });
                jasmine.clock().flush(); // make sure any promises are resolved
            });
            it("should make note of its spawnId and objectId", function() {
                expect(queenling.spawnId).toBe(mockWyrmHole.spawnId);
                expect(queenling.objectId).toBe(0);
            });
            it("should have a generic property getter and setter", function() {
                expect(queenling.getProperty).toEqual(jasmine.any(Function));
                expect(queenling.setProperty).toEqual(jasmine.any(Function));
            });
            it("should have properties for each of the items received from Enum", function() {
                _.each(enumProps, function(prop) {
                    expect(queenling.hasOwnProperty(prop)).toBe(true);
                });
            });
        });
    });
});
{'fraction_non_alphanumeric': 0.13330843913368184, 'fraction_numerical': 0.0005601194921583271, 'mean_word_length': 2.661654135338346, 'pattern_counts': {'":': 0, '<': 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': '7182277', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1513, 'n_words': 325}