<commit_before>var expect = require('chai').expect;
//var metacarattere = require('../index.js');

module.exports = function(metacarattere) {

    describe('Export', function() {

        it('should export a (constructor) function', function(){
            expect(metacarattere).to.be.a('function');
        });

    });

    describe('Exported function', function() {

        it('should return undefined when invoked', function() {
            expect( metacarattere(':pattern') ).to.be.undefined;
        });

        it('should return an object when invoked with new', function() {
            expect( new metacarattere(':pattern') ).to.be.an('object');
        });

        it('should not throw if no argument is given', function() {
            new metacarattere();        // That's all
        });

        it('should accept patterns w/out placeholders', function(){
            var inst = new metacarattere('pattern');
        });

    });

    describe('metacarattere instance', function() {

        describe('matches() function', function() {

            it('should exist', function() {
                var inst = new metacarattere(':pattern');

                expect( inst.matches ).to.be.a('function');
            });

            it('should return false if arguments are given', function() {

                var inst = new metacarattere(':pattern');
                expect( inst.matches() ).to.be.false;
            });

            it('should return false if it does not match', function() {
                var inst = new metacarattere('/a/b/c');

                ['/a','a/b/c/d/e'].forEach( function(url) {
                    expect( inst.matches(url) ).to.be.false;
                });
            });

            it('should return true if it does match', function() {
                var inst = new metacarattere('/a/:b/:c');

                ['/a/3/4','/a/true/false','/a/hello/world'].forEach( function(url) {
                    expect(inst.matches(url)).to.be.true;
                });
            });

            it('should not match partly', function(){
                var inst = new metacarattere("/vendor/:name/product/:prod");

                expect( inst.matches('/vendor/apple') ).to.be.false;
                expect( inst.matches('/vendor/apple/product/macbookair') ).to.be.true;
                expect( inst.matches('/vendor/microsoft/product/codeplex/accounts/locked') ).to.be.false;
            });

            it('should not match when no pattern is given', function() {
                var inst = new metacarattere();

                ['/a/3/4','/api/true/false','/collection/hello/world'].forEach( function(url) {
                    expect(inst.matches(url)).to.be.false;
                });
            });

        });

        describe('parse() function', function() {

            it('should exist', function(){
                var inst = new metacarattere(':pattern');

                expect( inst.parse ).to.be.a('function');
            });

            it('should return null if no arguments are given', function() {

                var inst = new metacarattere(':pattern');
                expect( inst.parse() ).to.be.null;
            });

            it('should return null if it does not match', function() {
                var inst = new metacarattere('/a/b/c');

                ['/a','a/b/c/d/e'].forEach( function(url) {
                    expect( inst.parse(url) ).to.be.null;
                });
            });

            it('should return an object w/ key-value-paris if it does match', function() {
                var inst = new metacarattere('/a/:b/:c');

                expect( inst.parse('/a/3/4') ).to.deep.equal( { b: '3', c: '4' } );
                expect( inst.parse('/a/hello/world') ).to.deep.equal( { b: 'hello', c: 'world' } );
            });

            it('should not match partly', function(){
                var inst = new metacarattere("/vendor/:name/product/:prod");

                expect( inst.parse('/vendor/apple') ).not.to.exist;
                expect( inst.parse('/vendor/apple/product/macbookair') ).to.be.an('object');
                expect( inst.parse('/vendor/apple/product/macbookair') ).to.deep.equal( { "name": "apple", "prod": "macbookair" } );
                expect( inst.parse('/vendor/microsoft/product/codeplex/accounts/locked') ).not.to.exist;
            });

            it('should return false if no pattern was given', function() {
                var inst = new metacarattere();

                ['/a/3/4','/api/true/false','/collection/hello/world'].forEach( function(url) {
                    expect(inst.matches(url)).to.be.false;
                });
            });

        });

        describe('getPattern() function', function() {
            it('should exist', function() {
                var inst = new metacarattere('/:pattern');

                expect( inst.getPattern ).to.be.a('function');
            });

            it('should return the original pattern', function() {
                [ '/prod/:id', '/a/b/c/d/', '/version/key/:abc'].forEach(function(pattern) {
                    var inst = new metacarattere(pattern);
                    expect( inst.getPattern() ).to.equal(pattern);
                });
            });
        });

        describe('getPlaceholders() function', function() {
            it('should exist', function() {
                var inst = new metacarattere('/:pattern');

                expect( inst.getPlaceholders ).to.be.a('function');
            });

            it('should return the placeholders', function() {
                [
                    { pattern: '/prod/:id', placeholders: ['id'] },
                    { pattern: '/a/b/c/d', placeholders: [] },
                    { pattern: '/:version/:key/:abc', placeholders: ['version','key','abc'] },
                    { pattern: '', placeholders: [] },
                    { pattern: undefined, placeholders: [] },
                    { pattern: null, placeholders: [] }

                ].forEach(function(what) {
                    var inst = new metacarattere(what.pattern);
                    expect( inst.getPlaceholders() ).to.eql(what.placeholders);
                });
            });
        });

        describe('getExpression() function', function() {
            it('should exist', function() {
                var inst = new metacarattere('/:pattern');

                expect( inst.getExpression ).to.be.a('function');
            });

            it('should return the compiled regex', function() {

                [
                    { pattern: '/prod/:id', regex: '^/prod/([^\/]+)$' },
                    { pattern: '/a/b/c/d', regex: '^/a/b/c/d$' },
                    { pattern: '/:version/:key/:abc', regex: '^/([^\/]+)/([^\/]+)/([^\/]+)$' },
                    { pattern: '',  regex: '^$' },
                    { pattern: undefined,  regex: '^(?!)$' },
                    { pattern: null,  regex: '^(?!)$' }

                ].forEach(function(what) {
                    var inst = new metacarattere(what.pattern);
                    expect( inst.getPlaceholders() ).to.eql(what.placeholders);
                });
            });
        });

    });

};
<commit_msg>Tests fixed<commit_after>var expect = require('chai').expect;
//var metacarattere = require('../index.js');

module.exports = function(metacarattere) {

    describe('Export', function() {

        it('should export a (constructor) function', function(){
            expect(metacarattere).to.be.a('function');
        });

    });

    describe('Exported function', function() {

        it('should return undefined when invoked', function() {
            expect( metacarattere(':pattern') ).to.be.undefined;
        });

        it('should return an object when invoked with new', function() {
            expect( new metacarattere(':pattern') ).to.be.an('object');
        });

        it('should not throw if no argument is given', function() {
            new metacarattere();        // That's all
        });

        it('should accept patterns w/out placeholders', function(){
            var inst = new metacarattere('pattern');
        });

    });

    describe('metacarattere instance', function() {

        describe('matches() function', function() {

            it('should exist', function() {
                var inst = new metacarattere(':pattern');

                expect( inst.matches ).to.be.a('function');
            });

            it('should return false if arguments are given', function() {

                var inst = new metacarattere(':pattern');
                expect( inst.matches() ).to.be.false;
            });

            it('should return false if it does not match', function() {
                var inst = new metacarattere('/a/b/c');

                ['/a','a/b/c/d/e'].forEach( function(url) {
                    expect( inst.matches(url) ).to.be.false;
                });
            });

            it('should return true if it does match', function() {
                var inst = new metacarattere('/a/:b/:c');

                ['/a/3/4','/a/true/false','/a/hello/world'].forEach( function(url) {
                    expect(inst.matches(url)).to.be.true;
                });
            });

            it('should not match partly', function(){
                var inst = new metacarattere("/vendor/:name/product/:prod");

                expect( inst.matches('/vendor/apple') ).to.be.false;
                expect( inst.matches('/vendor/apple/product/macbookair') ).to.be.true;
                expect( inst.matches('/vendor/microsoft/product/codeplex/accounts/locked') ).to.be.false;
            });

            it('should not match when no pattern is given', function() {
                var inst = new metacarattere();

                ['/a/3/4','/api/true/false','/collection/hello/world'].forEach( function(url) {
                    expect(inst.matches(url)).to.be.false;
                });
            });

        });

        describe('parse() function', function() {

            it('should exist', function(){
                var inst = new metacarattere(':pattern');

                expect( inst.parse ).to.be.a('function');
            });

            it('should return null if no arguments are given', function() {

                var inst = new metacarattere(':pattern');
                expect( inst.parse() ).to.be.null;
            });

            it('should return null if it does not match', function() {
                var inst = new metacarattere('/a/b/c');

                ['/a','a/b/c/d/e'].forEach( function(url) {
                    expect( inst.parse(url) ).to.be.null;
                });
            });

            it('should return an object w/ key-value-paris if it does match', function() {
                var inst = new metacarattere('/a/:b/:c');

                expect( inst.parse('/a/3/4') ).to.deep.equal( { b: '3', c: '4' } );
                expect( inst.parse('/a/hello/world') ).to.deep.equal( { b: 'hello', c: 'world' } );
            });

            it('should not match partly', function(){
                var inst = new metacarattere("/vendor/:name/product/:prod");

                expect( inst.parse('/vendor/apple') ).not.to.exist;
                expect( inst.parse('/vendor/apple/product/macbookair') ).to.be.an('object');
                expect( inst.parse('/vendor/apple/product/macbookair') ).to.deep.equal( { "name": "apple", "prod": "macbookair" } );
                expect( inst.parse('/vendor/microsoft/product/codeplex/accounts/locked') ).not.to.exist;
            });

            it('should return false if no pattern was given', function() {
                var inst = new metacarattere();

                ['/a/3/4','/api/true/false','/collection/hello/world'].forEach( function(url) {
                    expect(inst.matches(url)).to.be.false;
                });
            });

        });

        describe('getPattern() function', function() {
            it('should exist', function() {
                var inst = new metacarattere('/:pattern');

                expect( inst.getPattern ).to.be.a('function');
            });

            it('should return the original pattern', function() {
                [ '/prod/:id', '/a/b/c/d/', '/version/key/:abc'].forEach(function(pattern) {
                    var inst = new metacarattere(pattern);
                    expect( inst.getPattern() ).to.equal(pattern);
                });
            });
        });

        describe('getPlaceholders() function', function() {
            it('should exist', function() {
                var inst = new metacarattere('/:pattern');

                expect( inst.getPlaceholders ).to.be.a('function');
            });

            it('should return the placeholders', function() {
                [
                    { pattern: '/prod/:id', placeholders: ['id'] },
                    { pattern: '/a/b/c/d', placeholders: [] },
                    { pattern: '/:version/:key/:abc', placeholders: ['version','key','abc'] },
                    { pattern: '', placeholders: [] },
                    { pattern: undefined, placeholders: [] },
                    { pattern: null, placeholders: [] }

                ].forEach(function(what) {
                    var inst = new metacarattere(what.pattern);
                    expect( inst.getPlaceholders() ).to.eql(what.placeholders);
                });
            });
        });

        describe('getExpression() function', function() {
            it('should exist', function() {
                var inst = new metacarattere('/:pattern');

                expect( inst.getExpression ).to.be.a('function');
            });

            it('should return the compiled regex', function() {

                [
                    { pattern: '/prod/:id', regex: new RegExp('^/prod/([^\/]+)$').toString() },
                    { pattern: '/a/b/c/d', regex: new RegExp('^/a/b/c/d$').toString() },
                    { pattern: '/:version/:key/:abc', regex: new RegExp('^/([^\/]+)/([^\/]+)/([^\/]+)$').toString() },
                    { pattern: '',  regex: new RegExp('^$').toString() },
                    { pattern: undefined,  regex: new RegExp('^(?!)$').toString() },
                    { pattern: null,  regex: new RegExp('^(?!)$').toString() }

                ].forEach(function(what) {
                    var inst = new metacarattere(what.pattern);
                    expect( inst.getExpression().toString() ).to.equal(what.regex);
                });
            });
        });

    });

};
<|endoftext|>


