<commit_before>/**
 * User: Nabeel
 * Date: 4/1/14
 * Time: 7:25 PM
 */

var express = require('express');
var mongoose = require('mongoose');
var request = require('supertest');
var should = require('should');
var docs = require("../index.js");

var app = express();
app.use(app.router);

docs(app, mongoose);

var baseURL = "http://localhost:5000";

before(function (done) {

    // Add sample routes and start express app
    app.get("/test1", function() {});

    app.listen(5000, done);
});

before(function (done) {

    // Add sample schemas to mongoose
    var NestedSchema = new mongoose.Schema({
        prop1: Number
    });

    var EntitySchema = new mongoose.Schema({
        prop1: {type: String, required: true, enum: ["123"]},
        prop2: [NestedSchema]
    });

    mongoose.model("Entity", EntitySchema);
    done();
});

describe("docs", function () {

    it("should return routes", function (done) {
        request(baseURL)
            .get("/api-docs")
            .expect(200)
            .end(function (err, res) {
                if (err) return done(err);

                res.body.should.have.property("routes");
                res.body.routes.should.be.an.instanceOf(Array).with.length(1);
                res.body.routes[0][1][0].should.have.properties(["method", "path"]);

                done();
            });
    });

    it("should return schemas", function (done) {
        request(baseURL)
            .get("/api-docs")
            .expect(200)
            .end(function (err, res) {
                if (err) return done(err);

                res.body.should.have.property("schemas");
                var schemas = res.body.schemas;
                schemas.should.be.an.instanceOf(Array).with.length(3);
                schemas[0].should.have.properties(["name", "fields"]);

                var fields = schemas[0].fields;
                fields[0].required.should.be.true;
                fields[0].enumValues.should.be.an.instanceOf(Array);

                done();
            });
    });
});

<commit_msg>Unit testing<commit_after>/**
 * User: Nabeel
 * Date: 4/1/14
 * Time: 7:25 PM
 */

var express = require('express');
var mongoose = require('mongoose');
var request = require('supertest');
var should = require('should');
var docs = require("../index.js");

var app = express();
app.use(app.router);

docs(app, mongoose);

var baseURL = "http://localhost:5000";

before(function (done) {

    // Add sample routes and start express app
    app.get("/route1", function() {});

    app.listen(5000, done);
});

before(function (done) {

    // Add sample schemas to mongoose
    var NestedSchema = new mongoose.Schema({
        prop1: Number
    });

    var EntitySchema = new mongoose.Schema({
        prop1: {type: String, required: true, enum: ["123"]},
        prop2: [NestedSchema]
    });

    mongoose.model("Entity", EntitySchema);
    done();
});

describe("docs", function () {

    it("should return routes", function (done) {
        request(baseURL)
            .get("/api-docs")
            .expect(200)
            .end(function (err, res) {
                if (err) return done(err);

                res.body.should.have.property("routes");
                res.body.routes.should.be.an.instanceOf(Array).with.length(1);
                res.body.routes[0][1][0].should.have.properties(["method", "path"]);

                done();
            });
    });

    it("should return schemas", function (done) {
        request(baseURL)
            .get("/api-docs")
            .expect(200)
            .end(function (err, res) {
                if (err) return done(err);

                res.body.should.have.property("schemas");
                var schemas = res.body.schemas;
                schemas.should.be.an.instanceOf(Array).with.length(3);
                schemas[0].should.have.properties(["name", "fields"]);

                var fields = schemas[0].fields;
                fields[0].required.should.be.true;
                fields[0].enumValues.should.be.an.instanceOf(Array);

                done();
            });
    });
});

<|endoftext|>


<commit_before>var assert = chai.assert;

suite('Temperatura', function() {
    setup(function(){
      if (typeof __html__ !== 'undefined') {
          document.body.innerHTML = __html__['test/index.html'];
          original = document.getElementById('original');
          converted = document.getElementById('converted');
      }
    });

    test('32F = 0C', function() {
        original.value = "32F";
        calculate();
        assert.deepEqual(converted.innerHTML, "0C");
    });

    test('45C = 113F', function() {
        original.value = "45C";
        calculate();
        assert.deepEqual(converted.innerHTML, "113F");
    });

    test('5X = error', function() {
        original.value = "5X";
        calculate();
        assert.match(converted.innerHTML, /ERROR/);
    });
});<commit_msg>Correcciones<commit_after>var assert = chai.assert;
window.mocha.setup({ui: 'tdd'});

suite('Temperatura', function() {
    setup(function(){
      if (typeof __html__ !== 'undefined') {
          document.body.innerHTML = __html__['test/index.html'];
          original = document.getElementById('original');
          converted = document.getElementById('converted');
      }
    });

    test('32F = 0C', function() {
        original.value = "32F";
        calculate();
        assert.deepEqual(converted.innerHTML, "0C");
    });

    test('45C = 113F', function() {
        original.value = "45C";
        calculate();
        assert.deepEqual(converted.innerHTML, "113F");
    });

    test('5X = error', function() {
        original.value = "5X";
        calculate();
        assert.match(converted.innerHTML, /ERROR/);
    });
});<|endoftext|>


<commit_before>var Checker = require("../lib/checker").Checker
,   checker = new Checker()
,   path = require("path")
,   expect = require("expect.js")
,   events = require("events")
,   util = require("util")
;

var tests = {
    //Categories
    responsive : {
        //Checks
        "doc-width": [
        ,   {doc: "width_fail.html", errors: ["responsive.doc-width"]} //fail
        ,   {doc: "width_success.html"} //pass
        ]
    ,   "meta-viewport": [
        ,   {doc: "viewport_incorrect-initial-scale.html", errors: ["incorrect-initial-scale"]} //fail
        ,   {doc: "viewport_incorrect-width.html", errors: ["incorrect-width"]}
        ,   {doc: "viewport_many-viewport.html", errors: ["many-viewport"]}
        ,   {doc: "viewport_no-initial-scale.html", errors: ["no-initial-scale"]}
        ,   {doc: "viewport_no-meta-viewport.html", errors: ["no-meta-viewport"]}
        ,   {doc: "viewport_no-width.html", errors: ["no-width"]}
        ,   {doc: "viewport_ok.html"}
    ]
    }
}

function Sink () {
    this.ok = 0;
    this.errors = [];
    this.warnings = [];
    this.done = 0;
}

util.inherits(Sink, events.EventEmitter);

Object.keys(tests).forEach(function (category) {
    describe("Category " + category, function () {
        Object.keys(tests[category]).forEach(function (check) {
            describe("Check " + check, function () {
                tests[category][check].forEach(function (test) {
                    var passTest = test.errors ? false : true;
                    it("should " + (passTest ? "pass" : "fail") + "for " + test.doc, function (done) {
                        var c = require("../lib/checks/" + category + "/" + check)
                        ,   sink = new Sink
                        ;
                        console.log(test.doc);
                        sink.on('ok', function () {
                            console.log("ok");
                            sink.ok++;
                        });
                        sink.on('warning', function (type) {
                            console.log("warning");
                            sink.errors.push(type);
                        });
                        sink.on('err', function (type) {
                            console.log("error");
                            sink.errors.push(type);
                        });
                        sink.on('done', function () {
                            console.log('done');
                            sink.done++;
                        });
                        sink.on('end', function () {
                            if(passTest) {
                                expect(sink.errors).to.be.empty();
                                expect(sink.ok).to.eql(sink.done);
                            }
                            else{
                                expect(sink.errors.length).to.eql(test.errors.length);
                                /*for (var i = 0, n = test.errors.length; i < n; i++) {
                                    expect(sink.errors).to.contain(test.errors[i]);
                                }*/

                            }
                            console.log(sink);
                            done();
                        });
                        checker.check({
                            url : path.join(__dirname, "test_server/public/docs", test.doc)
                        ,   events : sink
                        ,   ip : "test"
                        ,   profile : "default"
                        ,   lang : "en"
                        ,   checklist: [c]
                        });
                    });
                });
            });
        });
    });
});

<commit_msg>test content of errors, not just length<commit_after>var Checker = require("../lib/checker").Checker
,   checker = new Checker()
,   path = require("path")
,   expect = require("expect.js")
,   events = require("events")
,   util = require("util")
;

var l10n = function(errid) {
    console.log(checker);
    var components = errid.split(".");
    return checker.l10n.message("en", components[0], components[1], components[2]);
}

var tests = {
    //Categories
    responsive : {
        //Checks
        "doc-width": [
        ,   {doc: "width_fail.html", errors: ["responsive.doc-width.err"]} //fail
        ,   {doc: "width_success.html"} //pass
        ]
    ,   "meta-viewport": [
        ,   {doc: "viewport_incorrect-initial-scale.html", errors: ["responsive.meta-viewport.6"]} //fail
        ,   {doc: "viewport_incorrect-width.html", errors: ["responsive.meta-viewport.5"]}
        ,   {doc: "viewport_many-viewport.html", errors: ["responsive.meta-viewport.2"]}
        ,   {doc: "viewport_no-initial-scale.html", errors: ["responsive.meta-viewport.4"]}
        ,   {doc: "viewport_no-meta-viewport.html", errors: ["responsive.meta-viewport.0"]}
        ,   {doc: "viewport_no-width.html", errors: ["responsive.meta-viewport.3"]}
        ,   {doc: "viewport_ok.html"}
    ]
    }
}

function Sink () {
    this.ok = 0;
    this.errors = [];
    this.warnings = [];
    this.done = 0;
}

util.inherits(Sink, events.EventEmitter);