<commit_before>/*
 * grunt-version-file
 * https://github.com/cfogelberg/grunt-version-file
 *
 * Copyright (c) 2014 Christo Fogelberg
 * Licensed under the MIT license.
 */

 "use strict";

describe("GeneratorManager", function() {
  it.skip("builds a generator for each file in options.generator_dir", function() {
  });

  it.skip("throws an error when options.generator_dir is not specified", function() {
  });

  it.skip("requires an options.generator_list constructor argument", function() {
  });

  it.skip("throws an error when a specified generator is not in generator_dir", function() {
  });

  it.skip("throws an error when any unexpected options fields are defined", function() {
  });

  it.skip("allows iteration over all generators", function() {
  });
});
<commit_msg>GeneratorManager - initial tests<commit_after>/*
 * grunt-version-file
 * https://github.com/cfogelberg/grunt-version-file
 *
 * Copyright (c) 2014 Christo Fogelberg
 * Licensed under the MIT license.
 */
// Allow indirectly-executed (should-executed) function literals to pass jshint IIFE warning:
/*jshint -W068 */
// Allow expressions (...should.be.a.Foo;)
/*jshint -W030 */

 "use strict";

describe("GeneratorManager", function() {
  var GeneratorManager = require("../../lib/generator_manager");

  it("requires an options.generator_dir constructor argument", function() {
    (function() {
      var config_without_generator_dir = { generator_list: ["foo", "bar"] };
      var gm = new GeneratorManager(config_without_generator_dir);
    }).should.throw();
  });

  it("throws an error when options.generator_dir is not a string", function() {
    (function() {
      var config_without_generator_dir_string = { generator_list: ["foo", "bar"], generator_dir: 1 };
      var gm = new GeneratorManager(config_without_generator_dir_string);
    }).should.throw();
  });

  it.skip("throws an error when options.generator_dir does not exist", function() {
  });

  it("requires an options.generator_list constructor argument", function() {
  it("requires an options.generator_dir constructor argument", function() {
    (function() {
      var config_without_generator_list = { generator_dir: "foo" };
      var gm = new GeneratorManager(config_without_generator_list);
    }).should.throw();
  });
  });

  it("throws an error when options.generator_list is not an array", function() {
    (function() {
      var config_without_generator_list_array = { generator_dir: "foo", generator_list: "foo" };
      var gm = new GeneratorManager(config_without_generator_list_array);
    }).should.throw();
  });

  it.skip("builds a generator for each entry in options.generator_dir", function() {
  });

  it.skip("throws an error when a gen. list member is not in generator_dir", function() {
  });

  it("throws an error when any unexpected options fields are defined", function() {
    (function() {
      var config_with_extra_entry = { generator_dir: "foo", generator_list: ["bar", "baz"], extra: 1234 };
      var gm = new GeneratorManager(config_with_extra_entry);
    }).should.throw();
  });

  it.skip("allows iteration over all generators", function() {
  });
});
<|endoftext|>


<commit_before>/* jshint undef: false */
var assert = chai.assert;

describe("Initial Definition Check", function(){
	it("storage.set(object,callback) should accept an object of key/value pairs to be set into localStorage and respond with callback", function(done){
		assert.doesNotThrow(function(){
			storage.set({
				testkey: "helloworld"
			},function(result){
				if (result === true) {
					done();
				}
			});
		});
	});

	it("storage.get(object,callback) should accept an array of keys to be retrieved from localStorage and respond with callback", function(done){
		assert.doesNotThrow(function(){
			storage.get(["testkey"],function(result){
				if (result.testkey === "helloworld") {
					done();
				}
			});
		});
	});

	it("storage.remove(object,callback) should accept an array of keys to be deleted from localStorage and respond with callback", function(done){
		assert.doesNotThrow(function(){
			storage.remove(["testkey"],function(result){
				if (result === true) {
					done();
				}
			});
		});
		assert.doesNotThrow(function(){
			storage.remove("testkey",function(result){
				if (result === true) {
					done();
				}
			});
		});
	});
});

describe("OpenSprinkler Firmware Version Functions",function(){

	describe("Test against Arduino Firmware Version",function(){
		before(function(){
			controller.options = {
				fwv: 210
			};
		});
		it("isOPSi() should identify if the device is an OSPi",function(){
			assert.equal(false,isOSPi());
		});
		it("versionCompare(device,compare) should check the given firmware (device) against the compare firmware where the input is an array",function(){
			assert.strictEqual(false,versionCompare([1],[1,5]));
			assert.strictEqual(0,versionCompare([1,5],[1,5]));
			assert.strictEqual(1,versionCompare([2,1],[1,5]));
		});
		it("checkOSVersion(compare) should compare the input firmware version against the Arduino firmware version.",function(){
			assert.strictEqual(false,checkOSVersion(211));
			assert.strictEqual(true,checkOSVersion(210));
			assert.strictEqual(1,checkOSVersion(208));
		});
		it("checkOSPiVersion(compare) should compare the input firmware version against the OSPi firmware version.",function(){
			assert.strictEqual(false,checkOSPiVersion("2.0"));
			assert.strictEqual(false,checkOSPiVersion("1.9"));
			assert.strictEqual(false,checkOSPiVersion("2.1"));
		});
	});

	describe("Test against OSPi Firmware Version",function(){
		before(function(){
			controller.options = {
				fwv: "1.9.0-OSPi"
			};
		});
		it("isOPSi() should identify if the device is an OSPi",function(){
			assert.equal(true,isOSPi());
		});
		it("versionCompare(device,compare) should check the given firmware (device) against the compare firmware where the input is an array",function(){
			assert.strictEqual(false,versionCompare([1],[1,5]));
			assert.strictEqual(0,versionCompare([1,5],[1,5]));
			assert.strictEqual(1,versionCompare([2,1],[1,5]));
		});
		it("checkOSVersion(compare) should compare the input firmware version against the Arduino firmware version.",function(){
			assert.strictEqual(false,checkOSVersion(211));
			assert.strictEqual(false,checkOSVersion(210));
			assert.strictEqual(false,checkOSVersion(208));
		});
		it("checkOSPiVersion(compare) should compare the input firmware version against the OSPi firmware version.",function(){
			assert.strictEqual(1,checkOSPiVersion("1.8"));
			assert.strictEqual(true,checkOSPiVersion("1.9.0"));
			assert.strictEqual(false,checkOSPiVersion("2.0"));
			assert.strictEqual(false,checkOSPiVersion("2.1"));
		});
	});

	describe("Retrieve the formatted firmware version",function(){
		before(function(){
			controller.options = {
				fwv: 204
			};
		});
		it("getOSVersion(fwv) should return the firmware in a string representation",function(){
			assert.equal("1.8.3-OSPi",getOSVersion("1.8.3-OSPi"));
			assert.equal("2.1.193-OSPi",getOSVersion("2.1.193-OSPi"));
			assert.equal("2.0.8",getOSVersion(208));
			assert.equal("2.0.4",getOSVersion());
		});
	});
});

describe("General Function Checks", function(){
	it("colorContrast(color) should take rgb(r,g,b) and return the appropriate color contrast for the input color",function(){
		assert.equal("black",colorContrast("rgb(50,200,0)"));
		assert.equal("white",colorContrast("rgb(0,0,0)"));
	});

	it("parseIntArray(array) should convert all members into integers",function(){
		assert.deepEqual([9, 394, 29193, -1],parseIntArray(["9","394","29193","-1"]));
	});

	it("sec2hms(number) should return a string representation of the difference the input represents (seconds)",function(){
		assert.equal("23:59:59",sec2hms(86399));
		assert.equal("15:00",sec2hms(900));
	});

	it("sec2dhms(number) should return an object containing days, hours, minutes and seconds from the input (seconds)",function(){
		assert.deepEqual({
			days: 936,
			hours: 17,
			minutes: 20,
			seconds: 9
		}, sec2dhms(80932809));
	});

	it("dhms2str(object) should convert an object with elements days, hours, minutes and seconds into a string representation",function(){
		assert.equal("5d 4h 3m 1s",dhms2str({days:5,hours:4,minutes:3,seconds:1}));
		assert.equal("0s",dhms2str({}));
	});

	it("dhms2sec(object) should convert an object with elements days, hours, minutes and seconds into a second value",function(){
		assert.equal(100981,dhms2sec({days:1,hours:4,minutes:3,seconds:1}));
	});

	it("getDayName(day,type) should return the day of the week and can be of type 'short'",function(){
		assert.equal("Sunday",getDayName(new Date(1410745528126)));
		assert.equal("Thu",getDayName(new Date(1410445528126),"short"));
	});

	it("getUnique(array) should take any array and remove duplicates",function(){
		assert.deepEqual([0],getUnique([0,0]));
		assert.deepEqual([9992,"hello"],getUnique([9992,9992,"hello"]));
	});

	it("pad(number) should succesfully prepend a 0 to a single digit",function(){
		assert.equal("00", pad(0));
		assert.equal("01", pad(1));
		assert.equal("10", pad(10));
		assert.equal("999", pad(999));
	});
});
<commit_msg>Tests: Remove duplicate test<commit_after>/* jshint undef: false */
var assert = chai.assert;

describe("Initial Definition Check", function(){
	it("storage.set(object,callback) should accept an object of key/value pairs to be set into localStorage and respond with callback", function(done){
		assert.doesNotThrow(function(){
			storage.set({
				testkey: "helloworld"
			},function(result){
				if (result === true) {
					done();
				}
			});
		});
	});

	it("storage.get(object,callback) should accept an array of keys to be retrieved from localStorage and respond with callback", function(done){
		assert.doesNotThrow(function(){
			storage.get(["testkey"],function(result){
				if (result.testkey === "helloworld") {
					done();
				}
			});
		});
	});

	it("storage.remove(object,callback) should accept an array of keys to be deleted from localStorage and respond with callback", function(done){
		assert.doesNotThrow(function(){
			storage.remove(["testkey"],function(result){
				if (result === true) {
					done();
				}
			});
		});
	});
});

describe("OpenSprinkler Firmware Version Functions",function(){

	describe("Test against Arduino Firmware Version",function(){
		before(function(){
			controller.options = {
				fwv: 210
			};
		});
		it("isOPSi() should identify if the device is an OSPi",function(){
			assert.equal(false,isOSPi());
		});
		it("versionCompare(device,compare) should check the given firmware (device) against the compare firmware where the input is an array",function(){
			assert.strictEqual(false,versionCompare([1],[1,5]));
			assert.strictEqual(0,versionCompare([1,5],[1,5]));
			assert.strictEqual(1,versionCompare([2,1],[1,5]));
		});
		it("checkOSVersion(compare) should compare the input firmware version against the Arduino firmware version.",function(){
			assert.strictEqual(false,checkOSVersion(211));
			assert.strictEqual(true,checkOSVersion(210));
			assert.strictEqual(1,checkOSVersion(208));
		});
		it("checkOSPiVersion(compare) should compare the input firmware version against the OSPi firmware version.",function(){
			assert.strictEqual(false,checkOSPiVersion("2.0"));
			assert.strictEqual(false,checkOSPiVersion("1.9"));
			assert.strictEqual(false,checkOSPiVersion("2.1"));
		});
	});

	describe("Test against OSPi Firmware Version",function(){
		before(function(){
			controller.options = {
				fwv: "1.9.0-OSPi"
			};
		});
		it("isOPSi() should identify if the device is an OSPi",function(){
			assert.equal(true,isOSPi());
		});
		it("versionCompare(device,compare) should check the given firmware (device) against the compare firmware where the input is an array",function(){
			assert.strictEqual(false,versionCompare([1],[1,5]));
			assert.strictEqual(0,versionCompare([1,5],[1,5]));
			assert.strictEqual(1,versionCompare([2,1],[1,5]));
		});
		it("checkOSVersion(compare) should compare the input firmware version against the Arduino firmware version.",function(){
			assert.strictEqual(false,checkOSVersion(211));
			assert.strictEqual(false,checkOSVersion(210));
			assert.strictEqual(false,checkOSVersion(208));
		});
		it("checkOSPiVersion(compare) should compare the input firmware version against the OSPi firmware version.",function(){
			assert.strictEqual(1,checkOSPiVersion("1.8"));
			assert.strictEqual(true,checkOSPiVersion("1.9.0"));
			assert.strictEqual(false,checkOSPiVersion("2.0"));
			assert.strictEqual(false,checkOSPiVersion("2.1"));
		});
	});

	describe("Retrieve the formatted firmware version",function(){
		before(function(){
			controller.options = {
				fwv: 204
			};
		});
		it("getOSVersion(fwv) should return the firmware in a string representation",function(){
			assert.equal("1.8.3-OSPi",getOSVersion("1.8.3-OSPi"));
			assert.equal("2.1.193-OSPi",getOSVersion("2.1.193-OSPi"));
			assert.equal("2.0.8",getOSVersion(208));
			assert.equal("2.0.4",getOSVersion());
		});
	});
});

describe("General Function Checks", function(){
	it("colorContrast(color) should take rgb(r,g,b) and return the appropriate color contrast for the input color",function(){
		assert.equal("black",colorContrast("rgb(50,200,0)"));
		assert.equal("white",colorContrast("rgb(0,0,0)"));
	});

	it("parseIntArray(array) should convert all members into integers",function(){
		assert.deepEqual([9, 394, 29193, -1],parseIntArray(["9","394","29193","-1"]));
	});

	it("sec2hms(number) should return a string representation of the difference the input represents (seconds)",function(){
		assert.equal("23:59:59",sec2hms(86399));
		assert.equal("15:00",sec2hms(900));
	});

	it("sec2dhms(number) should return an object containing days, hours, minutes and seconds from the input (seconds)",function(){
		assert.deepEqual({
			days: 936,
			hours: 17,
			minutes: 20,
			seconds: 9
		}, sec2dhms(80932809));
	});

	it("dhms2str(object) should convert an object with elements days, hours, minutes and seconds into a string representation",function(){
		assert.equal("5d 4h 3m 1s",dhms2str({days:5,hours:4,minutes:3,seconds:1}));
		assert.equal("0s",dhms2str({}));
	});

	it("dhms2sec(object) should convert an object with elements days, hours, minutes and seconds into a second value",function(){
		assert.equal(100981,dhms2sec({days:1,hours:4,minutes:3,seconds:1}));
	});

	it("getDayName(day,type) should return the day of the week and can be of type 'short'",function(){
		assert.equal("Sunday",getDayName(new Date(1410745528126)));
		assert.equal("Thu",getDayName(new Date(1410445528126),"short"));
	});

	it("getUnique(array) should take any array and remove duplicates",function(){
		assert.deepEqual([0],getUnique([0,0]));
		assert.deepEqual([9992,"hello"],getUnique([9992,9992,"hello"]));
	});

	it("pad(number) should succesfully prepend a 0 to a single digit",function(){
		assert.equal("00", pad(0));
		assert.equal("01", pad(1));
		assert.equal("10", pad(10));
		assert.equal("999", pad(999));
	});
});
<|endoftext|>