Object.keys(tests).forEach(function (category) {
    describe("Category " + category, function () {
        Object.keys(tests[category]).forEach(function (check) {
            describe("Check " + check, function () {
                tests[category][check].forEach(function (test) {
                    var passTest = test.errors ? false : true;
                    it("should " + (passTest ? "pass" : "fail") + "for " + test.doc, function (done) {
                        var c = require("../lib/checks/" + category + "/" + check)
                        ,   sink = new Sink
                        ;
                        console.log(test.doc);
                        sink.on('ok', function () {
                            console.log("ok");
                            sink.ok++;
                        });
                        sink.on('warning', function (type) {
                            console.log("warning");
                            sink.errors.push(type);
                        });
                        sink.on('err', function (type) {
                            console.log("error");
                            sink.errors.push(type);
                        });
                        sink.on('done', function () {
                            console.log('done');
                            sink.done++;
                        });
                        sink.on('end', function () {
                            if(passTest) {
                                expect(sink.errors).to.be.empty();
                                expect(sink.ok).to.eql(sink.done);
                            }
                            else{
                                expect(sink.errors).to.eql(test.errors.map(l10n));
                                /*for (var i = 0, n = test.errors.length; i < n; i++) {
                                    expect(sink.errors).to.contain(test.errors[i]);
                                }*/

                            }
                            console.log(sink);
                            done();
                        });
                        checker.check({
                            url : path.join(__dirname, "test_server/public/docs", test.doc)
                        ,   events : sink
                        ,   ip : "test"
                        ,   profile : "default"
                        ,   lang : "en"
                        ,   checklist: [c]
                        });
                    });
                });
            });
        });
    });
});

<|endoftext|>


<commit_before>describe('discuss.js', function () {

    describe('GET', function () {
        it ('should perform a basic GET', function (done) {
            var d = new Discuss('http://localhost:9000/user', { cors: true });
            d.get(function(body, error, status, responseHeaders) {
                chai.assert(!error);
                chai.assert.equal(status, 200);
                chai.assert.deepEqual(responseHeaders, {
                    'Content-Type': 'application/json'
                })
                chai.assert.deepEqual(body, {
                    username: 'testuser'
                });
                done();
            });
        });

        it ('should translate query parameter into a query string', function (done) {
            var d = new Discuss('http://localhost:9000/logs', { cors: true });
            d.get({ 'from': 523, 'to': 'end' },
                function(body, error, status, responseHeaders) {
                    chai.assert(!error);
                    chai.assert.equal(status, 200);
                    chai.assert.deepEqual(responseHeaders, {
                        'Content-Type': 'text/html; charset=utf-8'
                    });
                    chai.assert.equal(body, "?from=523&to=end");
                    done();
                }
            );
        });

        it ('should accept custom headers at instantiation', function (done) {
            var d = new Discuss('http://localhost:9000/headerbounce', { cors: true },
                {
                    'custom-header-a' : 'value goes here',
                    'custom-header-b' : 'more data here',
                }
            );
            d.get(function(body, error, status, responseHeaders) {
                chai.assert(!error);
                chai.assert.equal(status, 200);
                chai.assert.deepEqual(responseHeaders, {
                    'Content-Type': 'application/json'
                });
                chai.assert.equal(body['custom-header-a'], 'value goes here');
                chai.assert.equal(body['custom-header-b'], 'more data here');
                done();
            });
        });

        it ('should accept custom headers after instatiation', function (done) {
            var d = new Discuss('http://localhost:9000/headerbounce', { cors: true });
            d.get(function(body, error, status, responseHeaders) {
                chai.assert(!error);
                chai.assert.equal(status, 200);
                chai.assert.deepEqual(responseHeaders, {
                    'Content-Type': 'application/json'
                });
                chai.assert.equal(body['custom-header-a'], 'value goes here');
                chai.assert.equal(body['custom-header-b'], 'more data here');
                done();
            },
            {
                'custom-header-a' : 'value goes here',
                'custom-header-b' : 'more data here',
            });
        });
    });

    describe('POST', function () {
        it ('should perform a basic POST', function (done) {
            var postdata = {
                username: 'testuser',
                score: '4358194'
            };

            var d = new Discuss('http://localhost:9000/highscore', { cors: true });
            d.post(postdata,
                function(body, error, status, responseHeaders) {
                    chai.assert(!error);
                    chai.assert.equal(status, 201);
                    chai.assert.deepEqual(body, postdata);
                    done();
                }
            );
        });
    });

    describe('PUT', function () {
        it ('should perform a basic PUT', function (done) {
            var putdata = {
                'message' : 'what is the question?'
            };

            var d = new Discuss('http://localhost:9000/answers/42', { cors: true });
            d.put(putdata,
                function(body, error, status) {
                    chai.assert(!error);
                    chai.assert.equal(status, 200);
                    chai.assert.equal(body.id, 42);
                    chai.assert.equal(body.about.length, 3);
                    chai.assert.equal(body.about[0], 'life');
                    chai.assert.equal(body.about[1], 'the universe');
                    chai.assert.equal(body.about[2], 'everything');
                    chai.assert.deepEqual(body.original, putdata);
                    done();
                }
            );
        });
    });

    describe('DELETE', function () {
        it ('should perform a basic DELETE', function (done) {
            var d = new Discuss('http://localhost:9000/something/we/dont/need/93793', { cors: true });
            d.delete(function (body, error, status) {
                chai.assert(!error);
                chai.assert.equal(status, 200);
                done();
            });
        });

        it ('should translate query parameter into a query string', function (done) {
            var d = new Discuss('http://localhost:9000/something/else/we/dont/need/43622', { cors: true });
            d.delete({ 'zip': 90210, 'haircolor': 'brown', 'disposition': 'idiot' },
                function(body, error, status, responseHeaders) {
                    chai.assert(!error);
                    chai.assert.equal(status, 200);
                    chai.assert.deepEqual(responseHeaders, {
                        'Content-Type': 'text/html; charset=utf-8'
                    });
                    chai.assert.equal(body, "?zip=90210&haircolor=brown&disposition=idiot");
                    done();
                }
            );
        });
    });

    describe('', function () {
        it ('should destroy the Test API server', function (done) {
            var d = new Discuss('http://localhost:9000/finished', { cors: true, timeout: 1000 });
            d.post(function(body, error, status) {
                chai.assert(!error);
                chai.assert.equal(status, 200);

                d.post(function (body, error, status) {
                    // Verify that it's dead
                    chai.assert(!body);
                    chai.assert(error instanceof Error);
                    chai.assert.equal(status, 0);
                    done();
                });
            });
        });
    });
});<commit_msg>Turning on chai stack traces to debug travis<commit_after>chai.Assertion.includeStack = true;
describe('discuss.js', function () {

    describe('GET', function () {
        it ('should perform a basic GET', function (done) {
            var d = new Discuss('http://localhost:9000/user', { cors: true });
            d.get(function(body, error, status, responseHeaders) {
                chai.assert(!error);
                chai.assert.equal(status, 200);
                chai.assert.deepEqual(responseHeaders, {
                    'Content-Type': 'application/json'
                })
                chai.assert.deepEqual(body, {
                    username: 'testuser'
                });
                done();
            });
        });

        it ('should translate query parameter into a query string', function (done) {
            var d = new Discuss('http://localhost:9000/logs', { cors: true });
            d.get({ 'from': 523, 'to': 'end' },
                function(body, error, status, responseHeaders) {
                    chai.assert(!error);
                    chai.assert.equal(status, 200);
                    chai.assert.deepEqual(responseHeaders, {
                        'Content-Type': 'text/html; charset=utf-8'
                    });
                    chai.assert.equal(body, "?from=523&to=end");
                    done();
                }
            );
        });

        it ('should accept custom headers at instantiation', function (done) {
            var d = new Discuss('http://localhost:9000/headerbounce', { cors: true },
                {
                    'custom-header-a' : 'value goes here',
                    'custom-header-b' : 'more data here',
                }
            );
            d.get(function(body, error, status, responseHeaders) {
                chai.assert(!error);
                chai.assert.equal(status, 200);
                chai.assert.deepEqual(responseHeaders, {
                    'Content-Type': 'application/json'
                });
                chai.assert.equal(body['custom-header-a'], 'value goes here');
                chai.assert.equal(body['custom-header-b'], 'more data here');
                done();
            });
        });

        it ('should accept custom headers after instatiation', function (done) {
            var d = new Discuss('http://localhost:9000/headerbounce', { cors: true });
            d.get(function(body, error, status, responseHeaders) {
                chai.assert(!error);
                chai.assert.equal(status, 200);
                chai.assert.deepEqual(responseHeaders, {
                    'Content-Type': 'application/json'
                });
                chai.assert.equal(body['custom-header-a'], 'value goes here');
                chai.assert.equal(body['custom-header-b'], 'more data here');
                done();
            },
            {
                'custom-header-a' : 'value goes here',
                'custom-header-b' : 'more data here',
            });
        });
    });

    describe('POST', function () {
        it ('should perform a basic POST', function (done) {
            var postdata = {
                username: 'testuser',
                score: '4358194'
            };

            var d = new Discuss('http://localhost:9000/highscore', { cors: true });
            d.post(postdata,
                function(body, error, status, responseHeaders) {
                    chai.assert(!error);
                    chai.assert.equal(status, 201);
                    chai.assert.deepEqual(body, postdata);
                    done();
                }
            );
        });
    });

    describe('PUT', function () {
        it ('should perform a basic PUT', function (done) {
            var putdata = {
                'message' : 'what is the question?'
            };

            var d = new Discuss('http://localhost:9000/answers/42', { cors: true });
            d.put(putdata,
                function(body, error, status) {
                    chai.assert(!error);
                    chai.assert.equal(status, 200);
                    chai.assert.equal(body.id, 42);
                    chai.assert.equal(body.about.length, 3);
                    chai.assert.equal(body.about[0], 'life');
                    chai.assert.equal(body.about[1], 'the universe');
                    chai.assert.equal(body.about[2], 'everything');
                    chai.assert.deepEqual(body.original, putdata);
                    done();
                }
            );
        });
    });

    describe('DELETE', function () {
        it ('should perform a basic DELETE', function (done) {
            var d = new Discuss('http://localhost:9000/something/we/dont/need/93793', { cors: true });
            d.delete(function (body, error, status) {
                chai.assert(!error);
                chai.assert.equal(status, 200);
                done();
            });
        });

        it ('should translate query parameter into a query string', function (done) {
            var d = new Discuss('http://localhost:9000/something/else/we/dont/need/43622', { cors: true });
            d.delete({ 'zip': 90210, 'haircolor': 'brown', 'disposition': 'idiot' },
                function(body, error, status, responseHeaders) {
                    chai.assert(!error);
                    chai.assert.equal(status, 200);
                    chai.assert.deepEqual(responseHeaders, {
                        'Content-Type': 'text/html; charset=utf-8'
                    });
                    chai.assert.equal(body, "?zip=90210&haircolor=brown&disposition=idiot");
                    done();
                }
            );
        });
    });

    describe('', function () {
        it ('should destroy the Test API server', function (done) {
            var d = new Discuss('http://localhost:9000/finished', { cors: true, timeout: 1000 });
            d.post(function(body, error, status) {
                chai.assert(!error);
                chai.assert.equal(status, 200);

                d.post(function (body, error, status) {
                    // Verify that it's dead
                    chai.assert(!body);
                    chai.assert(error instanceof Error);
                    chai.assert.equal(status, 0);
                    done();
                });
            });
        });
    });
});<|endoftext|>