<commit_before>define(function (require) {
    var suite = require('intern!object');
    var parameterConverter = require('intern/dojo/node!../../src/builders/parameterConverter');
    var expect = require('intern/chai!expect');

    suite({
        'should convert to integer parameter': function () {
            expect(parameterConverter.convertParameterObject('12345', {type:'integer', format:'int32'})).to.eql(12345);
        },
        'should convert to long parameter': function () {
            expect(parameterConverter.convertParameterObject('12345', {type:'integer', format:'int64'})).to.eql(12345);
        },
        'should convert to float parameter': function () {
            expect(parameterConverter.convertParameterObject('12.345', {type:'number', format:'float'})).to.eql(12.345);
        },
        'should convert to double parameter': function () {
            expect(parameterConverter.convertParameterObject('12.345', {type:'number', format:'double'})).to.eql(12.345);
        },
        'should convert string parameter': function () {
            expect(parameterConverter.convertParameterObject('abc', {type:'string'})).to.eql("abc");
        },
        'should convert byte parameter': function () {
            expect(parameterConverter.convertParameterObject('abc', {type:'string', format:'byte'})).to.eql("abc");
        },
        'should convert boolean parameter': function () {
            expect(parameterConverter.convertParameterObject('true', {type:'boolean'})).to.eql(true);
        },
        'should convert date parameter': function () {
            expect(parameterConverter.convertParameterObject('2015-09-29', {type:'string', format:'date'})).to.eql(new Date('2015-09-29'));
        },
        'should convert dateTime parameter': function () {
            expect(parameterConverter.convertParameterObject('2015-09-29T23:59:59', {type:'string', format:'date-time'})).to.eql(new Date('2015-09-29T23:59:59'));
        },
        'should throw exception when configuration not found': function () {
            try {
                parameterConverter.convertParameterObject('abc', {type:'aaa', format:'bbb'});
            } catch (e) {
                expect(e).is.eql('Could not convert value: abc, for type: aaa, format: bbb, items: undefined, collectionFormat: undefined');
            }
        },
        'should convert csv array': function () {
            expect(parameterConverter.convertParameterObject("foo,bar", {
                "name": "tags",
                "in": "query",
                "type": "array",
                "items": {
                    "type": "string"
                }
            })).to.eql(['foo', 'bar']);
        },
        'should convert ssv array': function () {
            expect(parameterConverter.convertParameterObject("foo bar", {
                "name": "tags",
                "in": "query",
                "type": "array",
                "items": {
                    "type": "string"
                },
                collectionFormat: 'ssv'
            })).to.eql(['foo', 'bar']);
        },
        'should convert tsv array': function () {
            expect(parameterConverter.convertParameterObject("foo\tbar", {
                "name": "tags",
                "in": "query",
                "type": "array",
                "items": {
                    "type": "string"
                },
                collectionFormat: 'tsv'
            })).to.eql(['foo', 'bar']);
        },
        'should convert pipes array': function () {
            expect(parameterConverter.convertParameterObject("foo|bar", {
                "name": "tags",
                "in": "query",
                "type": "array",
                "items": {
                    "type": "string"
                },
                collectionFormat: 'pipes'
            })).to.eql(['foo', 'bar']);
        },
        'should throw exception when unknown collectionFormatwhile converting array': function () {
            try {
                parameterConverter.convertParameterObject("foo|bar", {
                    "name": "tags",
                    "in": "query",
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    collectionFormat: 'aaa'
                });
                expect.fail('expect exception to be thrown');
            }catch(e){
                expect(e).to.not.null;
            }
        },
        'should convert to integer array': function () {
            expect(parameterConverter.convertParameterObject("123,456", {
                "name": "tags",
                "in": "query",
                "type": "array",
                "items": {
                    "type": "integer",
                    "format": "int32"
                }
            })).to.eql([123, 456]);
        }
    });
});<commit_msg>Add schema validation<commit_after>define(function (require) {
    var suite = require('intern!object');
    var parameterConverter = require('intern/dojo/node!../../src/builders/parameterConverter');
    var expect = require('intern/chai!expect');

    suite({
        'should convert to integer parameter': function () {
            expect(parameterConverter.convertParameterObject('12345', {
                type: 'integer',
                format: 'int32'
            })).to.eql(12345);
        },
        'should convert to long parameter': function () {
            expect(parameterConverter.convertParameterObject('12345', {
                type: 'integer',
                format: 'int64'
            })).to.eql(12345);
        },
        'should convert to float parameter': function () {
            expect(parameterConverter.convertParameterObject('12.345', {
                type: 'number',
                format: 'float'
            })).to.eql(12.345);
        },
        'should convert to double parameter': function () {
            expect(parameterConverter.convertParameterObject('12.345', {
                type: 'number',
                format: 'double'
            })).to.eql(12.345);
        },
        'should convert string parameter': function () {
            expect(parameterConverter.convertParameterObject('abc', {type: 'string'})).to.eql("abc");
        },
        'should convert byte parameter': function () {
            expect(parameterConverter.convertParameterObject('abc', {type: 'string', format: 'byte'})).to.eql("abc");
        },
        'should convert boolean parameter': function () {
            expect(parameterConverter.convertParameterObject('true', {type: 'boolean'})).to.eql(true);
        },
        'should convert date parameter': function () {
            expect(parameterConverter.convertParameterObject('2015-09-29', {
                type: 'string',
                format: 'date'
            })).to.eql('2015-09-29');
        },
        'should convert dateTime parameter': function () {
            expect(parameterConverter.convertParameterObject('2015-09-29T23:59:59', {
                type: 'string',
                format: 'date-time'
            })).to.eql('2015-09-29T23:59:59');
        },
        'should throw exception when configuration not found': function () {
            try {
                parameterConverter.convertParameterObject('abc', {type: 'aaa', format: 'bbb'});
            } catch (e) {
                expect(e).is.eql('Could not convert value: abc, for type: aaa, format: bbb, items: undefined, collectionFormat: undefined');
            }
        },
        'should convert csv array': function () {
            expect(parameterConverter.convertParameterObject("foo,bar", {
                "name": "tags",
                "in": "query",
                "type": "array",
                "items": {
                    "type": "string"
                }
            })).to.eql(['foo', 'bar']);
        },
        'should convert ssv array': function () {
            expect(parameterConverter.convertParameterObject("foo bar", {
                "name": "tags",
                "in": "query",
                "type": "array",
                "items": {
                    "type": "string"
                },
                collectionFormat: 'ssv'
            })).to.eql(['foo', 'bar']);
        },
        'should convert tsv array': function () {
            expect(parameterConverter.convertParameterObject("foo\tbar", {
                "name": "tags",
                "in": "query",
                "type": "array",
                "items": {
                    "type": "string"
                },
                collectionFormat: 'tsv'
            })).to.eql(['foo', 'bar']);
        },
        'should convert pipes array': function () {
            expect(parameterConverter.convertParameterObject("foo|bar", {
                "name": "tags",
                "in": "query",
                "type": "array",
                "items": {
                    "type": "string"
                },
                collectionFormat: 'pipes'
            })).to.eql(['foo', 'bar']);
        },
        'should throw exception when unknown collectionFormatwhile converting array': function () {
            try {
                parameterConverter.convertParameterObject("foo|bar", {
                    "name": "tags",
                    "in": "query",
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    collectionFormat: 'aaa'
                });
                expect.fail('expect exception to be thrown');
            } catch (e) {
                expect(e).to.not.null;
            }
        },
        'should convert to integer array': function () {
            expect(parameterConverter.convertParameterObject("123,456", {
                "name": "tags",
                "in": "query",
                "type": "array",
                "items": {
                    "type": "integer",
                    "format": "int32"
                }
            })).to.eql([123, 456]);
        }
    });
});<|endoftext|>


<commit_before>casper.test.begin('Important Information', function suite(test) {

    casper.start("http://khs-minithon.github.io/website/", function() {

        test.assertHttpStatus(200, 'Connected to main page');
        test.assertUrlMatch('/website', 'URL is root');

        test.assertTitle('Kennett High School Mini-THON', 'Title is correct');

        // Event Name
        test.assertExists('#event-name', 'Event Name Found');
        test.assertEquals(this.fetchText('#event-name'), 'Kennett High School Mini-THON', 'Correct Event Name');

        // Event Date
        test.assertExists('#event-date', 'Event Date Found');
        test.assertEquals(this.fetchText('#event-date'), "Join Us on February 26, 2016", "Correct Event Date");

        // Event Slogan
        test.assertExists('#event-slogan', 'Slogan Found');
        test.assertEquals(this.fetchText('#event-slogan'), "For The Fight. For The Cure. For The Kids.", "Correct Event Slogan");

        // About Section
        test.assertElementCount('.about', 4, '4 About Boxes Found');

            // Who Are We?
            test.assertEquals(this.fetchText(".about:nth-child(1) h4"), "Who Are We?", "Who Are We? - Correct Title ");
            test.assertEquals(this.fetchText(".about:nth-child(1) p"), "We are a group of KHS students dedicated to raise as much money as possible to fight childhood cancer.", "Who Are We? - Correct Text ");

            // What Do We Do?
            test.assertEquals(this.fetchText(".about:nth-child(2) h4"), "What Do We Do?", "What Do We Do? - Correct Title ");
            test.assertEquals(this.fetchText(".about:nth-child(2) p"), "The KHS Mini-THON raises money through fundraisers and our annual Mini-THON to benefit the Four Diamonds Research.", "What Do We Do? - Correct Text ");

            // Why We Do It?
            test.assertEquals(this.fetchText(".about:nth-child(3) h4"), "Why We Do It?", "Why We Do It? - Correct Title ");
            test.assertEquals(this.fetchText(".about:nth-child(3) p"), "We do it for the fight. For the cure. For The Kids living with cancer.", "Why We Do It? - Correct Text ");

            // Since When?
            test.assertEquals(this.fetchText(".about:nth-child(4) h4"), "Since When?", "Since When? - Correct Title ");
            test.assertEquals(this.fetchText(".about:nth-child(4) p"), "We have been fighting childhood cancer since 2015 with our first annual Mini-THON being held in February of 2016.", "Since When? - Correct Text ");

        // Impact Section
        test.assertElementCount('.services', 4, '4 Services Boxes Found');

            // Mini-THONs
            test.assertEquals(this.fetchText(".services:nth-child(1) h4"), "Mini-THONs", "Mini-THONS - Correct Title ");
            test.assertEquals(this.fetchText(".services:nth-child(1) p"), "Mini-THONs are multi-hour, interactive, fun-filled events that are completely student-led. They can also be 3 month projects or year-long activities where students raise awareness and funds for Four Diamonds.", "Mini-THONS - Correct Text ");
            test.assertEquals(this.getElementAttribute('.services:nth-child(1) a', 'href'), 'http://fourdiamonds.donordrive.com/index.cfm?fuseaction=cms.page&id=1007', 'Mini-THON Correct Link');

            // Donations
            test.assertEquals(this.fetchText(".services:nth-child(2) h4"), "Donations", "Donations - Correct Title ");
            test.assertEquals(this.fetchText(".services:nth-child(2) p"), "By raising money, we can assure that the children get the help they need and deserve. Thanks to donations, 100% of children with cancer at Penn State Hershey Children's Hospital are eligible for assistance.", "Donations - Correct Text ");
            test.assertEquals(this.getElementAttribute('.services:nth-child(2) a', 'href'), 'http://www.fourdiamonds.org/about-us/#about-usfinancials', 'Mini-THONS Correct Link');

            // Raising Awareness
            test.assertEquals(this.fetchText(".services:nth-child(3) h4"), "Raising Awareness", "Raising Awareness - Correct Title ");
            test.assertEquals(this.fetchText(".services:nth-child(3) p"), "By reaching out the community, we make everyone come together to help fight for this noble cause.", "Raising Awareness - Correct Text ");
            test.assertEquals(this.getElementAttribute('.services:nth-child(3) a', 'href'), 'http://www.fourdiamonds.org/about-childhood-cancer/', 'Raising Awareness Correct Link');

            // Research
            test.assertEquals(this.fetchText(".services:nth-child(4) h4"), "Research", "Research - Correct Title ");
            test.assertEquals(this.fetchText(".services:nth-child(4) p"), "Through Four Diamonds, Penn State Hershey Children's Hospital is seeking improved treatments and cures to benefit those around the world.", "Research - Correct Text ");
            test.assertEquals(this.getElementAttribute('.services:nth-child(4) a', 'href'), 'https://www.youtube.com/watch?v=C7SPFR2T3tg', 'Research Correct Link');

            /* Add this exactly like this Travis going to flip
        // Four Diamonds Links
        test.assertElementCount('.imp-links li', 6, '6 Four Diamonds Links Found');

            // About
            test.assertEquals(this.fetchText('.imp-links li:nth-child(1)'), 'About', 'About - Correct Text');
            test.assertEquals(this.getElementAttribute('.imp-links li:nth-child(1) a', 'href'), 'http://www.fourdiamonds.org/about-us/#sidr-main', 'About - Correct Link');

            // History
            test.assertEquals(this.fetchText('.imp-links li:nth-child(2)'), 'History', 'History - Correct Text');
            test.assertEquals(this.getElementAttribute('.imp-links li:nth-child(2) a', 'href'), 'http://www.fourdiamonds.org/about-us/#about-usour-history', 'History - Correct Link');

            // Financials
            test.assertEquals(this.fetchText('.imp-links li:nth-child(3)'), 'Financials', 'Financials - Correct Text');
            test.assertEquals(this.getElementAttribute('.imp-links li:nth-child(3) a', 'href'), 'http://www.fourdiamonds.org/about-us/#about-usfinancials', 'Financials - Correct Link');

            // Penn State
            test.assertEquals(this.fetchText('.imp-links li:nth-child(4)'), 'Penn State', 'Penn State - Correct Text');
            test.assertEquals(this.getElementAttribute('.imp-links li:nth-child(4) a', 'href'), 'http://www.fourdiamonds.org/about-us/#about-usrelationship-to-penn-state', 'Penn State - Correct Link');

            // Staff
            test.assertEquals(this.fetchText('.imp-links li:nth-child(5)'), 'Staff', 'Staff - Correct Text');
            test.assertEquals(this.getElementAttribute('.imp-links li:nth-child(5) a', 'href'), 'http://www.fourdiamonds.org/about-us/#about-usstaff', 'Staff - Correct Link');

            // Families
            test.assertEquals(this.fetchText('.imp-links li:nth-child(6)'), 'Families', 'Families - Correct Text');
            test.assertEquals(this.getElementAttribute('.imp-links li:nth-child(6) a', 'href'), 'http://www.fourdiamonds.org/about-us/#about-usmeet-our-families', 'Families - Correct Link');
            */
    });

    casper.run(function() {
        test.done();
    });

});

casper.test.begin('Important Links', function suite(test) {

    casper.start("http://khs-minithon.github.io/website/", function() {

        // Navigation Bar
        test.assertExists('.navbar-nav', 'Navigation Bar Found');
        test.assertElementCount('.navbar-nav li', 7, '7 Sections in Navigation Bar Found');

            // Home
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(1) a'), "Home", "Correct Navigation-Home Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(1) a', 'href'), 'body', 'Correct Navigation-Home Link');

            // About
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(2) a'), "About", "Correct Navigation-About Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(2) a', 'href'), '#about-section', 'Correct Navigation-About Link');

            // Services
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(3) a'), "Services", "Correct Navigation-Services Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(3) a', 'href'), '#services-section', 'Correct Navigation-Services Link');

            // Impact
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(4) a'), "Impact", "Correct Navigation-Impact Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(4) a', 'href'), '#portfolio-section', 'Correct Navigation-Impact Link');

            // Sign Up
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(5) a'), "Sign Up", "Correct Navigation-SignUp Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(5) a', 'href'), '#signup-section', 'Correct Navigation-Sign Up Link');

            // Team
            //test.assertEquals(this.fetchText('.navbar-nav li:nth-child(6) a'), "Team", "Correct Navigation-Team Text");
            //test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(6) a', 'href'), '#team-section', 'Correct Navigation-Team Link');

            // Partners
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(6) a'), "Partners", "Correct Navigation-Partners Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(6) a', 'href'), '#partners-section', 'Correct Navigation-Partners Link');

            // Social
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(6) a'), "Social", "Correct Navigation-Social Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(6) a', 'href'), '#social-section', 'Correct Navigation-Social Link');

        // Sign Up Button
        test.assertExists('#sign-up', 'Sign Up Button Found');
        test.assertEquals(this.fetchText('#sign-up strong'), "Sign up", "Correct Sign Up Button Text");
        test.assertEquals(this.getElementAttribute('#sign-up', 'href'), 'http://fourdiamonds.donordrive.com/event/khs16', 'Correct Sign Up Link');

        // Donate Button
        test.assertExists('#donate', 'Donate Button Found');
        test.assertEquals(this.fetchText('#donate'), "Donate", "Correct Donate Button Text");
        test.assertEquals(this.getElementAttribute('#donate', 'href'), 'https://fourdiamonds.donordrive.com/index.cfm?fuseaction=donate.event&eventID=1179', 'Correct Donate Link');

        // Social Media Buttons
        test.assertElementCount('.social-list li', 4, '4 Social Media Buttons Found');

            // Facebook
            test.assertEquals(this.getElementAttribute('.social-list li:nth-child(1) a', 'href'), 'https://www.facebook.com/FourDiamondsFund', 'Correct Facebook Link');

            // Twitter
            test.assertEquals(this.getElementAttribute('.social-list li:nth-child(2) a', 'href'), 'https://twitter.com/khsminithon', 'Correct Twitter Link');

            // Instagram
            test.assertEquals(this.getElementAttribute('.social-list li:nth-child(3) a', 'href'), 'https://instagram.com/khsminithon/', 'Correct Instagram Link');

            // Google Group
            test.assertEquals(this.getElementAttribute('.social-list li:nth-child(4) a', 'href'), 'https://groups.google.com/forum/#!forum/khsminithon/join', 'Correct Google Group Link');

    });

    casper.run(function() {
        test.done();

         // work around "Unsafe JavaScript attempt to access frame with URL about:blank" error
        // http://stackoverflow.com/questions/26608391/using-phantomjs-to-embed-all-images-of-a-webpage-produces-warnings-but-works/26688062#26688062
        setTimeout(function() {
            phantom.exit();
        }, 0);

    });

});
<commit_msg>minor changes<commit_after>casper.test.begin('Important Information', function suite(test) {

    casper.start("http://khs-minithon.github.io/website/", function() {

        test.assertHttpStatus(200, 'Connected to main page');
        test.assertUrlMatch('/website', 'URL is root');

        test.assertTitle('Kennett High School Mini-THON', 'Title is correct');

        // Event Name
        test.assertExists('#event-name', 'Event Name Found');
        test.assertEquals(this.fetchText('#event-name'), 'Kennett High School Mini-THON', 'Correct Event Name');

        // Event Date
        test.assertExists('#event-date', 'Event Date Found');
        test.assertEquals(this.fetchText('#event-date'), "Join Us on February 26, 2016", "Correct Event Date");

        // Event Slogan
        test.assertExists('#event-slogan', 'Slogan Found');
        test.assertEquals(this.fetchText('#event-slogan'), "For The Fight. For The Cure. For The Kids.", "Correct Event Slogan");

        // About Section
        test.assertElementCount('.about', 4, '4 About Boxes Found');

            // Who Are We?
            test.assertEquals(this.fetchText(".about:nth-child(1) h4"), "Who Are We?", "Who Are We? - Correct Title ");
            test.assertEquals(this.fetchText(".about:nth-child(1) p"), "We are a group of KHS students dedicated to raise as much money as possible to fight childhood cancer.", "Who Are We? - Correct Text ");

            // What Do We Do?
            test.assertEquals(this.fetchText(".about:nth-child(2) h4"), "What Do We Do?", "What Do We Do? - Correct Title ");
            test.assertEquals(this.fetchText(".about:nth-child(2) p"), "The KHS Mini-THON raises money through fundraisers and our annual Mini-THON to benefit the Four Diamonds Research.", "What Do We Do? - Correct Text ");

            // Why We Do It?
            test.assertEquals(this.fetchText(".about:nth-child(3) h4"), "Why We Do It?", "Why We Do It? - Correct Title ");
            test.assertEquals(this.fetchText(".about:nth-child(3) p"), "We do it for the fight. For the cure. For The Kids living with cancer.", "Why We Do It? - Correct Text ");

            // Since When?
            test.assertEquals(this.fetchText(".about:nth-child(4) h4"), "Since When?", "Since When? - Correct Title ");
            test.assertEquals(this.fetchText(".about:nth-child(4) p"), "We have been fighting childhood cancer since 2015 with our first annual Mini-THON being held in February of 2016.", "Since When? - Correct Text ");

        // Impact Section
        test.assertElementCount('.services', 4, '4 Services Boxes Found');

            // Mini-THONs
            test.assertEquals(this.fetchText(".services:nth-child(1) h4"), "Mini-THONs", "Mini-THONS - Correct Title ");
            test.assertEquals(this.fetchText(".services:nth-child(1) p"), "Mini-THONs are multi-hour, interactive, fun-filled events that are completely student-led. They can also be 3 month projects or year-long activities where students raise awareness and funds for Four Diamonds.", "Mini-THONS - Correct Text ");
            test.assertEquals(this.getElementAttribute('.services:nth-child(1) a', 'href'), 'http://fourdiamonds.donordrive.com/index.cfm?fuseaction=cms.page&id=1007', 'Mini-THON Correct Link');

            // Donations
            test.assertEquals(this.fetchText(".services:nth-child(2) h4"), "Donations", "Donations - Correct Title ");
            test.assertEquals(this.fetchText(".services:nth-child(2) p"), "By raising money, we can assure that the children get the help they need and deserve. Thanks to donations, 100% of children with cancer at Penn State Hershey Children's Hospital are eligible for assistance.", "Donations - Correct Text ");
            test.assertEquals(this.getElementAttribute('.services:nth-child(2) a', 'href'), 'http://www.fourdiamonds.org/about-us/#about-usfinancials', 'Mini-THONS Correct Link');

            // Raising Awareness
            test.assertEquals(this.fetchText(".services:nth-child(3) h4"), "Raising Awareness", "Raising Awareness - Correct Title ");
            test.assertEquals(this.fetchText(".services:nth-child(3) p"), "By reaching out the community, we make everyone come together to help fight for this noble cause.", "Raising Awareness - Correct Text ");
            test.assertEquals(this.getElementAttribute('.services:nth-child(3) a', 'href'), 'http://www.fourdiamonds.org/about-childhood-cancer/', 'Raising Awareness Correct Link');

            // Research
            test.assertEquals(this.fetchText(".services:nth-child(4) h4"), "Research", "Research - Correct Title ");
            test.assertEquals(this.fetchText(".services:nth-child(4) p"), "Through Four Diamonds, Penn State Hershey Children's Hospital is seeking improved treatments and cures to benefit those around the world.", "Research - Correct Text ");
            test.assertEquals(this.getElementAttribute('.services:nth-child(4) a', 'href'), 'https://www.youtube.com/watch?v=C7SPFR2T3tg', 'Research Correct Link');

            /* Add this exactly like this Travis going to flip
        // Four Diamonds Links
        test.assertElementCount('.imp-links li', 6, '6 Four Diamonds Links Found');

            // About
            test.assertEquals(this.fetchText('.imp-links li:nth-child(1)'), 'About', 'About - Correct Text');
            test.assertEquals(this.getElementAttribute('.imp-links li:nth-child(1) a', 'href'), 'http://www.fourdiamonds.org/about-us/#sidr-main', 'About - Correct Link');

            // History
            test.assertEquals(this.fetchText('.imp-links li:nth-child(2)'), 'History', 'History - Correct Text');
            test.assertEquals(this.getElementAttribute('.imp-links li:nth-child(2) a', 'href'), 'http://www.fourdiamonds.org/about-us/#about-usour-history', 'History - Correct Link');

            // Financials
            test.assertEquals(this.fetchText('.imp-links li:nth-child(3)'), 'Financials', 'Financials - Correct Text');
            test.assertEquals(this.getElementAttribute('.imp-links li:nth-child(3) a', 'href'), 'http://www.fourdiamonds.org/about-us/#about-usfinancials', 'Financials - Correct Link');

            // Penn State
            test.assertEquals(this.fetchText('.imp-links li:nth-child(4)'), 'Penn State', 'Penn State - Correct Text');
            test.assertEquals(this.getElementAttribute('.imp-links li:nth-child(4) a', 'href'), 'http://www.fourdiamonds.org/about-us/#about-usrelationship-to-penn-state', 'Penn State - Correct Link');

            // Staff
            test.assertEquals(this.fetchText('.imp-links li:nth-child(5)'), 'Staff', 'Staff - Correct Text');
            test.assertEquals(this.getElementAttribute('.imp-links li:nth-child(5) a', 'href'), 'http://www.fourdiamonds.org/about-us/#about-usstaff', 'Staff - Correct Link');

            // Families
            test.assertEquals(this.fetchText('.imp-links li:nth-child(6)'), 'Families', 'Families - Correct Text');
            test.assertEquals(this.getElementAttribute('.imp-links li:nth-child(6) a', 'href'), 'http://www.fourdiamonds.org/about-us/#about-usmeet-our-families', 'Families - Correct Link');
            */
    });

    casper.run(function() {
        test.done();
    });

});