<commit_before>var assert =  require("chai").assert;
var cmds = require("../commands/commands");

function Message(id, channel, author, contents) {
	this.id = id;
	this.channel = channel;
	this.author = author;
	this.content = contents;
}

function Client() {
	this.replies = [];
	this.messages = [];
	this.sendMessage = function(channel, message) {
		this.messages[this.messages.length] = message;
	};
	this.reply = function(message, reply) {
		this.replies[this.replies.length] = reply;
	};
	this.deleteMessage = function(message) {

	};
}

var config = {};
config.cmdprefix = "!";
config.col = "0.25";

describe("Commands", function() {
	var client = new Client();
	before(function() {
		cmds.setUp(client, config, null);
	});
	describe("get()", function() {
		it("should return null if command doesn't exist", function() {
			assert.equal(null, cmds.get("test"));
		});

		it("should return a command if command exists", function() {
			var pingCmd =  cmds.get("ping");
			assert.isObject(pingCmd);
			assert.property(pingCmd, "cmd");
			assert.property(pingCmd, "description");
			assert.isFunction(pingCmd.action);
			assert.property(pingCmd, "hidden");
		});
		it("should return the correct command.", function() {
			var blameCmd = cmds.get("blame");
			assert.propertyVal(blameCmd, "description", "Assigns blame appropriately");
			assert.propertyNotVal(blameCmd, "description", "It's like ping-pong, but with words.");
		});
		it("hidden commands should have a hidden property", function() {
			var configCmd = cmds.get("config");
			assert.isTrue(configCmd.hidden);
		});
		it("visible commands should not have a hidden property", function() {
			var geCmd = cmds.get("ge");
			assert.isFalse(geCmd.hidden);
		});
	});
	describe("ping", function() {
		var pingCmd = cmds.get("ping");
		it("should reply with 'pong'", function() {
			var pingMsg = new Message(1, "general", "Deixel", "!ping");
			pingCmd.action(pingMsg);
			assert.equal(client.replies[client.replies.length-1], "pong");
		});
	});
	describe("blame", function() {
		var blameCmd = cmds.get("blame");
		it("should blame Yury when no parameters are set", function() {
			var blameMsg = new Message(1, "general", "Deixel", "!blame");
			blameCmd.action(blameMsg);
			assert.equal(client.messages[client.messages.length-1], "I blame Yury");
		});
		it("should blame a specified string if given", function() {
			var blameMsg = new Message(1, "general", "Deixel", "!blame potato");
			blameCmd.action(blameMsg);
			assert.equal(client.messages[client.messages.length-1], "I blame potato");
		});
	});
	describe("ge", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
	describe("hs", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
	describe("sb", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
	describe("config", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
	describe("botissues", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
	describe("report", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
	describe("say", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
	describe("help", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
});
<commit_msg>Added GE tests<commit_after>var assert =  require("chai").assert;
var cmds = require("../commands/commands");

function Message(id, channel, author, contents) {
	this.id = id;
	this.channel = channel;
	this.author = author;
	this.content = contents;
}

function Client() {
	this.replies = [];
	this.messages = [];
	this.sendMessage = function(channel, message) {
		this.messages[this.messages.length] = message;
	};
	this.reply = function(message, reply) {
		this.replies[this.replies.length] = reply;
	};
	this.deleteMessage = function(message) {
		//Do nothing
	};
}

var config = {};
config.cmdprefix = "!";
config.col = "0.25";

describe("Commands", function() {
	var client = new Client();
	before(function() {
		cmds.setUp(client, config, null);
	});
	describe("get()", function() {
		it("should return null if command doesn't exist", function() {
			assert.equal(null, cmds.get("test"));
		});

		it("should return a command if command exists", function() {
			var pingCmd =  cmds.get("ping");
			assert.isObject(pingCmd);
			assert.property(pingCmd, "cmd");
			assert.property(pingCmd, "description");
			assert.isFunction(pingCmd.action);
			assert.property(pingCmd, "hidden");
		});
		it("should return the correct command.", function() {
			var blameCmd = cmds.get("blame");
			assert.propertyVal(blameCmd, "description", "Assigns blame appropriately");
			assert.propertyNotVal(blameCmd, "description", "It's like ping-pong, but with words.");
		});
		it("hidden commands should have a hidden property", function() {
			var configCmd = cmds.get("config");
			assert.isTrue(configCmd.hidden);
		});
		it("visible commands should not have a hidden property", function() {
			var geCmd = cmds.get("ge");
			assert.isFalse(geCmd.hidden);
		});
	});
	describe("ping", function() {
		var pingCmd = cmds.get("ping");
		it("should reply with 'pong'", function() {
			var pingMsg = new Message(1, "general", "Deixel", "!ping");
			pingCmd.action(pingMsg);
			assert.equal(client.replies[client.replies.length-1], "pong");
		});
	});
	describe("blame", function() {
		var blameCmd = cmds.get("blame");
		it("should blame Yury when no parameters are set", function() {
			var blameMsg = new Message(1, "general", "Deixel", "!blame");
			blameCmd.action(blameMsg);
			assert.equal(client.messages[client.messages.length-1], "I blame Yury");
		});
		it("should blame a specified string if given", function() {
			var blameMsg = new Message(1, "general", "Deixel", "!blame potato");
			blameCmd.action(blameMsg);
			assert.equal(client.messages[client.messages.length-1], "I blame potato");
		});
	});
	describe("ge", function() {
		var geCmd = cmds.get("ge");
		it("should reply with an error if no item is specified", function() {
			var geMsg = new Message(1, "general", "Deixel", "!ge");
			geCmd.action(geMsg);
			assert.equal(client.replies[client.replies.length-1], "You need to specify an item");
		});
		it("should send a message with the right link if an item is specified", function() {
			var geMsg = new Message(1, "general", "Deixel", "!ge frost dragon");
			geCmd.action(geMsg);
			assert.equal(client.messages[client.messages.length-1], "http://services.runescape.com/m=itemdb_rs/results?query=frost+dragon");
		});
	});
	describe("hs", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
	describe("sb", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
	describe("config", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
	describe("botissues", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
	describe("report", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
	describe("say", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
	describe("help", function() {
		it("should fail", function() {
			assert.fail(true, false);
		});
	});
});
<|endoftext|>


<commit_before>$(function() {
	module('main');

	test('sum',function(){
		equals(jStat.sum([1,2,3,4,5,6]),21,'sum([1,2,3,4,5,6])');
	});

	test('min',function(){
		equals(jStat.min([1,2,3,4,5,6]),1,'min([1,2,3,4,5,6])');
	});

	test('max',function(){
		equals(jStat.max([1,2,3,4,5,6]),6,'max([1,2,3,4,5,6])');
	});

	test('mean',function(){
		equals(jStat.mean([1,2,3,4,5,6]),3.5,'mean([1,2,3,4,5,6])');
	});

	test('median',function(){
		equals(jStat.median([1,2,3,3,4,5,6]),3,'median([1,2,3,3,4,5,6])');
		equals(jStat.median([1,2,3,4,5,6]),3.5,'median([1,2,3,4,5,6])');
	});

	test('mode',function(){
		equals(jStat.mode([1,2,3,3,4,5,6]),3,'mode([1,2,3,3,4,5,6])');
		equals(jStat.mode([1,1,2,3,3,4,5,6]),false,'mode([1,1,2,3,3,4,5,6])');
	});

	test('range',function(){
		equals(jStat.range([1,2,3,3,4,5,6]),5,'range([1,2,3,3,4,5,6])');
		equals(jStat.range([-3,-6,-4]),3,'range([-3,-6,-4])');
	});

	test('variance',function(){
		equals(jStat.variance([1,2,3,4,5,6]),3.5,'variance([1,2,3,4,5,6])');
	});

	test('stdev',function(){
		equals(jStat.stdev([3,4,5]),1,'stdev([3,4,5])');
		equals(jStat.stdev([-3,-4,-5]),1,'stdev([-3,-4,-5])');
	});

	test('meandev',function(){
		equals(jStat.meandev([2,2,3,4,14]),3.6,'meandev([2,2,3,4,14])');
	});

	test('meddev',function(){
		equals(jStat.meddev([2,2,3,4,14]),2.8,'meddev([2,2,3,4,14])');
	});

	test('factorial',function(){
		equals(jStat.factorial(5),120,'factorial(5)');
		equals(jStat.factorial(.5),0.8862269254527566,'factorial(.5)');
	});

	test('combination',function(){
		equals(jStat.combination(10,4),210,'combination(10,4)');
	});

	test('permutation',function(){
		equals(jStat.permutation(10,4),5040,'permutation(10,4)');
	});

	test('gamma',function(){
		equals(jStat.gammafn(.5),1.7724538509055165,'gamma(.5)');
		equals(jStat.gammafn(15),87178291200,'gamma(5)');
	});

	test('quartiles',function(){
		equals(jStat.quartiles([1,2,3,6,9,3,1,2,5]).toString(),'1,3,5','quartiles([1,2,3,6,9,3,1,2,5])');
	});

	test('covariance',function(){
		equals(jStat.covariance([1,2,3,6,9,3,1,2,5],[2,3,5,2,5,7,8,9,6]),-1.1234567901234565,'covariance([1,2,3,6,9,3,1,2,5],[2,3,5,2,5,7,8,9,6])');
	});

	test('corrcoeff',function(){
		equals(jStat.corrcoeff([1,2,3,6,9,3,1,2,5],[2,3,5,2,5,7,8,9,6]),-0.16693777514921238,'corrcoeff([1,2,3,6,9,3,1,2,5],[2,3,5,2,5,7,8,9,6])');
	});

	module('distribution');

	test('uniformcdf',function(){
		equals(jDist.uniform.cdf(0.5, 0, 2),0.25,'uniform.cdf(0, 2, 0.5)');
	});

	test('binomial',function(){
		equals(jDist.binomial.pdf(2, 5, 0.5),0.3125,'binomial.pdf(5, 1/2, 2)');
	});

	test('weibull',function(){
		equals(jDist.weibull.pdf(1,1,1),0.36787944117144233,'weibull(1,1,1)');
		equals(jDist.weibull.pdf(2,1,2),0.18393972058572117,'weibull(2,1,2)');
	});

	test('weibullcdf',function(){
		equals(jDist.weibull.cdf(1,1,1),0.6321205588285577,'weibull.cdf(1,1,1)');
		equals(jDist.weibull.cdf(2,1,2),0.6321205588285577,'weibull.cdf(2,1,2)');
	});

	module('vector');

	// two vector objects used in the tests
	var v1 = jStat.Vector(1,2,3,4,5,6,7,8,9);
	var v2 = jStat.Vector(9,8,7,6,5,4,3,2,1);

	test('Vector.e', function() {
		for(var i = 1; i <= 9; i++) {
			equals(v1.e(i),i,'v1.e(' + i + ')');
		}
	});

	test('Vector.add', function() {
		var v3 = v1.add(5.7);	// vector + scalar addition
		var v4 = v1.add(v2);	// vector + vector addition
		for(var i = 1; i <= 9; i++) {
			equals(v3.e(i),i+5.7,'v1.add(5.7)');
			equals(v4.e(i),v1.e(i) + v2.e(i), 'v1.add(v2)');
		}
	});

	test('Vector.divide', function() {
		var v3 = v1.divide(2.5);
		var v4 = v1.divide(v2);
		for(var i = 1; i <= 9; i++) {
			equals(v3.e(i),i/2.5,'v1.divide(2.5)');
			equals(v4.e(i),v1.e(i) / v2.e(i), 'v1.divide(v2)');
		}
	});

	test('Vector.multiply', function() {
		var v3 = v1.multiply(3.141);
		var v4 = v1.multiply(v2);
		for(var i = 1; i <= 9; i++) {
			equals(v3.e(i),i*3.141,'v1.multiply(3.141)');
			equals(v4.e(i),v1.e(i) * v2.e(i), 'v1.multiply(v2)');
		}
	});

	test('Vector.subtract', function() {
		var v3 = v1.subtract(3.141);
		var v4 = v1.subtract(v2);
		for(var i = 1; i <= 9; i++) {
			equals(v3.e(i),i-3.141,'v1.subtract(3.141)');
			equals(v4.e(i),v1.e(i) - v2.e(i), 'v1.subtract(v2)');
		}
	});

	test('Vector.pow', function() {
		var v3 = v1.pow(3.141);
		var v4 = v1.pow(v2);
		for(var i = 1; i <= 9; i++) {
			equals(v3.e(i),Math.pow(i,3.141),'v1.pow(3.141)');
			equals(v4.e(i), Math.pow(v1.e(i), v2.e(i)), 'v1.pow(v2)');
		}
	});

	test('Vector.abs', function() {
		var v3 = v1.subtract(5);
		v3 = v3.abs();
		for(var i = 1; i <= 9; i++) {
			equals(v3.e(i),Math.abs(v1.e(i) - 5),'v1.abs()');
		}
	});

	test('Vector.max', function() {
		equals(v1.max(), 9, 'v1.max()');
		equals(v2.max(), 9, 'v2.max()');
	});

	test('Vector.min', function() {
		equals(v1.min(), 1, 'v1.min()');
		equals(v2.min(), 1, 'v2.min()');
	});

	test('Vector.sum', function() {
		equals(v1.sum(), 45, 'v1.sum()');
		equals(v2.sum(), 45, 'v2.sum()');
	});

	test('Vector.length', function() {
		equals(v1.length(), 9, 'v1.length()');
		equals(v2.length(), 9, 'v2.length()');
	});

	test('Vector.size', function() {
		equals(v1.size(), 9, 'v1.size()');
		equals(v2.size(), 9, 'v2.size()');
	});

	test('Vector.dot', function() {
		var v1dotv2 = v1.dot(v2);
		var v2dotv1 = v2.dot(v1);
		equals(v1dotv2, 165, 'v1.dot(v2)');
		equals(v2dotv1, 165, 'v2.dot(v1)');
	});

	test('Vector.clear', function() {
		var v3 = jStat.Vector(1,2,3,4,5,6,7,8,9);	// create a clone of v1
		v3.clear();
		for(var i = 1; i <= 9; i++) {
			equals(v3.e(i),0,'v1.clear()');
		}
	});

	test('Vector.norm', function() {
		var v1norm = v1.norm();
		var v2norm = v2.norm();

		equals(v1norm, Math.sqrt(v1.dot(v1)), 'v1.norm()');
		equals(v2norm, Math.sqrt(v2.dot(v2)), 'v2.norm()');
	});

	test('Vector.angle', function() {
		var v1angv2 = v1.angle(v2);
		var v2angv1 = v2.angle(v1);

		equals(v1angv2.toFixed(10), 0.9533592232, 'v1.angle(v2)');	// testing to 10 d.p.
		equals(v2angv1.toFixed(10), 0.9533592232, 'v2.angle(v1)');	// testing to 10 d.p.
	});

	test('Vector.sort', function() {
		var v3 = v2.sort();
		for(var i = 1; i <= 9; i++) {
			equals(v1.e(i), v3.e(i),'v1.e('+i+') == v3.e('+i+')');
		}
		var v4 = v2.sort('desc');
		for(var i = 1; i <= 9; i++) {
			equals(v2.e(i), v4.e(i),'v2.e('+i+') == v4.e(' + i + ')');
		}
	});

	test('Vector.right', function() {
		var v3 = v1.right(4);
		for(var i = 1; i <= 4; i++) {
			equals(v1.e(i+5), v3.e(i),'v1.e('+i+' + 5) == v3.e('+i+')');
		}
	});

	test('Vector.left', function() {
		var v3 = v1.left(4);
		for(var i = 1; i <= 4; i++) {
			equals(v1.e(i), v3.e(i),'v1.e('+i+') == v3.e('+i+')');
		}
	});

	test('Vector.mid', function() {
		var v3 = v1.mid(3, 3);
		for(var i = 1; i <= 3; i++) {
			equals(v1.e(i+2), v3.e(i),'v1.e('+i+' + 2) == v3.e('+i+')');
		}
	});

	test('Vector.transpose', function() {
		var m = v1.transpose();	// should return a single row matrix
		var row = m.row(1);
		for(var i = 1; i <= 9; i++) {
			equals(row.e(i), v1.e(i), 'row.e(' + i + ')');
		}
	});

	test('Vector.fill', function() {
		var v3 = jStat.Vector.fill(5.6, 5);
		for(var i = 1; i <= 5; i++) {
			equals(v3.e(i), 5.6, 'v3.e(' + i + ')');
		}
	});

	test('Vector.zeros', function() {
		var v3 = jStat.Vector.zeros(5);
		for(var i = 1; i <= 5; i++) {
			equals(v3.e(i), 0, 'v3.e(' + i + ')');
		}
	});

	test('Vector.fill', function() {
		var v3 = jStat.Vector.ones(5);
		for(var i = 1; i <= 5; i++) {
			equals(v3.e(i), 1, 'v3.e(' + i + ')');
		}
	});
});
<commit_msg>removed vector tests<commit_after>$(function() {
	module('main');

	test('sum',function(){
		equals(jStat.sum([1,2,3,4,5,6]),21,'sum([1,2,3,4,5,6])');
	});

	test('min',function(){
		equals(jStat.min([1,2,3,4,5,6]),1,'min([1,2,3,4,5,6])');
	});

	test('max',function(){
		equals(jStat.max([1,2,3,4,5,6]),6,'max([1,2,3,4,5,6])');
	});

	test('mean',function(){
		equals(jStat.mean([1,2,3,4,5,6]),3.5,'mean([1,2,3,4,5,6])');
	});

	test('median',function(){
		equals(jStat.median([1,2,3,3,4,5,6]),3,'median([1,2,3,3,4,5,6])');
		equals(jStat.median([1,2,3,4,5,6]),3.5,'median([1,2,3,4,5,6])');
	});

	test('mode',function(){
		equals(jStat.mode([1,2,3,3,4,5,6]),3,'mode([1,2,3,3,4,5,6])');
		equals(jStat.mode([1,1,2,3,3,4,5,6]),false,'mode([1,1,2,3,3,4,5,6])');
	});

	test('range',function(){
		equals(jStat.range([1,2,3,3,4,5,6]),5,'range([1,2,3,3,4,5,6])');
		equals(jStat.range([-3,-6,-4]),3,'range([-3,-6,-4])');
	});

	test('variance',function(){
		equals(jStat.variance([1,2,3,4,5,6]),3.5,'variance([1,2,3,4,5,6])');
	});

	test('stdev',function(){
		equals(jStat.stdev([3,4,5]),1,'stdev([3,4,5])');
		equals(jStat.stdev([-3,-4,-5]),1,'stdev([-3,-4,-5])');
	});

	test('meandev',function(){
		equals(jStat.meandev([2,2,3,4,14]),3.6,'meandev([2,2,3,4,14])');
	});

	test('meddev',function(){
		equals(jStat.meddev([2,2,3,4,14]),2.8,'meddev([2,2,3,4,14])');
	});

	test('factorial',function(){
		equals(jStat.factorial(5),120,'factorial(5)');
		equals(jStat.factorial(.5),0.8862269254527566,'factorial(.5)');
	});

	test('combination',function(){
		equals(jStat.combination(10,4),210,'combination(10,4)');
	});

	test('permutation',function(){
		equals(jStat.permutation(10,4),5040,'permutation(10,4)');
	});

	test('gamma',function(){
		equals(jStat.gammafn(.5),1.7724538509055165,'gamma(.5)');
		equals(jStat.gammafn(15),87178291200,'gamma(5)');
	});

	test('quartiles',function(){
		equals(jStat.quartiles([1,2,3,6,9,3,1,2,5]).toString(),'1,3,5','quartiles([1,2,3,6,9,3,1,2,5])');
	});

	test('covariance',function(){
		equals(jStat.covariance([1,2,3,6,9,3,1,2,5],[2,3,5,2,5,7,8,9,6]),-1.1234567901234565,'covariance([1,2,3,6,9,3,1,2,5],[2,3,5,2,5,7,8,9,6])');
	});

	test('corrcoeff',function(){
		equals(jStat.corrcoeff([1,2,3,6,9,3,1,2,5],[2,3,5,2,5,7,8,9,6]),-0.16693777514921238,'corrcoeff([1,2,3,6,9,3,1,2,5],[2,3,5,2,5,7,8,9,6])');
	});

	module('distribution');

	test('uniformcdf',function(){
		equals(jDist.uniform.cdf(0.5, 0, 2),0.25,'uniform.cdf(0, 2, 0.5)');
	});

	test('binomial',function(){
		equals(jDist.binomial.pdf(2, 5, 0.5),0.3125,'binomial.pdf(5, 1/2, 2)');
	});

	test('weibull',function(){
		equals(jDist.weibull.pdf(1,1,1),0.36787944117144233,'weibull(1,1,1)');
		equals(jDist.weibull.pdf(2,1,2),0.18393972058572117,'weibull(2,1,2)');
	});

	test('weibullcdf',function(){
		equals(jDist.weibull.cdf(1,1,1),0.6321205588285577,'weibull.cdf(1,1,1)');
		equals(jDist.weibull.cdf(2,1,2),0.6321205588285577,'weibull.cdf(2,1,2)');
	});

});
<|endoftext|>


<commit_before>var assert = chai.assert;
var router = new RouterRouter();

// Override browser's native Location object. See:
// https://github.com/jashkenas/backbone/blob/master/test/router.js#L13-L41
var Location = function(href) {
	this.replace(href);
};

Location.prototype = {
	parser: document.createElement('a'),

	replace: function(href) {
		this.parser.href = href;

		this.href = this.parser.href;
		this.hash = this.parser.hash;
		this.host = this.parser.host;
		this.search = this.parser.search;
		this.fragment = this.parser.fragment;
		this.pathname = this.parser.pathname;
		this.protocol = this.parser.protocol;

		// In IE, anchor.pathname does not contain a leading slash though
		// window.location.pathname does.
		if (!/^\//.test(this.pathname)) this.pathname = '/' + this.pathname;
	},

	toString: function() {
		return this.href;
	}
};

describe('RouterRouter', function() {
	it('should match an empty string.', function() {
		router.location = new Location('http://example.com');

		router.route('', function() {
			assert.ok(true);
		});
	});

	it('should match a string.', function() {
		router.location = new Location('http://example.com/foo');

		router.route('foo', function() {
			assert.ok(true);
		});
	});

	it('should match a string with Unicode characters.', function() {
		router.location = new Location('http://example.com/motleycrüe');

		router.route('motleycrüe', function() {
			assert.ok(true);
		});
	});

	it('should match a string with newline characters.', function() {
		router.location = new Location('http://example.com/foo%0Abar');

		router.route('foo\nbar', function() {
			assert.ok(true);
		});
	});

	it('should match parameter parts.', function() {
		router.location = new Location('http://example.com/1/2/3');

		router.route(':foo/:bar/:biz', function(foo, bar, biz) {
			assert.strictEqual(foo, '1');
			assert.strictEqual(bar, '2');
			assert.strictEqual(biz, '3');
		});
	});

	it('should match splat parts.', function() {
		router.location = new Location('http://example.com/path/to/some/file.txt');

		router.route('path/*foo', function(foo) {
			assert.strictEqual(foo, 'to/some/file.txt');
		});
	});

	describe('should match optional parts and', function() {
		it('returns the optional part when an optional part matches.', function() {
			router.location = new Location('http://example.com/blog/sample-post-title');

			router.route(':foo(/:bar)', function(foo, bar) {
				assert.strictEqual(foo, 'blog');
				assert.strictEqual(bar, 'sample-post-title');
			});
		});

		it('returns null when an optional part does not match.', function() {
			router.location = new Location('http://example.com/blog');

			router.route(':foo(/:bar)', function(foo, bar) {
				assert.strictEqual(foo, 'blog');
				assert.strictEqual(bar, null);
			});
		});
	});
});<commit_msg>Create test() method and reduce duplication across tests.<commit_after>var assert = chai.assert;
var router = new RouterRouter();

var test = function(url, route, callback) {
	router.location = new Location(url);

	router.route(route, callback);
};

// Override browser's native Location object. See:
// https://github.com/jashkenas/backbone/blob/master/test/router.js#L13-L41
var Location = function(href) {
	this.replace(href);
};

Location.prototype = {
	parser: document.createElement('a'),

	replace: function(href) {
		this.parser.href = href;

		this.href = this.parser.href;
		this.hash = this.parser.hash;
		this.host = this.parser.host;
		this.search = this.parser.search;
		this.fragment = this.parser.fragment;
		this.pathname = this.parser.pathname;
		this.protocol = this.parser.protocol;

		// In IE, anchor.pathname does not contain a leading slash though
		// window.location.pathname does.
		if (!/^\//.test(this.pathname)) this.pathname = '/' + this.pathname;
	},

	toString: function() {
		return this.href;
	}
};

describe('RouterRouter', function() {
	it('should match an empty string.', function() {
		test('http://example.com', '', function() {
			assert.ok(true);
		});
	});

	it('should match a string.', function() {
		test('http://example.com/foo', 'foo', function() {
			assert.ok(true);
		});
	});

	it('should match a string with Unicode characters.', function() {
		test('http://example.com/motleycrüe', 'motleycrüe', function() {
			assert.ok(true);
		});
	});

	it('should match a string with newline characters.', function() {
		test('http://example.com/foo%0Abar', 'foo\nbar', function() {
			assert.ok(true);
		});
	});

	it('should match parameter parts.', function() {
		test('http://example.com/1/2/3', ':foo/:bar/:biz', function(foo, bar, biz) {
			assert.strictEqual(foo, '1');
			assert.strictEqual(bar, '2');
			assert.strictEqual(biz, '3');
		});
	});

	it('should match splat parts.', function() {
		test('http://example.com/path/to/some/file.txt', 'path/*foo', function(foo) {
			assert.strictEqual(foo, 'to/some/file.txt');
		});
	});

	describe('should match optional parts and', function() {
		it('returns the optional part when an optional part matches.', function() {
			test('http://example.com/blog/sample-post-title', ':foo(/:bar)', function(foo, bar) {
				assert.strictEqual(foo, 'blog');
				assert.strictEqual(bar, 'sample-post-title');
			});
		});

		it('returns null when an optional part does not match.', function() {
			test('http://example.com/blog', ':foo(/:bar)', function(foo, bar) {
				assert.strictEqual(foo, 'blog');
				assert.strictEqual(bar, null);
			});
		});
	});
});<|endoftext|>


<commit_before>"use strict";

// Check if .env file exists, and load values. But do not fail if it doesn't!
require('dotenv').config({silent: true});

var EventSearch = require("../index");
var path = require("path");
var fs = require("fs");
var Promise = require("bluebird");
var chai = require("chai");
var should = chai.should();
var chaiAsPromised = require("chai-as-promised");
var Ajv = require("ajv");
var ajv = new Ajv();

chai.use(chaiAsPromised);

chai.config.includeStack = false;

describe("# Testing the facebook-events-by-location-core functionality", function() {

    var accessToken = process.env.FEBL_ACCESS_TOKEN;

    // Reset access token env variable
    process.env.FEBL_ACCESS_TOKEN = "";

    describe("## Basic functionality testing", function () {

        it("should return a list of events for a popular coordinate (Brooklyn, NY)", function (done) {

            // Set timeout
            this.timeout(5000);

            var es = new EventSearch({
                "lat": 40.710803,
                "lng": -73.964040,
                "distance": 1000,
                "accessToken": accessToken
            });

            es.search().should.be.fulfilled.and.notify(done);

        });

        it("should return an error if no Access Token is present", function (done) {

            var es = new EventSearch({
                "lat": 40.710803,
                "lng": -73.964040,
                "distance": 1000
            });

            es.search().should.be.rejectedWith(1).and.notify(done);

        });

        it("should return an error if a partial coordinate is used", function (done) {

            var es = new EventSearch({
                "lat": 40.710803,
                "accessToken": accessToken
            });

            es.search().should.be.rejectedWith(2).and.notify(done);

        });

        it("should return a valid JSON schema", function (done) {

            var schema = JSON.parse(fs.readFileSync(path.join(__dirname, "../", "schema", "events-response.schema.json"), "utf8"));

            var es = new EventSearch({
                "lat": 40.710803,
                "lng": -73.964040,
                "distance": 1000,
                "accessToken": accessToken
            });

            es.search().then( function (events) {
                var validate = ajv.compile(schema);
                var valid = validate(events);
                return new Promise(function (resolve, reject) {
                    if (!valid) {
                        reject(validate.errors);
                    } else {
                        resolve(valid);
                    }
                });
            }).should.be.fulfilled.and.notify(done);

        });

    });

});

<commit_msg>Increase timeouts<commit_after>"use strict";

// Check if .env file exists, and load values. But do not fail if it doesn't!
require('dotenv').config({silent: true});

var EventSearch = require("../index");
var path = require("path");
var fs = require("fs");
var Promise = require("bluebird");
var chai = require("chai");
var should = chai.should();
var chaiAsPromised = require("chai-as-promised");
var Ajv = require("ajv");
var ajv = new Ajv();

chai.use(chaiAsPromised);

chai.config.includeStack = false;

describe("# Testing the facebook-events-by-location-core functionality", function() {

    var accessToken = process.env.FEBL_ACCESS_TOKEN;

    // Reset access token env variable
    process.env.FEBL_ACCESS_TOKEN = "";

    describe("## Basic functionality testing", function () {

        it("should return a list of events for a popular coordinate (Brooklyn, NY)", function (done) {

            // Set timeout
            this.timeout(10000);

            var es = new EventSearch({
                "lat": 40.710803,
                "lng": -73.964040,
                "distance": 1000,
                "accessToken": accessToken
            });

            es.search().should.be.fulfilled.and.notify(done);

        });

        it("should return an error if no Access Token is present", function (done) {

            var es = new EventSearch({
                "lat": 40.710803,
                "lng": -73.964040,
                "distance": 1000
            });

            es.search().should.be.rejectedWith(1).and.notify(done);

        });

        it("should return an error if a partial coordinate is used", function (done) {

            var es = new EventSearch({
                "lat": 40.710803,
                "accessToken": accessToken
            });

            es.search().should.be.rejectedWith(2).and.notify(done);

        });

        it("should return a valid JSON schema", function (done) {

            // Set timeout
            this.timeout(10000);

            var schema = JSON.parse(fs.readFileSync(path.join(__dirname, "../", "schema", "events-response.schema.json"), "utf8"));

            var es = new EventSearch({
                "lat": 40.710803,
                "lng": -73.964040,
                "distance": 1000,
                "accessToken": accessToken
            });

            es.search().then( function (events) {
                var validate = ajv.compile(schema);
                var valid = validate(events);
                return new Promise(function (resolve, reject) {
                    if (!valid) {
                        reject(validate.errors);
                    } else {
                        resolve(valid);
                    }
                });
            }).should.be.fulfilled.and.notify(done);

        });

    });

});

<|endoftext|>


<commit_before>// Opening for events
const eventTitle = getElementByClassName('event-title', 0)
const eventSubtitle = getElementByClassName('event-subtitle', 0)
const eventDetails = getElementByClassName('event-details', 0)
// Remove display classes on init for hero tabs
eventTitle.classList.remove('fade-move')
eventSubtitle.classList.remove('fade-move')
eventDetails.classList.remove('fade-move')
// Fade in first slide
eventTitle.classList.add('display')
eventSubtitle.classList.add('display')
eventDetails.classList.add('display')
// Email signup form
setTimeout(() => changeEmailContainerBackground(getElementByClassName('email-container-background', 0)), 600)

// Event listener for if reg form is closed
const regFormModal = getElementByClassName('modal-status registration', 0)
const regFormModalWindow = getElementByClassName('modal registration', 0)
const regFormButtons = getElementsByClassName('button register')
for (let i = 0; i < regFormButtons.length; i++) {
	onClick(regFormButtons[i], () => {
		// Prevent background from scrolling
		document.body.style.overflow = 'hidden'
		// Prepare for fade in
		regFormModalWindow.style.opacity = '0'
		// Unhide modal
		setTimeout(() => regFormModal.style.display = 'block', 100)
		// Fade in modal window
		setTimeout(() => regFormModalWindow.style.opacity = '1.0', 200)
		// Show reg form: browser error that doesn’t show opacity of children unless scrolled to
		setTimeout(() => {
			showAndScrollTo(getElementByClassName('event-registration', 0))
		}, 300)
	})
}

const regFormClose = getElementByClassName('reg-form-close', 0)
onClick(regFormClose, () => {
	document.body.style.overflow = 'visible'
	regFormModalWindow.style.opacity = '0'
	setTimeout(() => regFormModal.style.display = 'none', 200)
})

// Event summary “Read more...” expansion
getElementByClassName('text read-more', 0).addEventListener('mouseover', () => {
	hideElement(getElementByClassName('text read-more'))
	hideElement(getElementByClassName('text summary'))
	getElementByClassName('text description').classList.add('display')
	setTimeout(() => getElementByClassName('text description display').classList.add('fade'), 100)
})

// Prevent accidental submission of form through 'enter' key
onKeyPress(document, e => {
	if (isInput(e.target) && e.which === 13) {
		e.preventDefault()
		return false
	}
})

let countries = [{value:'AF',label:'Afghanistan'},{value:'AX',label:'Åland Islands'},{value:'AL',label:'Albania'},{value:'DZ',label:'Algeria'},{value:'AS',label:'American Samoa'},{value:'AD',label:'Andorra'},{value:'AO',label:'Angola'},{value:'AI',label:'Anguilla'},{value:'AQ',label:'Antarctica'},{value:'AG',label:'Antigua and Barbuda'},{value:'AR',label:'Argentina'},{value:'AM',label:'Armenia'},{value:'AW',label:'Aruba'},{value:'AU',label:'Australia'},{value:'AT',label:'Austria'},{value:'AZ',label:'Azerbaijan'},{value:'BS',label:'Bahamas'},{value:'BH',label:'Bahrain'},{value:'BD',label:'Bangladesh'},{value:'BB',label:'Barbados'},{value:'BY',label:'Belarus'},{value:'BE',label:'Belgium'},{value:'BZ',label:'Belize'},{value:'BJ',label:'Benin'},{value:'BM',label:'Bermuda'},{value:'BT',label:'Bhutan'},{value:'BO',label:'Bolivia'},{value:'BA',label:'Bosnia and Herzegovina'},{value:'BW',label:'Botswana'},{value:'BV',label:'Bouvet Island'},{value:'BR',label:'Brazil'},{value:'IO',label:'British Indian Ocean Territory'},{value:'BN',label:'Brunei Darussalam'},{value:'BG',label:'Bulgaria'},{value:'BF',label:'Burkina Faso'},{value:'BI',label:'Burundi'},{value:'KH',label:'Cambodia'},{value:'CM',label:'Cameroon'},{value:'CA',label:'Canada'},{value:'CV',label:'Cape Verde'},{value:'KY',label:'Cayman Islands'},{value:'CF',label:'Central African Republic'},{value:'TD',label:'Chad'},{value:'CL',label:'Chile'},{value:'CN',label:'China, People’s Republic of'},{value:'CX',label:'Christmas Island'},{value:'CC',label:'Cocos (Keeling) Islands'},{value:'CO',label:'Colombia'},{value:'KM',label:'Comoros'},{value:'CG',label:'Congo'},{value:'CD',label:'Congo, The Democratic Republic of the'},{value:'CK',label:'Cook Islands'},{value:'CR',label:'Costa Rica'},{value:'CI',label:'Cote D’Ivoire'},{value:'HR',label:'Croatia'},{value:'CU',label:'Cuba'},{value:'CY',label:'Cyprus'},{value:'CZ',label:'Czech Republic'},{value:'DK',label:'Denmark'},{value:'DJ',label:'Djibouti'},{value:'DM',label:'Dominica'},{value:'DO',label:'Dominican Republic'},{value:'EC',label:'Ecuador'},{value:'EG',label:'Egypt'},{value:'SV',label:'El Salvador'},{value:'GQ',label:'Equatorial Guinea'},{value:'ER',label:'Eritrea'},{value:'EE',label:'Estonia'},{value:'ET',label:'Ethiopia'},{value:'FK',label:'Falkland Islands (Malvinas)'},{value:'FO',label:'Faroe Islands'},{value:'FJ',label:'Fiji'},{value:'FI',label:'Finland'},{value:'FR',label:'France'},{value:'GF',label:'French Guiana'},{value:'PF',label:'French Polynesia'},{value:'TF',label:'French Southern Territories'},{value:'GA',label:'Gabon'},{value:'GM',label:'Gambia'},{value:'GE',label:'Georgia'},{value:'DE',label:'Germany'},{value:'GH',label:'Ghana'},{value:'GI',label:'Gibraltar'},{value:'GR',label:'Greece'},{value:'GL',label:'Greenland'},{value:'GD',label:'Grenada'},{value:'GP',label:'Guadeloupe'},{value:'GU',label:'Guam'},{value:'GT',label:'Guatemala'},{value:'GG',label:'Guernsey'},{value:'GN',label:'Guinea'},{value:'GW',label:'Guinea-Bissau'},{value:'GY',label:'Guyana'},{value:'HT',label:'Haiti'},{value:'HM',label:'Heard Island and Mcdonald Islands'},{value:'VA',label:'Holy See (Vatican City State)'},{value:'HN',label:'Honduras'},{value:'HK',label:'Hong Kong'},{value:'HU',label:'Hungary'},{value:'IS',label:'Iceland'},{value:'IN',label:'India'},{value:'ID',label:'Indonesia'},{value:'IR',label:'Iran, Islamic Republic Of'},{value:'IQ',label:'Iraq'},{value:'IE',label:'Ireland'},{value:'IM',label:'Isle of Man'},{value:'IL',label:'Israel'},{value:'IT',label:'Italy'},{value:'JM',label:'Jamaica'},{value:'JP',label:'Japan'},{value:'JE',label:'Jersey'},{value:'JO',label:'Jordan'},{value:'KZ',label:'Kazakhstan'},{value:'KE',label:'Kenya'},{value:'KI',label:'Kiribati'},{value:'KP',label:'Democratic People’s Republic of Korea'},{value:'KR',label:'Korea, Republic of'},{value:'XK',label:'Kosovo'},{value:'KW',label:'Kuwait'},{value:'KG',label:'Kyrgyzstan'},{value:'LA',label:'Lao People’s Democratic Republic'},{value:'LV',label:'Latvia'},{value:'LB',label:'Lebanon'},{value:'LS',label:'Lesotho'},{value:'LR',label:'Liberia'},{value:'LY',label:'Libyan Arab Jamahiriya'},{value:'LI',label:'Liechtenstein'},{value:'LT',label:'Lithuania'},{value:'LU',label:'Luxembourg'},{value:'MO',label:'Macao'},{value:'MK',label:'Macedonia, The Former Yugoslav Republic of'},{value:'MG',label:'Madagascar'},{value:'MW',label:'Malawi'},{value:'MY',label:'Malaysia'},{value:'MV',label:'Maldives'},{value:'ML',label:'Mali'},{value:'MT',label:'Malta'},{value:'MH',label:'Marshall Islands'},{value:'MQ',label:'Martinique'},{value:'MR',label:'Mauritania'},{value:'MU',label:'Mauritius'},{value:'YT',label:'Mayotte'},{value:'MX',label:'Mexico'},{value:'FM',label:'Micronesia, Federated States of'},{value:'MD',label:'Moldova, Republic of'},{value:'MC',label:'Monaco'},{value:'MN',label:'Mongolia'},{value:'ME',label:'Montenegro'},{value:'MS',label:'Montserrat'},{value:'MA',label:'Morocco'},{value:'MZ',label:'Mozambique'},{value:'MM',label:'Myanmar'},{value:'NA',label:'Namibia'},{value:'NR',label:'Nauru'},{value:'NP',label:'Nepal'},{value:'NL',label:'Netherlands'},{value:'AN',label:'Netherlands Antilles'},{value:'NC',label:'New Caledonia'},{value:'NZ',label:'New Zealand'},{value:'NI',label:'Nicaragua'},{value:'NE',label:'Niger'},{value:'NG',label:'Nigeria'},{value:'NU',label:'Niue'},{value:'NF',label:'Norfolk Island'},{value:'MP',label:'Northern Mariana Islands'},{value:'NO',label:'Norway'},{value:'OM',label:'Oman'},{value:'PK',label:'Pakistan'},{value:'PW',label:'Palau'},{value:'PS',label:'Palestine, State of'},{value:'PA',label:'Panama'},{value:'PG',label:'Papua New Guinea'},{value:'PY',label:'Paraguay'},{value:'PE',label:'Peru'},{value:'PH',label:'Philippines'},{value:'PN',label:'Pitcairn'},{value:'PL',label:'Poland'},{value:'PT',label:'Portugal'},{value:'PR',label:'Puerto Rico'},{value:'QA',label:'Qatar'},{value:'RE',label:'Reunion'},{value:'RO',label:'Romania'},{value:'RU',label:'Russian Federation'},{value:'RW',label:'Rwanda'},{value:'SH',label:'Saint Helena'},{value:'KN',label:'Saint Kitts and Nevis'},{value:'LC',label:'Saint Lucia'},{value:'PM',label:'Saint Pierre and Miquelon'},{value:'VC',label:'Saint Vincent and the Grenadines'},{value:'WS',label:'Samoa'},{value:'SM',label:'San Marino'},{value:'ST',label:'Sao Tome and Principe'},{value:'SA',label:'Saudi Arabia'},{value:'SN',label:'Senegal'},{value:'RS',label:'Serbia'},{value:'SC',label:'Seychelles'},{value:'SL',label:'Sierra Leone'},{value:'SG',label:'Singapore'},{value:'SK',label:'Slovakia'},{value:'SI',label:'Slovenia'},{value:'SB',label:'Solomon Islands'},{value:'SO',label:'Somalia'},{value:'ZA',label:'South Africa'},{value:'GS',label:'South Georgia and the South Sandwich Islands'},{value:'ES',label:'Spain'},{value:'LK',label:'Sri Lanka'},{value:'SD',label:'Sudan'},{value:'SR',label:'Suriname'},{value:'SJ',label:'Svalbard and Jan Mayen'},{value:'SZ',label:'Swaziland'},{value:'SE',label:'Sweden'},{value:'CH',label:'Switzerland'},{value:'SY',label:'Syrian Arab Republic'},{value:'TW',label:'Taiwan, Republic of China'},{value:'TJ',label:'Tajikistan'},{value:'TZ',label:'Tanzania, United Republic of'},{value:'TH',label:'Thailand'},{value:'TL',label:'Timor-Leste'},{value:'TG',label:'Togo'},{value:'TK',label:'Tokelau'},{value:'TO',label:'Tonga'},{value:'TT',label:'Trinidad and Tobago'},{value:'TN',label:'Tunisia'},{value:'TR',label:'Turkey'},{value:'TM',label:'Turkmenistan'},{value:'TC',label:'Turks and Caicos Islands'},{value:'TV',label:'Tuvalu'},{value:'UG',label:'Uganda'},{value:'UA',label:'Ukraine'},{value:'AE',label:'United Arab Emirates'},{value:'GB',label:'United Kingdom'},{value:'US',label:'United States'},{value:'UM',label:'United States Minor Outlying Islands'},{value:'UY',label:'Uruguay'},{value:'UZ',label:'Uzbekistan'},{value:'VU',label:'Vanuatu'},{value:'VE',label:'Venezuela'},{value:'VN',label:'Viet Nam'},{value:'VG',label:'Virgin Islands, British'},{value:'VI',label:'Virgin Islands, U.S.'},{value:'WF',label:'Wallis and Futuna'},{value:'EH',label:'Western Sahara'},{value:'YE',label:'Yemen'},{value:'ZM',label:'Zambia'},{value:'ZW',label:'Zimbabwe'}]

// Countries
if (getElementById('country')) {
	for(let i in countries) {
		let option = document.createElement('option')
		option.text = countries[i].label
		option.value = countries[i].value
		option.selected = countries[i] === 'United States'
			? true
			: false
		appendSelect(getElementById('country'), option)
	}
}

// Load reg form scripts
const baseScriptUrl = 'https://ecstaticliving.github.io/ecstaticliving.com/dev/events/'
const scripts = ['elements', 'functions', 'onchange', 'webflow', 'payment']
// Load scripts synchronously, one after another, to make sure hierarchy is respected.
const loadScript = index => {
	let js = document.createElement('script')
	js.src = baseScriptUrl + scripts[index] + '.js'
	js.onload = () => {
		// Once final script has loaded, initialise
		if (scripts[index] === 'payment' && (page() === 'Event' || page() === 'Update')) {
			resetForm()
			scriptsHaveBeenLoaded = true
		}
		else {
			loadScript(index + 1)
		}
	}
	document.head.appendChild(js)
}
loadScript(0)
<commit_msg>Reg form modal display.<commit_after>// Opening for events
const eventTitle = getElementByClassName('event-title', 0)
const eventSubtitle = getElementByClassName('event-subtitle', 0)
const eventDetails = getElementByClassName('event-details', 0)
// Remove display classes on init for hero tabs
eventTitle.classList.remove('fade-move')
eventSubtitle.classList.remove('fade-move')
eventDetails.classList.remove('fade-move')
// Fade in first slide
eventTitle.classList.add('display')
eventSubtitle.classList.add('display')
eventDetails.classList.add('display')
// Email signup form
setTimeout(() => changeEmailContainerBackground(getElementByClassName('email-container-background', 0)), 600)

// Event listener for if reg form is closed
const regFormModal = getElementByClassName('modal-status registration', 0)
const regFormModalWindow = getElementByClassName('modal registration', 0)
const regFormButtons = getElementsByClassName('button register')
for (let i = 0; i < regFormButtons.length; i++) {
	onClick(regFormButtons[i], () => {
		// Prevent background from scrolling
		document.body.style.overflow = 'hidden'
		// Prepare for fade in
		regFormModalWindow.style.opacity = '0'
		// Unhide modal
		setTimeout(() => regFormModal.style.display = 'block', 100)
		// Fade in modal window
		setTimeout(() => regFormModalWindow.style.opacity = '1.0', 200)
		// Show reg form: browser error that doesn’t show opacity of children unless scrolled to
		setTimeout(() => {
			showAndScrollTo(getElementByClassName('reg-form', 0))
		}, 300)
	})
}

const regFormClose = getElementByClassName('reg-form-close', 0)
onClick(regFormClose, () => {
	document.body.style.overflow = 'visible'
	regFormModalWindow.style.opacity = '0'
	setTimeout(() => regFormModal.style.display = 'none', 200)
})

// Event summary “Read more...” expansion
getElementByClassName('text read-more', 0).addEventListener('mouseover', () => {
	hideElement(getElementByClassName('text read-more'))
	hideElement(getElementByClassName('text summary'))
	getElementByClassName('text description').classList.add('display')
	setTimeout(() => getElementByClassName('text description display').classList.add('fade'), 100)
})

// Prevent accidental submission of form through 'enter' key
onKeyPress(document, e => {
	if (isInput(e.target) && e.which === 13) {
		e.preventDefault()
		return false
	}
})

let countries = [{value:'AF',label:'Afghanistan'},{value:'AX',label:'Åland Islands'},{value:'AL',label:'Albania'},{value:'DZ',label:'Algeria'},{value:'AS',label:'American Samoa'},{value:'AD',label:'Andorra'},{value:'AO',label:'Angola'},{value:'AI',label:'Anguilla'},{value:'AQ',label:'Antarctica'},{value:'AG',label:'Antigua and Barbuda'},{value:'AR',label:'Argentina'},{value:'AM',label:'Armenia'},{value:'AW',label:'Aruba'},{value:'AU',label:'Australia'},{value:'AT',label:'Austria'},{value:'AZ',label:'Azerbaijan'},{value:'BS',label:'Bahamas'},{value:'BH',label:'Bahrain'},{value:'BD',label:'Bangladesh'},{value:'BB',label:'Barbados'},{value:'BY',label:'Belarus'},{value:'BE',label:'Belgium'},{value:'BZ',label:'Belize'},{value:'BJ',label:'Benin'},{value:'BM',label:'Bermuda'},{value:'BT',label:'Bhutan'},{value:'BO',label:'Bolivia'},{value:'BA',label:'Bosnia and Herzegovina'},{value:'BW',label:'Botswana'},{value:'BV',label:'Bouvet Island'},{value:'BR',label:'Brazil'},{value:'IO',label:'British Indian Ocean Territory'},{value:'BN',label:'Brunei Darussalam'},{value:'BG',label:'Bulgaria'},{value:'BF',label:'Burkina Faso'},{value:'BI',label:'Burundi'},{value:'KH',label:'Cambodia'},{value:'CM',label:'Cameroon'},{value:'CA',label:'Canada'},{value:'CV',label:'Cape Verde'},{value:'KY',label:'Cayman Islands'},{value:'CF',label:'Central African Republic'},{value:'TD',label:'Chad'},{value:'CL',label:'Chile'},{value:'CN',label:'China, People’s Republic of'},{value:'CX',label:'Christmas Island'},{value:'CC',label:'Cocos (Keeling) Islands'},{value:'CO',label:'Colombia'},{value:'KM',label:'Comoros'},{value:'CG',label:'Congo'},{value:'CD',label:'Congo, The Democratic Republic of the'},{value:'CK',label:'Cook Islands'},{value:'CR',label:'Costa Rica'},{value:'CI',label:'Cote D’Ivoire'},{value:'HR',label:'Croatia'},{value:'CU',label:'Cuba'},{value:'CY',label:'Cyprus'},{value:'CZ',label:'Czech Republic'},{value:'DK',label:'Denmark'},{value:'DJ',label:'Djibouti'},{value:'DM',label:'Dominica'},{value:'DO',label:'Dominican Republic'},{value:'EC',label:'Ecuador'},{value:'EG',label:'Egypt'},{value:'SV',label:'El Salvador'},{value:'GQ',label:'Equatorial Guinea'},{value:'ER',label:'Eritrea'},{value:'EE',label:'Estonia'},{value:'ET',label:'Ethiopia'},{value:'FK',label:'Falkland Islands (Malvinas)'},{value:'FO',label:'Faroe Islands'},{value:'FJ',label:'Fiji'},{value:'FI',label:'Finland'},{value:'FR',label:'France'},{value:'GF',label:'French Guiana'},{value:'PF',label:'French Polynesia'},{value:'TF',label:'French Southern Territories'},{value:'GA',label:'Gabon'},{value:'GM',label:'Gambia'},{value:'GE',label:'Georgia'},{value:'DE',label:'Germany'},{value:'GH',label:'Ghana'},{value:'GI',label:'Gibraltar'},{value:'GR',label:'Greece'},{value:'GL',label:'Greenland'},{value:'GD',label:'Grenada'},{value:'GP',label:'Guadeloupe'},{value:'GU',label:'Guam'},{value:'GT',label:'Guatemala'},{value:'GG',label:'Guernsey'},{value:'GN',label:'Guinea'},{value:'GW',label:'Guinea-Bissau'},{value:'GY',label:'Guyana'},{value:'HT',label:'Haiti'},{value:'HM',label:'Heard Island and Mcdonald Islands'},{value:'VA',label:'Holy See (Vatican City State)'},{value:'HN',label:'Honduras'},{value:'HK',label:'Hong Kong'},{value:'HU',label:'Hungary'},{value:'IS',label:'Iceland'},{value:'IN',label:'India'},{value:'ID',label:'Indonesia'},{value:'IR',label:'Iran, Islamic Republic Of'},{value:'IQ',label:'Iraq'},{value:'IE',label:'Ireland'},{value:'IM',label:'Isle of Man'},{value:'IL',label:'Israel'},{value:'IT',label:'Italy'},{value:'JM',label:'Jamaica'},{value:'JP',label:'Japan'},{value:'JE',label:'Jersey'},{value:'JO',label:'Jordan'},{value:'KZ',label:'Kazakhstan'},{value:'KE',label:'Kenya'},{value:'KI',label:'Kiribati'},{value:'KP',label:'Democratic People’s Republic of Korea'},{value:'KR',label:'Korea, Republic of'},{value:'XK',label:'Kosovo'},{value:'KW',label:'Kuwait'},{value:'KG',label:'Kyrgyzstan'},{value:'LA',label:'Lao People’s Democratic Republic'},{value:'LV',label:'Latvia'},{value:'LB',label:'Lebanon'},{value:'LS',label:'Lesotho'},{value:'LR',label:'Liberia'},{value:'LY',label:'Libyan Arab Jamahiriya'},{value:'LI',label:'Liechtenstein'},{value:'LT',label:'Lithuania'},{value:'LU',label:'Luxembourg'},{value:'MO',label:'Macao'},{value:'MK',label:'Macedonia, The Former Yugoslav Republic of'},{value:'MG',label:'Madagascar'},{value:'MW',label:'Malawi'},{value:'MY',label:'Malaysia'},{value:'MV',label:'Maldives'},{value:'ML',label:'Mali'},{value:'MT',label:'Malta'},{value:'MH',label:'Marshall Islands'},{value:'MQ',label:'Martinique'},{value:'MR',label:'Mauritania'},{value:'MU',label:'Mauritius'},{value:'YT',label:'Mayotte'},{value:'MX',label:'Mexico'},{value:'FM',label:'Micronesia, Federated States of'},{value:'MD',label:'Moldova, Republic of'},{value:'MC',label:'Monaco'},{value:'MN',label:'Mongolia'},{value:'ME',label:'Montenegro'},{value:'MS',label:'Montserrat'},{value:'MA',label:'Morocco'},{value:'MZ',label:'Mozambique'},{value:'MM',label:'Myanmar'},{value:'NA',label:'Namibia'},{value:'NR',label:'Nauru'},{value:'NP',label:'Nepal'},{value:'NL',label:'Netherlands'},{value:'AN',label:'Netherlands Antilles'},{value:'NC',label:'New Caledonia'},{value:'NZ',label:'New Zealand'},{value:'NI',label:'Nicaragua'},{value:'NE',label:'Niger'},{value:'NG',label:'Nigeria'},{value:'NU',label:'Niue'},{value:'NF',label:'Norfolk Island'},{value:'MP',label:'Northern Mariana Islands'},{value:'NO',label:'Norway'},{value:'OM',label:'Oman'},{value:'PK',label:'Pakistan'},{value:'PW',label:'Palau'},{value:'PS',label:'Palestine, State of'},{value:'PA',label:'Panama'},{value:'PG',label:'Papua New Guinea'},{value:'PY',label:'Paraguay'},{value:'PE',label:'Peru'},{value:'PH',label:'Philippines'},{value:'PN',label:'Pitcairn'},{value:'PL',label:'Poland'},{value:'PT',label:'Portugal'},{value:'PR',label:'Puerto Rico'},{value:'QA',label:'Qatar'},{value:'RE',label:'Reunion'},{value:'RO',label:'Romania'},{value:'RU',label:'Russian Federation'},{value:'RW',label:'Rwanda'},{value:'SH',label:'Saint Helena'},{value:'KN',label:'Saint Kitts and Nevis'},{value:'LC',label:'Saint Lucia'},{value:'PM',label:'Saint Pierre and Miquelon'},{value:'VC',label:'Saint Vincent and the Grenadines'},{value:'WS',label:'Samoa'},{value:'SM',label:'San Marino'},{value:'ST',label:'Sao Tome and Principe'},{value:'SA',label:'Saudi Arabia'},{value:'SN',label:'Senegal'},{value:'RS',label:'Serbia'},{value:'SC',label:'Seychelles'},{value:'SL',label:'Sierra Leone'},{value:'SG',label:'Singapore'},{value:'SK',label:'Slovakia'},{value:'SI',label:'Slovenia'},{value:'SB',label:'Solomon Islands'},{value:'SO',label:'Somalia'},{value:'ZA',label:'South Africa'},{value:'GS',label:'South Georgia and the South Sandwich Islands'},{value:'ES',label:'Spain'},{value:'LK',label:'Sri Lanka'},{value:'SD',label:'Sudan'},{value:'SR',label:'Suriname'},{value:'SJ',label:'Svalbard and Jan Mayen'},{value:'SZ',label:'Swaziland'},{value:'SE',label:'Sweden'},{value:'CH',label:'Switzerland'},{value:'SY',label:'Syrian Arab Republic'},{value:'TW',label:'Taiwan, Republic of China'},{value:'TJ',label:'Tajikistan'},{value:'TZ',label:'Tanzania, United Republic of'},{value:'TH',label:'Thailand'},{value:'TL',label:'Timor-Leste'},{value:'TG',label:'Togo'},{value:'TK',label:'Tokelau'},{value:'TO',label:'Tonga'},{value:'TT',label:'Trinidad and Tobago'},{value:'TN',label:'Tunisia'},{value:'TR',label:'Turkey'},{value:'TM',label:'Turkmenistan'},{value:'TC',label:'Turks and Caicos Islands'},{value:'TV',label:'Tuvalu'},{value:'UG',label:'Uganda'},{value:'UA',label:'Ukraine'},{value:'AE',label:'United Arab Emirates'},{value:'GB',label:'United Kingdom'},{value:'US',label:'United States'},{value:'UM',label:'United States Minor Outlying Islands'},{value:'UY',label:'Uruguay'},{value:'UZ',label:'Uzbekistan'},{value:'VU',label:'Vanuatu'},{value:'VE',label:'Venezuela'},{value:'VN',label:'Viet Nam'},{value:'VG',label:'Virgin Islands, British'},{value:'VI',label:'Virgin Islands, U.S.'},{value:'WF',label:'Wallis and Futuna'},{value:'EH',label:'Western Sahara'},{value:'YE',label:'Yemen'},{value:'ZM',label:'Zambia'},{value:'ZW',label:'Zimbabwe'}]

// Countries
if (getElementById('country')) {
	for(let i in countries) {
		let option = document.createElement('option')
		option.text = countries[i].label
		option.value = countries[i].value
		option.selected = countries[i] === 'United States'
			? true
			: false
		appendSelect(getElementById('country'), option)
	}
}

// Load reg form scripts
const baseScriptUrl = 'https://ecstaticliving.github.io/ecstaticliving.com/dev/events/'
const scripts = ['elements', 'functions', 'onchange', 'webflow', 'payment']
// Load scripts synchronously, one after another, to make sure hierarchy is respected.
const loadScript = index => {
	let js = document.createElement('script')
	js.src = baseScriptUrl + scripts[index] + '.js'
	js.onload = () => {
		// Once final script has loaded, initialise
		if (scripts[index] === 'payment' && (page() === 'Event' || page() === 'Update')) {
			resetForm()
			scriptsHaveBeenLoaded = true
		}
		else {
			loadScript(index + 1)
		}
	}
	document.head.appendChild(js)
}
loadScript(0)
<|endoftext|>