casper.test.begin('Important Links', function suite(test) {

    casper.start("http://khs-minithon.github.io/website/", function() {

        // Navigation Bar
        test.assertExists('.navbar-nav', 'Navigation Bar Found');
        test.assertElementCount('.navbar-nav li', 7, '7 Sections in Navigation Bar Found');

            // Home
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(1) a'), "Home", "Correct Navigation-Home Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(1) a', 'href'), 'body', 'Correct Navigation-Home Link');

            // About
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(2) a'), "About", "Correct Navigation-About Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(2) a', 'href'), '#about-section', 'Correct Navigation-About Link');

            // Services
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(3) a'), "Services", "Correct Navigation-Services Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(3) a', 'href'), '#services-section', 'Correct Navigation-Services Link');

            // Impact
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(4) a'), "Impact", "Correct Navigation-Impact Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(4) a', 'href'), '#portfolio-section', 'Correct Navigation-Impact Link');

            // Sign Up
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(5) a'), "Sign Up", "Correct Navigation-SignUp Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(5) a', 'href'), '#signup-section', 'Correct Navigation-Sign Up Link');

            // Team
            //test.assertEquals(this.fetchText('.navbar-nav li:nth-child(6) a'), "Team", "Correct Navigation-Team Text");
            //test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(6) a', 'href'), '#team-section', 'Correct Navigation-Team Link');

            // Partners
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(6) a'), "Partners", "Correct Navigation-Partners Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(6) a', 'href'), '#partners-section', 'Correct Navigation-Partners Link');

            // Social
            test.assertEquals(this.fetchText('.navbar-nav li:nth-child(7) a'), "Social", "Correct Navigation-Social Text");
            test.assertEquals(this.getElementAttribute('.navbar-nav li:nth-child(7) a', 'href'), '#social-section', 'Correct Navigation-Social Link');

        // Sign Up Button
        test.assertExists('#sign-up', 'Sign Up Button Found');
        test.assertEquals(this.fetchText('#sign-up strong'), "Sign up", "Correct Sign Up Button Text");
        test.assertEquals(this.getElementAttribute('#sign-up', 'href'), 'http://fourdiamonds.donordrive.com/event/khs16', 'Correct Sign Up Link');

        // Donate Button
        test.assertExists('#donate', 'Donate Button Found');
        test.assertEquals(this.fetchText('#donate'), "Donate", "Correct Donate Button Text");
        test.assertEquals(this.getElementAttribute('#donate', 'href'), 'https://fourdiamonds.donordrive.com/index.cfm?fuseaction=donate.event&eventID=1179', 'Correct Donate Link');

        // Social Media Buttons
        test.assertElementCount('.social-list li', 4, '4 Social Media Buttons Found');

            // Facebook
            test.assertEquals(this.getElementAttribute('.social-list li:nth-child(1) a', 'href'), 'https://www.facebook.com/FourDiamondsFund', 'Correct Facebook Link');

            // Twitter
            test.assertEquals(this.getElementAttribute('.social-list li:nth-child(2) a', 'href'), 'https://twitter.com/khsminithon', 'Correct Twitter Link');

            // Instagram
            test.assertEquals(this.getElementAttribute('.social-list li:nth-child(3) a', 'href'), 'https://instagram.com/khsminithon/', 'Correct Instagram Link');

            // Google Group
            test.assertEquals(this.getElementAttribute('.social-list li:nth-child(4) a', 'href'), 'https://groups.google.com/forum/#!forum/khsminithon/join', 'Correct Google Group Link');

    });

    casper.run(function() {
        test.done();

         // work around "Unsafe JavaScript attempt to access frame with URL about:blank" error
        // http://stackoverflow.com/questions/26608391/using-phantomjs-to-embed-all-images-of-a-webpage-produces-warnings-but-works/26688062#26688062
        setTimeout(function() {
            phantom.exit();
        }, 0);

    });

});
<|endoftext|>


<commit_before>var core = require('../lib/core');
var util = require('../lib/util');

describe('evac tasks', function(){
  describe('parseRecipeFile()', function() {
    it('should be parse recipe file. (JSON format)', function(done){
      util.parseSettingFile(__dirname + '/fixtures/recipe/sample.json', function(err, config){
        err.should.be.false;
        config.out.stdout.should.be.a('object');
        done();
      });
    });

    it('should be parse recipe file. (YAML format)', function(done){
      util.parseSettingFile(__dirname + '/fixtures/recipe/sample.yaml', function(err, config){
        err.should.be.false;
        config.out.stdout.should.be.a('object');
        done();
      });
    });
  });

  describe('parseRecipeJson()', function(){
    it('should be parse recipe.', function(done){
      var recipe = {
        "in": {
          "staticWord": {
            "text": "test word."
          }
        },
        "filter": {
          "through": {}
        },
        "out": {
          "stdout": {}
        }
      };

      core.parseRecipeJson(recipe, function(err, message){
        err.should.be.false;
        done();
      });
    });

    it('should be parse multiple recipe.', function(done){
      var recipe = [
        {
          "in": {
            "staticWord": {
              "text": "1st recipe."
            }
          },
          "filter": {
            "through": {}
          },
          "out": {
            "stdout": {}
          }
        },
        {
          "in": {
            "staticWord": {
              "text": "2nd recipe."
            }
          },
          "filter": {
            "through": {}
          },
          "out": {
            "stdout": {}
          }
        }
      ];

      core.parseRecipeJson(recipe, function(err, message){
        err.should.be.false;
        done();
      });
    });

    it('should be parse abbreviated recipe.', function(done){
      var recipe = {
        "in": {
          "staticWord": {
            "text": "test word."
          }
        },
        "out": {
          "stdout": {}
        }
      };

      core.parseRecipeJson(recipe, function(err, message){
        err.should.be.false;
        done();
      });
    });

    it.skip('should be raise error with invalid recipe.', function(done){
      var recipe = {
        "inin": {
          "staticWord": {
            "text": "test word."
          }
        }
      };

      core.parseRecipeJson(recipe, function(err, message){
        err.should.be.not.false;
        done();
      });
    });
  });
});
<commit_msg>レシピ修正<commit_after>var core = require('../lib/core');
var util = require('../lib/util');

describe('evac tasks', function(){
  describe('parseRecipeFile()', function() {
    it('should be parse recipe file. (JSON format)', function(done){
      util.parseSettingFile(__dirname + '/fixtures/recipe/sample.json', function(err, config){
        err.should.be.false;
        config.out.stdout.should.be.a('object');
        done();
      });
    });

    it('should be parse recipe file. (YAML format)', function(done){
      util.parseSettingFile(__dirname + '/fixtures/recipe/sample.yaml', function(err, config){
        err.should.be.false;
        config.out.stdout.should.be.a('object');
        done();
      });
    });
  });

  describe('parseRecipeJson()', function(){
    it('should be parse recipe.', function(done){
      var recipe = {
        "in": {
          "staticWord": {
            "text": "test word."
          }
        },
        "filter": {
          "through": {}
        },
        "out": {
          "stdout": {}
        }
      };

      core.parseRecipeJson(recipe, function(err, message){
        err.should.be.false;
        done();
      });
    });

    it('should be parse multiple recipe.', function(done){
      var recipe = [
        {
          "in": {
            "staticWord": {
              "text": "1st recipe."
            }
          },
          "filter": {
            "through": {}
          },
          "out": {
            "stdout": {}
          }
        }
      ];

      core.parseRecipeJson(recipe, function(err, message){
        err.should.be.false;
        done();
      });
    });

    it('should be parse abbreviated recipe.', function(done){
      var recipe = {
        "in": {
          "staticWord": {
            "text": "test word."
          }
        },
        "out": {
          "stdout": {}
        }
      };

      core.parseRecipeJson(recipe, function(err, message){
        err.should.be.false;
        done();
      });
    });

    it.skip('should be raise error with invalid recipe.', function(done){
      var recipe = {
        "inin": {
          "staticWord": {
            "text": "test word."
          }
        }
      };

      core.parseRecipeJson(recipe, function(err, message){
        err.should.be.not.false;
        done();
      });
    });
  });
});
<|endoftext|>


<commit_before>'use strict';

//contrib
var request = require('supertest')
var assert = require('assert');
var fs = require('fs');

//mine
var config = require('../config');
var db = require('../api/models/db');
var app = require('../api/server').app;

describe('/task', function() {
    var instance = null;
    var task = null;

    before(function(done) {
        request(app)
        .get('/instance/')
        .set('Authorization', 'Bearer '+config.sca.jwt)
        .set('Accept', 'application/json')
        .query('limit=1&find='+encodeURIComponent(JSON.stringify({"workflow_id": "test"})))
        .expect(200)
        .end(function(err, res) {
            if(err) return done(err);
            var instances = res.body.instances;
            if(instances.length == 0) {
                console.log("creating new test instance");
                request(app)
                .post('/instance')
                .set('Authorization', 'Bearer '+config.sca.jwt)
                .set('Accept', 'application/json')
                .send({
                    workflow_id: "test",
                    user_id: "testuser",
                    name: "test 2",
                    desc: "test desc 2",
                    config: {
                        what: "ever"
                    }
                })
                .expect(200)
                .end(function(err, res) {
                    if(err) return done(err);
                    instance = res.body;
                    done();
                });
            } else {
                instance = instances[0];
                done();
            }
        });
    });

    it('should not create task with missing resource_dep', function(done) {
        request(app)
        .post('/task')
        .set('Authorization', 'Bearer '+config.sca.jwt)
        .set('Accept', 'application/json')
        .send({
                name: "test",
                desc: "test desc",
                instance_id: instance._id,
                service: "soichih/sca-service-noop",
                config: {
                        what: "ever"
                },
                resource_deps: ["5760192fa6b6070a731af134"]
        })
        .expect(500)
        .end(function(err, res) {
            if(err) return done(err);
            done();
        });
    });

    it('should not create task with resource preference set to missing resource', function(done) {
        request(app)
        .post('/task')
        .set('Authorization', 'Bearer '+config.sca.jwt)
        .set('Accept', 'application/json')
        .send({
                name: "test",
                desc: "test desc",
                instance_id: instance._id,
                service: "soichih/sca-service-noop",
                config: {
                        what: "ever"
                },
                preferred_resource_id: "5760192fa6b6070a731af134",
        })
        .expect(500)
        .end(function(err, res) {
            if(err) return done(err);
            done();
        });
    });

    it('should create a task', function(done) {
        request(app)
        .post('/task')
        .set('Authorization', 'Bearer '+config.sca.jwt)
        .set('Accept', 'application/json')
        .send({
                name: "test",
                desc: "test desc",
                instance_id: instance._id,
                group_id: "ahoi",
                service: "soichih/sca-service-noop",
                config: {
                        what: "ever"
                },
        })
        .expect(200)
        .end(function(err, res) {
            if(err) return done(err);
            task = res.body.task;
            assert(task.progress_key == "_sca."+instance._id+".ahoi."+task._id); //make sure group id is added
            //console.dir(task);
            done();
        });
    });

    it('should update a task', function(done) {
        request(app)
        .put('/task/'+task._id)
        .set('Authorization', 'Bearer '+config.sca.jwt)
        .set('Accept', 'application/json')
        .send({
                name: "test 2",
                desc: null,
                instance_id: "123",
                user_id: "123",
        })
        .expect(200)
        .end(function(err, res) {
            if(err) return done(err);
            var task2 = res.body;
            assert(task2.name == "test 2"); //should be new
            assert(task2.desc == undefined); //should be reset
            assert(task2.instance_id == task.instance_id); //should remain the same
            assert(task2.user_id == task.user_id); //should remain the same
            done();
        });
    });

    it('should remove a task', function(done) {
        request(app)
        .delete('/task/'+task._id)
        .set('Authorization', 'Bearer '+config.sca.jwt)
        .set('Accept', 'application/json')
        .expect(200)
        .end(function(err, res) {
            if(err) return done(err);
            done();
        });
    });
});
<commit_msg>fixed a test case reflecting group_id removal<commit_after>'use strict';

//contrib
var request = require('supertest')
var assert = require('assert');
var fs = require('fs');

//mine
var config = require('../config');
var db = require('../api/models/db');
var app = require('../api/server').app;

describe('/task', function() {
    var instance = null;
    var task = null;

    before(function(done) {
        request(app)
        .get('/instance/')
        .set('Authorization', 'Bearer '+config.sca.jwt)
        .set('Accept', 'application/json')
        .query('limit=1&find='+encodeURIComponent(JSON.stringify({"workflow_id": "test"})))
        .expect(200)
        .end(function(err, res) {
            if(err) return done(err);
            var instances = res.body.instances;
            if(instances.length == 0) {
                console.log("creating new test instance");
                request(app)
                .post('/instance')
                .set('Authorization', 'Bearer '+config.sca.jwt)
                .set('Accept', 'application/json')
                .send({
                    workflow_id: "test",
                    user_id: "testuser",
                    name: "test 2",
                    desc: "test desc 2",
                    config: {
                        what: "ever"
                    }
                })
                .expect(200)
                .end(function(err, res) {
                    if(err) return done(err);
                    instance = res.body;
                    done();
                });
            } else {
                instance = instances[0];
                done();
            }
        });
    });

    it('should not create task with missing resource_dep', function(done) {
        request(app)
        .post('/task')
        .set('Authorization', 'Bearer '+config.sca.jwt)
        .set('Accept', 'application/json')
        .send({
                name: "test",
                desc: "test desc",
                instance_id: instance._id,
                service: "soichih/sca-service-noop",
                config: {
                        what: "ever"
                },
                resource_deps: ["5760192fa6b6070a731af134"]
        })
        .expect(500)
        .end(function(err, res) {
            if(err) return done(err);
            done();
        });
    });

    it('should not create task with resource preference set to missing resource', function(done) {
        request(app)
        .post('/task')
        .set('Authorization', 'Bearer '+config.sca.jwt)
        .set('Accept', 'application/json')
        .send({
                name: "test",
                desc: "test desc",
                instance_id: instance._id,
                service: "soichih/sca-service-noop",
                config: {
                        what: "ever"
                },
                preferred_resource_id: "5760192fa6b6070a731af134",
        })
        .expect(500)
        .end(function(err, res) {
            if(err) return done(err);
            done();
        });
    });

    it('should create a task', function(done) {
        request(app)
        .post('/task')
        .set('Authorization', 'Bearer '+config.sca.jwt)
        .set('Accept', 'application/json')
        .send({
                name: "test",
                desc: "test desc",
                instance_id: instance._id,
                service: "soichih/sca-service-noop",
                config: {
                        what: "ever"
                },
        })
        .expect(200)
        .end(function(err, res) {
            if(err) return done(err);
            task = res.body.task;
            assert(task.progress_key == "_sca."+instance._id+"."+task._id); //make sure group id is added
            //console.dir(task);
            done();
        });
    });

    it('should update a task', function(done) {
        request(app)
        .put('/task/'+task._id)
        .set('Authorization', 'Bearer '+config.sca.jwt)
        .set('Accept', 'application/json')
        .send({
                name: "test 2",
                desc: null,
                instance_id: "123",
                user_id: "123",
        })
        .expect(200)
        .end(function(err, res) {
            if(err) return done(err);
            var task2 = res.body;
            assert(task2.name == "test 2"); //should be new
            assert(task2.desc == undefined); //should be reset
            assert(task2.instance_id == task.instance_id); //should remain the same
            assert(task2.user_id == task.user_id); //should remain the same
            done();
        });
    });

    it('should remove a task', function(done) {
        request(app)
        .delete('/task/'+task._id)
        .set('Authorization', 'Bearer '+config.sca.jwt)
        .set('Accept', 'application/json')
        .expect(200)
        .end(function(err, res) {
            if(err) return done(err);
            done();
        });
    });
});
<|endoftext|>


<commit_before>var neverDrop = require('./../neverdrop.js');
var fs = require('fs');

var clientOptions = {
	host: 'localhost',
	port: 3547,
	reconnectGrow: 2,
	heartbeatTimeout: 3000,
	reconnectCap: 7000,
	reconnectTime: 1000,
	rejectUnauthorized: false,
	ca: [fs.readFileSync('./cert/test.crt')],
	requestCert: true,
	agent: false
}

var serverOptions = {
	key: fs.readFileSync('./cert/test.key'),
	cert: fs.readFileSync('./cert/test.crt'),
	rejectUnauthorized: false,
	requestCert: true,
};

var server = neverDrop.createServer(serverOptions, function(socket){
	socket.on('data', function(data){
		console.log('server data: ', data.toString())
	});

	socket.on('message', function(data){
		console.log('server message: ', data);
	});

	socket.on('heartbeat', function(){
		console.log('server hb');
	});

	socket.write('hithere|poop');
	socket.noaccumulate();
	socket.write('here is a |lot of data');
	socket.write('plz no |accumulate');
	socket.accumulate();
	socket.write('jk u can start again');
});
server.listen(3547);

var socket = neverDrop.connect(clientOptions);
socket.on('error', function(e){
	console.log('error: ', e);
});

socket.on('message', function(data){
	console.log('client message: ', data);
});

socket.on('heartbeat', function(){
		console.log('client hb');
	});

socket.on('data', function(data){
	console.log('client data: ', data.toString());
});<commit_msg>did some testing, pipes to socket must have option end set to false<commit_after>var neverDrop = require('./../neverdrop.js');
var fs = require('fs');

var clientOptions = {
	host: 'localhost',
	port: 3547,
	reconnectGrow: 2,
	heartbeatTimeout: 3000,
	reconnectCap: 7000,
	reconnectTime: 1000,
	rejectUnauthorized: false,
	ca: [fs.readFileSync('./cert/test.crt')],
	requestCert: true,
	agent: false
}

var serverOptions = {
	key: fs.readFileSync('./cert/test.key'),
	cert: fs.readFileSync('./cert/test.crt'),
	rejectUnauthorized: false,
	requestCert: true,
};

var server = neverDrop.createServer(serverOptions, function(socket){
	socket.on('data', function(data){
		console.log('server data: ', data.toString())
	});

	socket.on('message', function(data){
		console.log('server message: ', data);
	});

	socket.on('heartbeat', function(){
		console.log('server hb');
	});

	socket.write('hithere|poop');
	socket.noaccumulate();
	var fileStream = fs.createReadStream('test.js');
	fileStream.on('close', function(){
		fileStream.unpipe();
		socket.accumulate();
		socket.write('jk u can start again');
	});
	fileStream.pipe(socket, {end: false});
});
server.listen(3547);

var socket = neverDrop.connect(clientOptions);
socket.on('error', function(e){
	console.log('error: ', e);
});

socket.on('message', function(data){
	console.log('client message: ', data);
});

socket.on('heartbeat', function(){
		console.log('client hb');
	});

socket.on('data', function(data){
	console.log('client data: ', data.toString());
});<|endoftext|>


<commit_before>var test = require( 'tape' );
var CarteroNodeHook = require( "../" );
var path = require( "path" );

test( 'throw errors when required options are missing', function( t ) {
	t.plan( 2 );

	t.throws( function() {
		var hook = CarteroNodeHook();
	} );

	t.throws( function() {
		var hook = CarteroNodeHook( '' );
	} );
} );

test( 'example3', function( t ) {
	t.plan( 3 );
	var hook = new CarteroNodeHook(
		path.join( __dirname, "example3/static/assets" ),
		{
			outputDirUrl : "/l"
		}
	);

	hook.getParcelAssets( '/my/fake/abs/path/page1', function( err, result ) {
		if( err ) throw err;

		t.deepEqual( result, {
			script : [ 'b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_14d030e0e64ea9a1fced71e9da118cb29caa6676.js' ],
			style : [ 'b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_da3d062d2f431a76824e044a5f153520dad4c697.css' ] }
		);
	} );

	hook.getParcelTags( '/my/fake/abs/path/page1', function( err, scriptTags, styleTags ) {
		if( err ) throw err;

		t.deepEqual( scriptTags, '<script type=\'text/javascript\' src=\'/l/b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_14d030e0e64ea9a1fced71e9da118cb29caa6676.js\'></script>' );
		t.deepEqual( styleTags, '<link rel=\'stylesheet\' href=\'/l/b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_da3d062d2f431a76824e044a5f153520dad4c697.css\'></link>' );
	} );
} );

test( 'example3 (no baseUrl)', function( t ) {

	t.plan( 3 );
	var hook = new CarteroNodeHook(
		path.join( __dirname, "example3/static/assets" )
	);

	hook.getParcelAssets( '/my/fake/abs/path/page2', function( err, result ) {
		if( err ) throw err;

		t.deepEqual( result, {
			script : [ 'ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_5066f9594b8be17fd6360e23df52ffe750206020.js' ],
			style : [ 'ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_182694e4a327db0056cfead31f2396287b7d4544.css' ] }
		);
	} );

	hook.getParcelTags( '/my/fake/abs/path/page2', function( err, scriptTags, styleTags ) {
		if( err ) throw err;

		t.deepEqual( scriptTags, '<script type=\'text/javascript\' src=\'/ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_5066f9594b8be17fd6360e23df52ffe750206020.js\'></script>' );
		t.deepEqual( styleTags, '<link rel=\'stylesheet\' href=\'/ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_182694e4a327db0056cfead31f2396287b7d4544.css\'></link>' );
	} );
} );<commit_msg>added tests for getAssetUrl<commit_after>var test = require( 'tape' );
var CarteroNodeHook = require( "../" );
var path = require( "path" );

test( 'throw errors when required options are missing', function( t ) {
	t.plan( 2 );

	t.throws( function() {
		var hook = CarteroNodeHook();
	} );

	t.throws( function() {
		var hook = CarteroNodeHook( '' );
	} );
} );

test( 'example3', function( t ) {
	t.plan( 4 );

	var hook = new CarteroNodeHook(
		path.join( __dirname, "example3/static/assets" ),
		{
			outputDirUrl : "/l"
		}
	);

	hook.getParcelAssets( '/my/fake/abs/path/page1', function( err, result ) {
		if( err ) throw err;

		t.deepEqual( result, {
			script : [ 'b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_14d030e0e64ea9a1fced71e9da118cb29caa6676.js' ],
			style : [ 'b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_da3d062d2f431a76824e044a5f153520dad4c697.css' ] }
		);
	} );

	hook.getParcelTags( '/my/fake/abs/path/page1', function( err, scriptTags, styleTags ) {
		if( err ) throw err;

		t.deepEqual( scriptTags, '<script type=\'text/javascript\' src=\'/l/b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_14d030e0e64ea9a1fced71e9da118cb29caa6676.js\'></script>' );
		t.deepEqual( styleTags, '<link rel=\'stylesheet\' href=\'/l/b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1_bundle_da3d062d2f431a76824e044a5f153520dad4c697.css\'></link>' );
	} );

	t.deepEqual( hook.getAssetUrl( '/my/fake/abs/path/page1/page1.js' ), '/l/b4ca7610c2ace13dc8d4c9f96eb62b459fcfceca/page1.js' );
} );

test( 'example3 (no baseUrl)', function( t ) {
	t.plan( 4 );

	var hook = new CarteroNodeHook(
		path.join( __dirname, "example3/static/assets" )
	);

	hook.getParcelAssets( '/my/fake/abs/path/page2', function( err, result ) {
		if( err ) throw err;

		t.deepEqual( result, {
			script : [ 'ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_5066f9594b8be17fd6360e23df52ffe750206020.js' ],
			style : [ 'ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_182694e4a327db0056cfead31f2396287b7d4544.css' ] }
		);
	} );

	hook.getParcelTags( '/my/fake/abs/path/page2', function( err, scriptTags, styleTags ) {
		if( err ) throw err;

		t.deepEqual( scriptTags, '<script type=\'text/javascript\' src=\'/ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_5066f9594b8be17fd6360e23df52ffe750206020.js\'></script>' );
		t.deepEqual( styleTags, '<link rel=\'stylesheet\' href=\'/ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2_bundle_182694e4a327db0056cfead31f2396287b7d4544.css\'></link>' );
	} );

	t.deepEqual( hook.getAssetUrl( '/my/fake/abs/path/page2/page2.js' ), '/ea7138e6b6eea6321eb1926e8ac88d65f16aa51d/page2.js' );
} );<|endoftext|>