<commit_before>// Core tests
require('can-component/test/tests');
require('can-define/test/test');
// require('can-route/test/test'); in dev-only
// require('can-route-pushstate/can-route-pushstate_test'); in dev-only
// require('can-stache/test/stache-test'); in dev-only
require('can-stache-bindings/test/tests');
require('can-set/test/test');
// can-connect
// can-stache-route-helpers

// Infrastructure tests
require('can-ajax/can-ajax-test');
require('can-assign/can-assign-test');
require('can-construct/can-construct_test');
require('can-construct-super/test/can-construct-super_test');
require('can-control/can-control_test');
require('can-define-lazy-value/define-lazy-value-test');
require('can-deparam/can-deparam-test');
require('can-dom-events/can-dom-events-test');
require('can-event-dom-enter/can-event-dom-enter-test');
require('can-event-dom-radiochange/can-event-dom-radiochange-test');
require('can-event-queue/can-event-queue-test');
require('can-globals/can-globals-test');
require('can-key-tree/can-key-tree-test');
// require('can-observation/can-observation_test'); in dev-only
require('can-param/can-param-test');
require('can-parse-uri/can-parse-uri-test');
require('can-queues/can-queues-test');
require('can-reflect/can-reflect-test');
require('can-reflect-dependencies/test');
require('can-reflect-promise/test/can-reflect-promise_test');
require('can-simple-dom/test/test');
// require('can-simple-map/can-simple-map_test'); in dev-only
require('can-simple-observable/can-simple-observable-test');
require('can-stache-key/can-stache-key-test');
require('can-symbol/can-symbol-test');
require('can-util/test/test');
require('can-validate-interface/test');
// require('can-view-callbacks/test/callbacks-test'); in dev-only
require('can-view-live/test/test');
require('can-view-model/test/test');
require('can-view-nodelist/test/can-view-nodelist-test');
require('can-view-parser/test/can-view-parser-test');
require('can-view-scope/test/scope-test');
require('can-view-target/test/test');
// require('can-zone/test/test'); needs to publish this

require('can-stache-converters/test/test');

// Legacy tests
require('can-compute/can-compute_test');
require('can-list/can-list_test');
require('can-map/can-map_test');

//require('can-map-define/can-map-define_test');
//require('can-view-href/test/test');
//require('can-map-backup/can-map-backup_test');
//require('can-validate-legacy/can-validate-test');

// Ecosystem tests
require('can-fixture/test/fixture_test');
//require('can-connect-signalr/test');
//require('can-connect-cloneable/test/test');
// require('can-connect-feathers/test/test'); depends on babel-polyfill
require('can-kefir/can-kefir-test');
require('can-stream/can-stream_test');
require('can-stream-kefir/can-stream-kefir_test');
require('can-ndjson-stream/can-ndjson-stream-test');
// require('can-vdom/test/test'); uses mocha
//require('can-connect-ndjson/test/can-connect-ndjson-test');
//if(typeof Proxy === "function"){
//	require('can-observe/test');
//}
require('can-define-stream/can-define-stream_test');
require('can-define-stream-kefir/can-define-stream-kefir_test');

require('can-validate/test');
require('can-validate-validatejs/test');
require('can-define-validate-validatejs/test');

require('react-view-model/test/test#?can/test/browser-supports-react');
//require('can-react-component/test/test#?can/test/browser-supports-react');
// require('can-jquery/test/test');
// require('can-vdom/test/test');
require('can-view-autorender/test/test');
// require('can-zone/test/test');
// require('can-zone-storage/test/can-zone-storage_zone-test');

// Integration tests
//require('../docs/can-guides/experiment/todomvc/test');
//require('./integration/all/test');
<commit_msg>not running the can-util/dom tests<commit_after>// Core tests
require('can-component/test/tests');
require('can-define/test/test');
// require('can-route/test/test'); in dev-only
// require('can-route-pushstate/can-route-pushstate_test'); in dev-only
// require('can-stache/test/stache-test'); in dev-only
require('can-stache-bindings/test/tests');
require('can-set/test/test');
// can-connect
// can-stache-route-helpers

// Infrastructure tests
require('can-ajax/can-ajax-test');
require('can-assign/can-assign-test');
require('can-construct/can-construct_test');
require('can-construct-super/test/can-construct-super_test');
require('can-control/can-control_test');
require('can-define-lazy-value/define-lazy-value-test');
require('can-deparam/can-deparam-test');
require('can-dom-events/can-dom-events-test');
require('can-event-dom-enter/can-event-dom-enter-test');
require('can-event-dom-radiochange/can-event-dom-radiochange-test');
require('can-event-queue/can-event-queue-test');
require('can-globals/can-globals-test');
require('can-key-tree/can-key-tree-test');
// require('can-observation/can-observation_test'); in dev-only
require('can-param/can-param-test');
require('can-parse-uri/can-parse-uri-test');
require('can-queues/can-queues-test');
require('can-reflect/can-reflect-test');
require('can-reflect-dependencies/test');
require('can-reflect-promise/test/can-reflect-promise_test');
require('can-simple-dom/test/test');
// require('can-simple-map/can-simple-map_test'); in dev-only
require('can-simple-observable/can-simple-observable-test');
require('can-stache-key/can-stache-key-test');
require('can-symbol/can-symbol-test');
// require('can-util/dom/tests');
require('can-util/js/tests');
require('can-validate-interface/test');
// require('can-view-callbacks/test/callbacks-test'); in dev-only
require('can-view-live/test/test');
require('can-view-model/test/test');
require('can-view-nodelist/test/can-view-nodelist-test');
require('can-view-parser/test/can-view-parser-test');
require('can-view-scope/test/scope-test');
require('can-view-target/test/test');
// require('can-zone/test/test'); needs to publish this

require('can-stache-converters/test/test');

// Legacy tests
require('can-compute/can-compute_test');
require('can-list/can-list_test');
require('can-map/can-map_test');

//require('can-map-define/can-map-define_test');
//require('can-view-href/test/test');
//require('can-map-backup/can-map-backup_test');
//require('can-validate-legacy/can-validate-test');

// Ecosystem tests
require('can-fixture/test/fixture_test');
//require('can-connect-signalr/test');
//require('can-connect-cloneable/test/test');
// require('can-connect-feathers/test/test'); depends on babel-polyfill
require('can-kefir/can-kefir-test');
require('can-stream/can-stream_test');
require('can-stream-kefir/can-stream-kefir_test');
require('can-ndjson-stream/can-ndjson-stream-test');
// require('can-vdom/test/test'); uses mocha
//require('can-connect-ndjson/test/can-connect-ndjson-test');
//if(typeof Proxy === "function"){
//	require('can-observe/test');
//}
require('can-define-stream/can-define-stream_test');
require('can-define-stream-kefir/can-define-stream-kefir_test');

require('can-validate/test');
require('can-validate-validatejs/test');
require('can-define-validate-validatejs/test');

require('react-view-model/test/test#?can/test/browser-supports-react');
//require('can-react-component/test/test#?can/test/browser-supports-react');
// require('can-jquery/test/test');
// require('can-vdom/test/test');
require('can-view-autorender/test/test');
// require('can-zone/test/test');
// require('can-zone-storage/test/can-zone-storage_zone-test');

// Integration tests
//require('../docs/can-guides/experiment/todomvc/test');
//require('./integration/all/test');
<|endoftext|>


<commit_before>'use strict';

var should = require('should');

var DependencyManager = require('../src/dependency-manager');

describe('dependency injection', function () {
  var dm;

  beforeEach(function () {
    dm = new DependencyManager();
  });

  describe('core api', function () {
    it('allows to set and get dependency', function (done) {
      dm.set('a', 1);

      dm.get('a', function (a) {
        a.should.equal(1);
        done();
      });
    });

    it('allows to get dependency as a promise', function () {
      dm.set('a', 1);

      var promise = dm.get('a');

      promise.should.have.property('then');

      return promise.then(function (a) {
        a.should.equal(1);
      });
    });

    it('allows to get multiple dependencies as array', function (done) {
      dm.set('a', 1);
      dm.set('b', 2);

      dm.getAsArray(['a', 'b'], function (deps) {
        deps.should.be.an.Array.and.eql([1, 2]);
        dm.set('c', 3);
      });

      dm.getAsArray(['a', 'b', 'c'])
        .then(function (deps) {
          deps.should.be.an.Array.and.eql([1, 2, 3]);
          done();
        });
    });

    it('allows to get multiple dependencies as object', function (done) {
      dm.set('a', 1);
      dm.set('b', 2);

      dm.getAsObject(['a', 'b'], function (deps) {
        deps.should.be.an.Object.and.eql({ a: 1, b: 2 });
        dm.set('c', 3);
      });

      dm.getAsObject(['a', 'b', 'c'])
        .then(function (deps) {
          deps.should.be.an.Object.and.eql({ a: 1, b: 2, c: 3 });
          done();
        });
    });

    it('works asynchronously in any order', function () {
      dm.set('a', 1);

      dm.getAsObject(['a', 'b'])
        .then(function (deps) {
          deps.should.be.an.Object.and.eql({ a: 1, b: 2 });

          setTimeout(function () {
            dm.set('c', 3);
          }, 50);
        });

      setTimeout(function () {
        dm.set('b', 2);
      }, 50);

      return dm
        .get('c')
        .then(function (c) {
          c.should.equal(3);
        });
    });
  });

  describe('injection api', function () {
    it('can use constructors to create dependencies', function () {
      function Animal() {}

      dm.provide('dog', ['class', Animal]);
      dm.provide('cat', ['type', Animal]);

      return dm
        .getAsObject(['dog', 'cat'])
        .then(function (deps) {
          deps
            .should.be.an.Object
            .and
            .have.properties(['dog', 'cat']);

          deps.dog.should.be.an.instanceof(Animal);
          deps.cat.should.be.an.instanceof(Animal);

          deps.dog.should.not.equal(deps.cat);
        });
    });

    it('can use factory functions to create dependencies', function () {
      function getObject() {
        return {
          some: 'value'
        };
      }

      dm.provide('object', ['factory', getObject]);

      return dm
        .get('object')
        .then(function (object) {
          object.should.have.property('some', 'value');
        });
    });

    it('can use any value directly as a dependency', function () {
      function some() {}

      dm.provide('pi', ['value', 3.14]);
      dm.provide('func', ['value', some]);

      return dm
        .getAsObject(['pi', 'func'])
        .then(function (deps) {
          deps
            .should.be.an.Object
            .and
            .have.properties(['pi', 'func']);

          deps.pi.should.equal(3.14);
          deps.func.should.equal(some);
        });
    });

    describe('injects dependencies to constructors', function () {
      it('as an array (using $depends)', function () {
        function Class(a, b) {
          a.should.equal(1);
          b.should.equal(2);

          this.a = a;
          this.b = b;
        }

        Class.$depends = ['a', 'b'];

        dm.provide('instance', ['class', Class]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance
              .should.be.instanceof(Class)
              .and
              .have.properties({ a: 1, b: 2 });
          });
      });

      it('as an array (requested explicitly)', function () {
        function Class(a, b) {
          a.should.equal(1);
          b.should.equal(2);

          this.a = a;
          this.b = b;
        }

        dm.provide('instance', ['class', Class, ['a', 'b']]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance
              .should.be.instanceof(Class)
              .and
              .have.properties({ a: 1, b: 2 });
          });
      });

      it('as an object (using $depends)', function () {
        function Class(deps) {
          deps
            .should.be.an.Object
            .and
            .have.properties({ a: 1, b: 2 });

          this.a = deps.a;
          this.b = deps.b;
        }

        Class.$depends = { a: true, b: true };

        dm.provide('instance', ['class', Class]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance
              .should.be.instanceof(Class)
              .and
              .have.properties({ a: 1, b: 2 });
          });
      });

      it('as an object (requested explicitly)', function () {
        function Class(deps) {
          deps
            .should.be.an.Object
            .and
            .have.properties({ a: 1, b: 2 });

          this.a = deps.a;
          this.b = deps.b;
        }

        dm.provide('instance', ['class', Class, { a: true, b: true }]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance
              .should.be.instanceof(Class)
              .and
              .have.properties({ a: 1, b: 2 });
          });
      });
    });

    describe('injects dependencies to factories', function () {
      it('as an array (using $depends)', function () {
        function getObject(a, b) {
          a.should.equal(1);
          b.should.equal(2);

          return {
            a: a,
            b: b
          };
        }

        getObject.$depends = ['a', 'b'];

        dm.provide('instance', ['factory', getObject]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance.should.have.properties({ a: 1, b: 2 });
          });
      });

      it('as an array (requested explicitly)', function () {
        function getObject(a, b) {
          a.should.equal(1);
          b.should.equal(2);

          return {
            a: a,
            b: b
          };
        }

        dm.provide('instance', ['factory', getObject, ['a', 'b']]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance.should.have.properties({ a: 1, b: 2 });
          });
      });

      it('as an object (using $depends)', function () {
        function getObject(deps) {
          deps
            .should.be.an.Object
            .and
            .have.properties({ a: 1, b: 2 });

          return {
            a: deps.a,
            b: deps.b
          };
        }

        getObject.$depends = { a: true, b: true };

        dm.provide('instance', ['factory', getObject]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance.should.have.properties({ a: 1, b: 2 });
          });
      });

      it('as an object (requested explicitly)', function () {
        function getObject(deps) {
          deps
            .should.be.an.Object
            .and
            .have.properties({ a: 1, b: 2 });

          return {
            a: deps.a,
            b: deps.b
          };
        }

        dm.provide('instance', ['factory', getObject, { a: true, b: true }]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance.should.have.properties({ a: 1, b: 2 });
          });
      });
    });

    describe('returns original source after providing them', function () {
      // Either this should not happen
      // or dependencies should not be created until the first `invoke()` call '
      throw new Error();
    });
  });
});<commit_msg>comment<commit_after>'use strict';

var should = require('should');

var DependencyManager = require('../src/dependency-manager');

describe('dependency injection', function () {
  var dm;

  beforeEach(function () {
    dm = new DependencyManager();
  });

  describe('core api', function () {
    it('allows to set and get dependency', function (done) {
      dm.set('a', 1);

      dm.get('a', function (a) {
        a.should.equal(1);
        done();
      });
    });

    it('allows to get dependency as a promise', function () {
      dm.set('a', 1);

      var promise = dm.get('a');

      promise.should.have.property('then');

      return promise.then(function (a) {
        a.should.equal(1);
      });
    });

    it('allows to get multiple dependencies as array', function (done) {
      dm.set('a', 1);
      dm.set('b', 2);

      dm.getAsArray(['a', 'b'], function (deps) {
        deps.should.be.an.Array.and.eql([1, 2]);
        dm.set('c', 3);
      });

      dm.getAsArray(['a', 'b', 'c'])
        .then(function (deps) {
          deps.should.be.an.Array.and.eql([1, 2, 3]);
          done();
        });
    });

    it('allows to get multiple dependencies as object', function (done) {
      dm.set('a', 1);
      dm.set('b', 2);

      dm.getAsObject(['a', 'b'], function (deps) {
        deps.should.be.an.Object.and.eql({ a: 1, b: 2 });
        dm.set('c', 3);
      });

      dm.getAsObject(['a', 'b', 'c'])
        .then(function (deps) {
          deps.should.be.an.Object.and.eql({ a: 1, b: 2, c: 3 });
          done();
        });
    });

    it('works asynchronously in any order', function () {
      dm.set('a', 1);

      dm.getAsObject(['a', 'b'])
        .then(function (deps) {
          deps.should.be.an.Object.and.eql({ a: 1, b: 2 });

          setTimeout(function () {
            dm.set('c', 3);
          }, 50);
        });

      setTimeout(function () {
        dm.set('b', 2);
      }, 50);

      return dm
        .get('c')
        .then(function (c) {
          c.should.equal(3);
        });
    });
  });

  describe('injection api', function () {
    it('can use constructors to create dependencies', function () {
      function Animal() {}

      dm.provide('dog', ['class', Animal]);
      dm.provide('cat', ['type', Animal]);

      return dm
        .getAsObject(['dog', 'cat'])
        .then(function (deps) {
          deps
            .should.be.an.Object
            .and
            .have.properties(['dog', 'cat']);

          deps.dog.should.be.an.instanceof(Animal);
          deps.cat.should.be.an.instanceof(Animal);

          deps.dog.should.not.equal(deps.cat);
        });
    });

    it('can use factory functions to create dependencies', function () {
      function getObject() {
        return {
          some: 'value'
        };
      }

      dm.provide('object', ['factory', getObject]);

      return dm
        .get('object')
        .then(function (object) {
          object.should.have.property('some', 'value');
        });
    });

    it('can use any value directly as a dependency', function () {
      function some() {}

      dm.provide('pi', ['value', 3.14]);
      dm.provide('func', ['value', some]);

      return dm
        .getAsObject(['pi', 'func'])
        .then(function (deps) {
          deps
            .should.be.an.Object
            .and
            .have.properties(['pi', 'func']);

          deps.pi.should.equal(3.14);
          deps.func.should.equal(some);
        });
    });

    describe('injects dependencies to constructors', function () {
      it('as an array (using $depends)', function () {
        function Class(a, b) {
          a.should.equal(1);
          b.should.equal(2);

          this.a = a;
          this.b = b;
        }

        Class.$depends = ['a', 'b'];

        dm.provide('instance', ['class', Class]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance
              .should.be.instanceof(Class)
              .and
              .have.properties({ a: 1, b: 2 });
          });
      });

      it('as an array (requested explicitly)', function () {
        function Class(a, b) {
          a.should.equal(1);
          b.should.equal(2);

          this.a = a;
          this.b = b;
        }

        dm.provide('instance', ['class', Class, ['a', 'b']]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance
              .should.be.instanceof(Class)
              .and
              .have.properties({ a: 1, b: 2 });
          });
      });

      it('as an object (using $depends)', function () {
        function Class(deps) {
          deps
            .should.be.an.Object
            .and
            .have.properties({ a: 1, b: 2 });

          this.a = deps.a;
          this.b = deps.b;
        }

        Class.$depends = { a: true, b: true };

        dm.provide('instance', ['class', Class]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance
              .should.be.instanceof(Class)
              .and
              .have.properties({ a: 1, b: 2 });
          });
      });

      it('as an object (requested explicitly)', function () {
        function Class(deps) {
          deps
            .should.be.an.Object
            .and
            .have.properties({ a: 1, b: 2 });

          this.a = deps.a;
          this.b = deps.b;
        }

        dm.provide('instance', ['class', Class, { a: true, b: true }]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance
              .should.be.instanceof(Class)
              .and
              .have.properties({ a: 1, b: 2 });
          });
      });
    });

    describe('injects dependencies to factories', function () {
      it('as an array (using $depends)', function () {
        function getObject(a, b) {
          a.should.equal(1);
          b.should.equal(2);

          return {
            a: a,
            b: b
          };
        }

        getObject.$depends = ['a', 'b'];

        dm.provide('instance', ['factory', getObject]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance.should.have.properties({ a: 1, b: 2 });
          });
      });

      it('as an array (requested explicitly)', function () {
        function getObject(a, b) {
          a.should.equal(1);
          b.should.equal(2);

          return {
            a: a,
            b: b
          };
        }

        dm.provide('instance', ['factory', getObject, ['a', 'b']]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance.should.have.properties({ a: 1, b: 2 });
          });
      });

      it('as an object (using $depends)', function () {
        function getObject(deps) {
          deps
            .should.be.an.Object
            .and
            .have.properties({ a: 1, b: 2 });

          return {
            a: deps.a,
            b: deps.b
          };
        }

        getObject.$depends = { a: true, b: true };

        dm.provide('instance', ['factory', getObject]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance.should.have.properties({ a: 1, b: 2 });
          });
      });

      it('as an object (requested explicitly)', function () {
        function getObject(deps) {
          deps
            .should.be.an.Object
            .and
            .have.properties({ a: 1, b: 2 });

          return {
            a: deps.a,
            b: deps.b
          };
        }

        dm.provide('instance', ['factory', getObject, { a: true, b: true }]);

        dm.set('a', 1);
        dm.set('b', 2);

        return dm
          .get('instance')
          .then(function (instance) {
            instance.should.have.properties({ a: 1, b: 2 });
          });
      });
    });

    describe('returns original source after providing dependency', function () {
      // Either this should not happen
      // or dependencies should not be created until the first `invoke()` call '
      throw new Error();
    });
  });
});<|endoftext|>


<commit_before>var _ = require('lodash');

var getRequirejsConfig = function () {
  var requirejsConfig;
  global.define = function (config) {
    requirejsConfig = config({ isBuild: true });
  };
  require('./app/config');

  return _.extend(requirejsConfig, {
    baseUrl: 'app',
    name: 'client',
    waitSeconds: 60,
    include: ['vendor/almond'],
    deps: [
      'client',
      'client/client_bootstrap'
    ],
    wrap: true,
    optimize: 'uglify'
  });
};

var addArgs = function (cmd) {
  return function () {
    return [cmd].concat([].slice.apply(arguments)).join(' ');
  };
};

var requirejsConfig = getRequirejsConfig();

module.exports = function (grunt) {
  'use strict';

  grunt.initConfig({
    // Removes the contents of the public directory
    clean: ['public/'],
    // Builds Sass in development and production
    sass: {
      development: {
        files: {
          'public/stylesheets/spotlight.css': 'styles/index.scss'
        },
        options: {
          includePaths: [
            'node_modules/govuk_frontend_toolkit/govuk_frontend_toolkit/stylesheets'
          ],
          style: 'nested',
          sourceComments: 'map'
        }
      },
      production: {
        files: [
          { 'public/stylesheets/spotlight.css': 'styles/index.scss' },
          {
            expand: true,
            cwd: 'node_modules/govuk_template_mustache/assets/stylesheets',
            src: ['*.css'],
            dest: 'public/stylesheets',
            ext: '.css'
          }
        ],
        options: {
          includePaths: [
            'node_modules/govuk_frontend_toolkit/govuk_frontend_toolkit/stylesheets'
          ],
          outputStyle: 'compressed'
        }
      }
    },
    // Sets up Jasmine tests
    jasmine: {
      spotlight: {
        src: ['app/**/*.js'],
        options: {
          helpers: ['spec/helpers/*.js'],
          specs: [
            'spec/shared/**/spec.*.js',
            'spec/client/**/spec.*.js'
          ],
          template: 'spec/index.html',
          keepRunner: true
        }
      }
    },
    // Sets up server-side Jasmine node tests
    jasmine_node: {
      legacy: {
        verbose: false,
        src: './spec/helpers',
        options: {
          specFolders: [
            './spec/shared',
            './spec/server'
          ],
          useHelpers: true,
          specNameMatcher: 'spec.*', // load only specs containing specNameMatcher
          match: '.*',
          useRequireJs: 'spec/requirejs-setup.js',
          verbose: false,
          jUnit: {
            report: false,
            savePath : './build/reports/jasmine/',
            useDotNotation: true,
            consolidate: true
          }
        }
      },
      server: {
        verbose: false,
        src: './spec/server-pure',
        options: {
          specFolders: [
            './spec/server-pure'
          ],
          useHelpers: true,
          specNameMatcher: 'spec.*', // load only specs containing specNameMatcher
          match: '.*',
          verbose: false,
          jUnit: {
            report: false,
            savePath : './build/reports/jasmine/',
            useDotNotation: true,
            consolidate: true
          }
        }
      },
    },
    // Sets up server-side Jasmine node tests
    // Lints our JavaScript
    jshint: {
      files: ['app/**/*.js', 'app/**/*.json', 'spec/**/*.js', 'tools/**/*.js'],
      options: {
        reporter: require('jshint-stylish'),
        jshintrc: true
      }
    },
    // Creates a single big JS file
    requirejs: {
      production: {
        options: _.extend({}, requirejsConfig, {
          out: 'public/javascripts/spotlight.js',
          d3: true
        })
      },
      'production-no-d3': {
        options: _.extend({}, requirejsConfig, {
          out: 'public/javascripts/spotlight-no-d3.js',
          d3: false
        })
      }
    },
    // Copies templates and assets from external modules and dirs
    copy: {
      govuk_template: {
        src: 'node_modules/govuk_template_mustache/views/layouts/govuk_template.html',
        dest: 'app/server/templates/page-components/',
        expand: true,
        flatten: true,
        filter: 'isFile'
      },
      govuk_assets: {
        files: [
          {
            expand: true,
            src: '**',
            cwd: 'node_modules/govuk_template_mustache/assets',
            dest: 'public/'
          }
        ]
      },
      spotlight_assets: {
        files: [
          {
            expand: true,
            src: '**',
            cwd: 'assets',
            dest: 'public/'
          }
        ]
      },
      vendor: {
        files: [
          {
            src: 'node_modules/backbone/backbone.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          },
          {
            src: 'node_modules/d3/d3.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          },
          {
            src: 'node_modules/moment-timezone/moment-timezone.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          },
          {
            src: 'node_modules/lodash/dist/lodash.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          }
        ]
      }
    },
    // Watches styles and specs for changes
    watch: {
      css: {
        files: ['styles/**/*.scss'],
        tasks: ['sass:development'],
        options: { nospawn: true }
      },
      spec: {
        files: ['spec/**/spec.*.js'],
        tasks: ['jasmine:spotlight:build']
      }
    },
    shell: {
      // Runs cheapseats tests
      cheapseats: {
        options: {
          failOnError: true,
          stderr: true,
          stdout: true
        },
        command: addArgs('node ./node_modules/cheapseats/index.js --reporter dot-retry --standalone --path ./')
      },
      // Generates the page-per-thing module JSON stubs
      generate_services_list: {
        options: {
          failOnError: true,
          stderr: true,
          stdout: true
        },
        command: 'node tools/generate-services-list.js'
      },
      // Generates the page-per-thing module JSON stubs
      validate_module_stubs: {
        options: {
          failOnError: true,
          stderr: true,
          stdout: true
        },
        command: addArgs('node tools/validate-stubs.js')
      },
      // Supervises the node process in development
      supervisor: {
        options: {
          stdout: true,
          stderr: true,
          execOptions: {
            maxBuffer: Infinity
          }
        },
        command: './node_modules/supervisor/lib/cli-wrapper.js -w app -i app/vendor -e "js|html" -n error app/server'
      }
    },
    // Runs development tasks concurrently
    concurrent: {
      dev: {
        tasks: ['shell:supervisor', 'watch'],
        options: {
          logConcurrentOutput: true
        }
      }
    },
    // Creates an asset digest for cachebusting URLs
    digest: {
      options: {
        out: 'public/asset-digest.json',
        separator: '-',
        algorithm: 'md5'
      },
      files: {
        src: ['public/**/*.*']
      }
    }
  });

  // Load external module tasks
  [
    'grunt-contrib-jasmine',
    'grunt-jasmine-node-new',
    'grunt-contrib-jshint',
    'grunt-contrib-clean',
    'grunt-contrib-requirejs',
    'grunt-digest',
    'grunt-sass',
    'grunt-contrib-copy',
    'grunt-contrib-watch',
    'grunt-shell',
    'grunt-concurrent'
  ].forEach(function (task) {
    grunt.loadNpmTasks(task);
  });

  grunt.registerTask('copy:assets', [
    'copy:govuk_assets',
    'copy:spotlight_assets'
  ]);

  grunt.registerTask('build:common', [
    'copy:vendor',
    'copy:govuk_template',
    'clean',
    'copy:assets',
    'shell:validate_module_stubs',
    'shell:generate_services_list'
  ]);

  grunt.registerTask('build:development', [
    'build:common',
    'sass:development',
    'digest'
  ]);

  grunt.registerTask('build:production', [
    'build:common',
    'sass:production',
    'requirejs:production',
    'requirejs:production-no-d3',
    'digest'
  ]);

  grunt.registerTask('test:stubs', [
    'shell:validate_module_stubs'
  ]);

  grunt.registerTask('test:stubs:unpublished', [
    'shell:validate_module_stubs:--unpublished'
  ]);

  grunt.registerTask('test:unit', [
    'copy:vendor',
    'copy:govuk_template',
    'clean',
    'copy:assets',
    'shell:validate_module_stubs',
    'shell:generate_services_list',
    'sass:development',
    'digest',
    'jasmine',
    'jasmine_node',
    'jshint'
  ]);

  grunt.registerTask('test:all', [
    'test:unit',
    'shell:cheapseats'
  ]);

  grunt.registerTask('cheapseats', [
    'shell:cheapseats'
  ]);

  grunt.registerTask('cheapseats:unpublished', [
    'shell:cheapseats:--unpublished'
  ]);

  // Default task
  grunt.registerTask('default', [
    'build:development',
    'jasmine:spotlight:build',
    'concurrent'
  ]);

  grunt.registerTask('heroku:development', [
    'build:development'
  ]);

};
<commit_msg>We need to include the logger as a dependency<commit_after>var _ = require('lodash');

var getRequirejsConfig = function () {
  var requirejsConfig;
  global.define = function (config) {
    requirejsConfig = config({ isBuild: true });
  };
  require('./app/config');

  return _.extend(requirejsConfig, {
    baseUrl: 'app',
    name: 'client',
    waitSeconds: 60,
    include: ['vendor/almond'],
    deps: [
      'client',
      'client/client_bootstrap',
      'client/logger'
    ],
    wrap: true,
    optimize: 'uglify'
  });
};

var addArgs = function (cmd) {
  return function () {
    return [cmd].concat([].slice.apply(arguments)).join(' ');
  };
};

var requirejsConfig = getRequirejsConfig();

module.exports = function (grunt) {
  'use strict';

  grunt.initConfig({
    // Removes the contents of the public directory
    clean: ['public/'],
    // Builds Sass in development and production
    sass: {
      development: {
        files: {
          'public/stylesheets/spotlight.css': 'styles/index.scss'
        },
        options: {
          includePaths: [
            'node_modules/govuk_frontend_toolkit/govuk_frontend_toolkit/stylesheets'
          ],
          style: 'nested',
          sourceComments: 'map'
        }
      },
      production: {
        files: [
          { 'public/stylesheets/spotlight.css': 'styles/index.scss' },
          {
            expand: true,
            cwd: 'node_modules/govuk_template_mustache/assets/stylesheets',
            src: ['*.css'],
            dest: 'public/stylesheets',
            ext: '.css'
          }
        ],
        options: {
          includePaths: [
            'node_modules/govuk_frontend_toolkit/govuk_frontend_toolkit/stylesheets'
          ],
          outputStyle: 'compressed'
        }
      }
    },
    // Sets up Jasmine tests
    jasmine: {
      spotlight: {
        src: ['app/**/*.js'],
        options: {
          helpers: ['spec/helpers/*.js'],
          specs: [
            'spec/shared/**/spec.*.js',
            'spec/client/**/spec.*.js'
          ],
          template: 'spec/index.html',
          keepRunner: true
        }
      }
    },
    // Sets up server-side Jasmine node tests
    jasmine_node: {
      legacy: {
        verbose: false,
        src: './spec/helpers',
        options: {
          specFolders: [
            './spec/shared',
            './spec/server'
          ],
          useHelpers: true,
          specNameMatcher: 'spec.*', // load only specs containing specNameMatcher
          match: '.*',
          useRequireJs: 'spec/requirejs-setup.js',
          verbose: false,
          jUnit: {
            report: false,
            savePath : './build/reports/jasmine/',
            useDotNotation: true,
            consolidate: true
          }
        }
      },
      server: {
        verbose: false,
        src: './spec/server-pure',
        options: {
          specFolders: [
            './spec/server-pure'
          ],
          useHelpers: true,
          specNameMatcher: 'spec.*', // load only specs containing specNameMatcher
          match: '.*',
          verbose: false,
          jUnit: {
            report: false,
            savePath : './build/reports/jasmine/',
            useDotNotation: true,
            consolidate: true
          }
        }
      },
    },
    // Sets up server-side Jasmine node tests
    // Lints our JavaScript
    jshint: {
      files: ['app/**/*.js', 'app/**/*.json', 'spec/**/*.js', 'tools/**/*.js'],
      options: {
        reporter: require('jshint-stylish'),
        jshintrc: true
      }
    },
    // Creates a single big JS file
    requirejs: {
      production: {
        options: _.extend({}, requirejsConfig, {
          out: 'public/javascripts/spotlight.js',
          d3: true
        })
      },
      'production-no-d3': {
        options: _.extend({}, requirejsConfig, {
          out: 'public/javascripts/spotlight-no-d3.js',
          d3: false
        })
      }
    },
    // Copies templates and assets from external modules and dirs
    copy: {
      govuk_template: {
        src: 'node_modules/govuk_template_mustache/views/layouts/govuk_template.html',
        dest: 'app/server/templates/page-components/',
        expand: true,
        flatten: true,
        filter: 'isFile'
      },
      govuk_assets: {
        files: [
          {
            expand: true,
            src: '**',
            cwd: 'node_modules/govuk_template_mustache/assets',
            dest: 'public/'
          }
        ]
      },
      spotlight_assets: {
        files: [
          {
            expand: true,
            src: '**',
            cwd: 'assets',
            dest: 'public/'
          }
        ]
      },
      vendor: {
        files: [
          {
            src: 'node_modules/backbone/backbone.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          },
          {
            src: 'node_modules/d3/d3.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          },
          {
            src: 'node_modules/moment-timezone/moment-timezone.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          },
          {
            src: 'node_modules/lodash/dist/lodash.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          }
        ]
      }
    },
    // Watches styles and specs for changes
    watch: {
      css: {
        files: ['styles/**/*.scss'],
        tasks: ['sass:development'],
        options: { nospawn: true }
      },
      spec: {
        files: ['spec/**/spec.*.js'],
        tasks: ['jasmine:spotlight:build']
      }
    },
    shell: {
      // Runs cheapseats tests
      cheapseats: {
        options: {
          failOnError: true,
          stderr: true,
          stdout: true
        },
        command: addArgs('node ./node_modules/cheapseats/index.js --reporter dot-retry --standalone --path ./')
      },
      // Generates the page-per-thing module JSON stubs
      generate_services_list: {
        options: {
          failOnError: true,
          stderr: true,
          stdout: true
        },
        command: 'node tools/generate-services-list.js'
      },
      // Generates the page-per-thing module JSON stubs
      validate_module_stubs: {
        options: {
          failOnError: true,
          stderr: true,
          stdout: true
        },
        command: addArgs('node tools/validate-stubs.js')
      },
      // Supervises the node process in development
      supervisor: {
        options: {
          stdout: true,
          stderr: true,
          execOptions: {
            maxBuffer: Infinity
          }
        },
        command: './node_modules/supervisor/lib/cli-wrapper.js -w app -i app/vendor -e "js|html" -n error app/server'
      }
    },
    // Runs development tasks concurrently
    concurrent: {
      dev: {
        tasks: ['shell:supervisor', 'watch'],
        options: {
          logConcurrentOutput: true
        }
      }
    },
    // Creates an asset digest for cachebusting URLs
    digest: {
      options: {
        out: 'public/asset-digest.json',
        separator: '-',
        algorithm: 'md5'
      },
      files: {
        src: ['public/**/*.*']
      }
    }
  });

  // Load external module tasks
  [
    'grunt-contrib-jasmine',
    'grunt-jasmine-node-new',
    'grunt-contrib-jshint',
    'grunt-contrib-clean',
    'grunt-contrib-requirejs',
    'grunt-digest',
    'grunt-sass',
    'grunt-contrib-copy',
    'grunt-contrib-watch',
    'grunt-shell',
    'grunt-concurrent'
  ].forEach(function (task) {
    grunt.loadNpmTasks(task);
  });

  grunt.registerTask('copy:assets', [
    'copy:govuk_assets',
    'copy:spotlight_assets'
  ]);

  grunt.registerTask('build:common', [
    'copy:vendor',
    'copy:govuk_template',
    'clean',
    'copy:assets',
    'shell:validate_module_stubs',
    'shell:generate_services_list'
  ]);

  grunt.registerTask('build:development', [
    'build:common',
    'sass:development',
    'digest'
  ]);

  grunt.registerTask('build:production', [
    'build:common',
    'sass:production',
    'requirejs:production',
    'requirejs:production-no-d3',
    'digest'
  ]);

  grunt.registerTask('test:stubs', [
    'shell:validate_module_stubs'
  ]);

  grunt.registerTask('test:stubs:unpublished', [
    'shell:validate_module_stubs:--unpublished'
  ]);

  grunt.registerTask('test:unit', [
    'copy:vendor',
    'copy:govuk_template',
    'clean',
    'copy:assets',
    'shell:validate_module_stubs',
    'shell:generate_services_list',
    'sass:development',
    'digest',
    'jasmine',
    'jasmine_node',
    'jshint'
  ]);

  grunt.registerTask('test:all', [
    'test:unit',
    'shell:cheapseats'
  ]);

  grunt.registerTask('cheapseats', [
    'shell:cheapseats'
  ]);

  grunt.registerTask('cheapseats:unpublished', [
    'shell:cheapseats:--unpublished'
  ]);

  // Default task
  grunt.registerTask('default', [
    'build:development',
    'jasmine:spotlight:build',
    'concurrent'
  ]);

  grunt.registerTask('heroku:development', [
    'build:development'
  ]);

};
<|endoftext|>


<commit_before>'use strict';
var URL = require('../models/URL.js'),
	utils = require('../utils.js');

module.exports = {
	createURL: function (req, res) {
		utils.validateHttpURL(req.body.orgURL, function (url) {
			utils.validateCreateURL(url, function (err) {
				if (err.length >= 1) {
					return res.json(200, {'success': false, 'err': err});
				} else {
					var userIP = req.connection.remoteAddress;
					URL.addURL(url, userIP, function (err, result) {
						if (err) {
							return res.json(200, {'success': false, 'err': err});
						} else if (result && result.url_original && result.url_modify) {
							return res.json(200, {'success': true, 'res': result});
						} else {
							return res.json(200, {'success': false });
						}
					});
				}
			});
		});
	},

	getURLStats: function (req, res) {
		var modURL = req.params.modURL;
		utils.validateGoToURL(modURL, function (err) {
			if (err.length >= 1) {
				return res.json(200, {'success': false, 'err': err});
			} else {
				URL.getURLStats(modURL, function (err, result) {
					if (err) {
						return res.json(200, {'success': false, 'err': err});
					} else if (result && result._id) {
						return res.json(200, {'success': true, 'res': result});
					} else {
						return res.json(200, {'success': false});
					}
				});
			}
		});
	},

	goToURL: function (req, res) {
		var modURL = req.params.modURL;
		utils.validateGoToURL(modURL, function (err) {
			if (err.length >= 1) {
				return res.json(200, {'success': false, 'err': err});
			} else {
				URL.goToURL(modURL, function (err, result) {
					if (err) {
						return res.json(200, {'success': false, 'err': err});
					} else if (result && result.url_original) {
						res.redirect(302, result.url_original);
						return res.end();
					} else {
						return res.json(200, {'success': false});
					}
				});
			}
		});
	}
};
<commit_msg>updating the way we pass json back<commit_after>'use strict';
var URL = require('../models/URL.js'),
	utils = require('../utils.js');

module.exports = {
	createURL: function (req, res) {
		utils.validateHttpURL(req.body.orgURL, function (url) {
			utils.validateCreateURL(url, function (err) {
				if (err.length >= 1) {
					return res.status(200).json({'success': false, 'err': err});
				} else {
					var userIP = req.connection.remoteAddress;
					URL.addURL(url, userIP, function (err, result) {
						if (err) {
							return res.status(200).json({'success': false, 'err': err});
						} else if (result && result.url_original && result.url_modify) {
							return res.status(200).json({'success': true, 'res': result});
						} else {
							return res.status(200).json({'success': false });
						}
					});
				}
			});
		});
	},

	getURLStats: function (req, res) {
		var modURL = req.params.modURL;
		utils.validateGoToURL(modURL, function (err) {
			if (err.length >= 1) {
				return res.status(200).json({'success': false, 'err': err});
			} else {
				URL.getURLStats(modURL, function (err, result) {
					if (err) {
						return res.status(200).json({'success': false, 'err': err});
					} else if (result && result._id) {
						return res.status(200).json({'success': true, 'res': result});
					} else {
						return res.status(200).json({'success': false});
					}
				});
			}
		});
	},

	goToURL: function (req, res) {
		var modURL = req.params.modURL;
		utils.validateGoToURL(modURL, function (err) {
			if (err.length >= 1) {
				return res.status(200).json({'success': false, 'err': err});
			} else {
				URL.goToURL(modURL, function (err, result) {
					if (err) {
						return res.status(200).json({'success': false, 'err': err});
					} else if (result && result.url_original) {
						res.redirect(302, result.url_original);
						return res.end();
					} else {
						return res.status(200).json({'success': false});
					}
				});
			}
		});
	}
};
<|endoftext|>


<commit_before>"use strict";

var ndev = require("../src/ndev");
var util = require("../src/util");
var chai = require('chai');

chai.use(require('chai-fs'));

describe("first test", function () {
    it("should copy the title", function (done) {
        ndev.cwd = __dirname + "/tmp/clone/";
        ndev.cmdClone(["https://github.com/javanile/declinejs"], function(out) {
            chai.assert.isDirectory(ndev.cwd + "/ndev_modules/declinejs/");
            chai.assert.isFile(ndev.cwd + "/ndev_modules/declinejs/LICENSE");
            done();
        });
    });
});<commit_msg>  version 0.0.16<commit_after>"use strict";

var ndev = require("../src/ndev");
var util = require("../src/util");
var chai = require('chai');

chai.use(require('chai-fs'));

describe("first test", function () {
    it("should copy the title", function (done) {
        ndev.cwd = __dirname + "/tmp/clone/";
        ndev.cmdClone(["https://github.com/javanile/declinejs"], function(log) {
            console.log(log);
            chai.assert.isDirectory(ndev.cwd + "/ndev_modules/declinejs/");
            chai.assert.isFile(ndev.cwd + "/ndev_modules/declinejs/LICENSE");
            done();
        });
    });
});<|endoftext|>


<commit_before>/* global Pyjamas */

describe('Pyjamas.manifest', function(){
    'use strict';
    var myA, myB;

    var MyClassA = (function(){
        function MyClassA(){
            this.value = 0;
        }

        MyClassA.prototype.add = function(){
            this.value++;
        };

        return MyClassA;
    })();

    var MyClassB = (function(){
        function MyClassB(name){
            this.name = name;
            this.a = new MyClassA();
        }
        return MyClassB;
    })();

    beforeEach(function(){
        myA = new MyClassA();
        myB = new MyClassB('Pyjamas');

        Pyjamas.DB.insert(MyClassA, new Pyjamas('0.1.0', {
            value : Number
        }));

        Pyjamas.DB.insert(MyClassB, new Pyjamas('0.2.0', {
            name    : String,
            a       : MyClassA
        }));
    });

    it('Manifests a single object', function(){
        expect(Pyjamas.manifest(myA)).toEqual({
            version : '0.1.0',
            value   : 0
        });

        myA.add();

        expect(Pyjamas.manifest(myA)).toEqual({
            version : '0.1.0',
            value   : 1
        });
    });

    it('Recursively manifests objects', function(){
        expect(Pyjamas.manifest(myB)).toEqual({
            version : '0.2.0',
            name    : 'Pyjamas',
            a       : {
                version : '0.1.0',
                value   : 0
            }
        });

        myB.a.add();

        expect(Pyjamas.manifest(myB)).toEqual({
            version : '0.2.0',
            name    : 'Pyjamas',
            a       : {
                version : '0.1.0',
                value   : 1
            }
        });
    });

    it('Does not encode an undefined property', function(){
        myB.name = undefined;

        expect(Pyjamas.manifest(myB)).toEqual({
            version : '0.2.0',
            a       : {
                version : '0.1.0',
                value   : 0
            }
        });

    });

    it('Does not encode an function property', function(){
        myB.name = function(){};

        expect(Pyjamas.manifest(myB)).toEqual({
            version : '0.2.0',
            a       : {
                version : '0.1.0',
                value   : 0
            }
        });

    });

});

<commit_msg>[Fixed #41] Moved Parens Into IIFE of Manifest Spec<commit_after>/* global Pyjamas */

describe('Pyjamas.manifest', function(){
    'use strict';
    var myA, myB;

    var MyClassA = (function(){
        function MyClassA(){
            this.value = 0;
        }

        MyClassA.prototype.add = function(){
            this.value++;
        };

        return MyClassA;
    }());

    var MyClassB = (function(){
        function MyClassB(name){
            this.name = name;
            this.a = new MyClassA();
        }
        return MyClassB;
    }());

    beforeEach(function(){
        myA = new MyClassA();
        myB = new MyClassB('Pyjamas');

        Pyjamas.DB.insert(MyClassA, new Pyjamas('0.1.0', {
            value : Number
        }));

        Pyjamas.DB.insert(MyClassB, new Pyjamas('0.2.0', {
            name    : String,
            a       : MyClassA
        }));
    });

    it('Manifests a single object', function(){
        expect(Pyjamas.manifest(myA)).toEqual({
            version : '0.1.0',
            value   : 0
        });

        myA.add();

        expect(Pyjamas.manifest(myA)).toEqual({
            version : '0.1.0',
            value   : 1
        });
    });

    it('Recursively manifests objects', function(){
        expect(Pyjamas.manifest(myB)).toEqual({
            version : '0.2.0',
            name    : 'Pyjamas',
            a       : {
                version : '0.1.0',
                value   : 0
            }
        });

        myB.a.add();

        expect(Pyjamas.manifest(myB)).toEqual({
            version : '0.2.0',
            name    : 'Pyjamas',
            a       : {
                version : '0.1.0',
                value   : 1
            }
        });
    });

    it('Does not encode an undefined property', function(){
        myB.name = undefined;

        expect(Pyjamas.manifest(myB)).toEqual({
            version : '0.2.0',
            a       : {
                version : '0.1.0',
                value   : 0
            }
        });

    });

    it('Does not encode an function property', function(){
        myB.name = function(){};

        expect(Pyjamas.manifest(myB)).toEqual({
            version : '0.2.0',
            a       : {
                version : '0.1.0',
                value   : 0
            }
        });

    });

});

<|endoftext|>


<commit_before>module.exports = function (grunt) {
  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    bower: {
      install: {
        options: {
          targetDir: 'app/lib',
          verbose: true
        }
      }
    },
    copy: {
      closureLibrary: {
        files: [
          {
            expand: true,
            cwd: 'node_modules/',
            src: [
              'google-closure-library/closure/goog/**/*.js',
              'google-closure-library/third_party/closure/goog/**/*.js'
            ],
            dest: 'app/lib/'
          }
        ]
      }
    },
    shell: {
      buildDebug: {
        command: [
          'java -jar node_modules/google-closure-compiler/compiler.jar',

          '--only_closure_dependencies',
          '--closure_entry_point=KeepMeContributing',

          '--create_source_map=app/js/output.js.map',
          '--source_map_location_mapping=app\\|',
          '--output_wrapper "%output%\n//# sourceMappingURL=/js/output.js.map"',

          '--language_in=ECMASCRIPT6',
          '--language_out=ECMASCRIPT5_STRICT',

          '--jscomp_error=constantProperty',
          '--jscomp_error=const',
          '--jscomp_error=checkRegExp',
          '--warning_level=VERBOSE',
          '--jscomp_warning=checkDebuggerStatement',

          '--js=app/lib/google-closure-library/closure/goog/**.js',
          '--js=!app/lib/google-closure-library/closure/goog/**test.js',
          '--js=app/lib/google-closure-library/third_party/closure/goog/**.js',
          '--js=!app/lib/google-closure-library/third_party/closure/goog/**test.js',
          '--js=app/js/KeepMeContributing/**.js',
          '--js_output_file=app/js/app.js'
        ].join(' ')
      },
      buildServer: { command: 'mvn compile' },
      testServer: { command: 'foreman start web' },
      lint: { command: 'eslint Gruntfile.js app/js/' }
    },
    watch: {
      buildDebug: {
        files: ['app/js/KeepMeContributing/*.js'],
        tasks: ['shell:buildDebug', 'notify:buildDebug'],
        options: { interrupt: true }
      },
      buildServer: {
        files: ['src/main/java/**/*.java'],
        tasks: ['shell:buildServer', 'notify:buildServer'],
        options: { interrupt: true }
      }
    },
    notify: {
      buildDebug: {
        options: {
          title: 'buildDebug',
          message: 'Finished to build js/app.js.\nCheck the terminal to check for warnings.'
        }
      },
      buildServer: {
        options: {
          title: 'buildServer',
          message: 'Finished to build the server application.\nCheck the terminal to check for warnings.'
        }
      }
    }
  });

  grunt.registerTask('install', [
    'bower:install',
    'copy:closureLibrary'
  ]);
  grunt.registerTask('test', [
    'shell:buildDebug',
    'shell:testServer'
  ]);

  grunt.registerTask('default', [
    'shell:lint',
    'shell:buildDebug'
  ]);
};
<commit_msg>add task to execute unit tests of server<commit_after>module.exports = function (grunt) {
  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    bower: {
      install: {
        options: {
          targetDir: 'app/lib',
          verbose: true
        }
      }
    },
    copy: {
      closureLibrary: {
        files: [
          {
            expand: true,
            cwd: 'node_modules/',
            src: [
              'google-closure-library/closure/goog/**/*.js',
              'google-closure-library/third_party/closure/goog/**/*.js'
            ],
            dest: 'app/lib/'
          }
        ]
      }
    },
    shell: {
      buildDebug: {
        command: [
          'java -jar node_modules/google-closure-compiler/compiler.jar',

          '--only_closure_dependencies',
          '--closure_entry_point=KeepMeContributing',

          '--create_source_map=app/js/output.js.map',
          '--source_map_location_mapping=app\\|',
          '--output_wrapper "%output%\n//# sourceMappingURL=/js/output.js.map"',

          '--language_in=ECMASCRIPT6',
          '--language_out=ECMASCRIPT5_STRICT',

          '--jscomp_error=constantProperty',
          '--jscomp_error=const',
          '--jscomp_error=checkRegExp',
          '--warning_level=VERBOSE',
          '--jscomp_warning=checkDebuggerStatement',

          '--js=app/lib/google-closure-library/closure/goog/**.js',
          '--js=!app/lib/google-closure-library/closure/goog/**test.js',
          '--js=app/lib/google-closure-library/third_party/closure/goog/**.js',
          '--js=!app/lib/google-closure-library/third_party/closure/goog/**test.js',
          '--js=app/js/KeepMeContributing/**.js',
          '--js_output_file=app/js/app.js'
        ].join(' ')
      },
      buildServer: { command: 'mvn compile' },
      buildServerTest: { command: 'mvn test' },
      testServer: { command: 'foreman start web' },
      lint: { command: 'eslint Gruntfile.js app/js/' }
    },
    watch: {
      buildDebug: {
        files: ['app/js/KeepMeContributing/*.js'],
        tasks: ['shell:buildDebug', 'notify:buildDebug'],
        options: { interrupt: true }
      },
      buildServer: {
        files: ['src/main/java/**/*.java'],
        tasks: ['shell:buildServer', 'notify:buildServer'],
        options: { interrupt: true }
      },
      buildServerTest: {
        files: ['src/main/java/**/*.java', 'src/test/java/**/*.java'],
        tasks: ['shell:buildServerTest', 'notify:buildServerTest'],
        options: { interrupt: true }
      }
    },
    notify: {
      buildDebug: {
        options: {
          title: 'buildDebug',
          message: 'Finished to build js/app.js.\nCheck the terminal to check for warnings.'
        }
      },
      buildServer: {
        options: {
          title: 'buildServer',
          message: 'Finished to build the server application.\nCheck the terminal to check for warnings.'
        }
      },
      buildServerTest: {
        options: {
          title: 'buildServerTest',
          message: 'Finished to build the tests of the server application.\nCheck the terminal to check for warnings.'
        }
      }
    }
  });

  grunt.registerTask('install', [
    'bower:install',
    'copy:closureLibrary'
  ]);
  grunt.registerTask('test', [
    'shell:buildDebug',
    'shell:testServer'
  ]);

  grunt.registerTask('default', [
    'shell:lint',
    'shell:buildDebug'
  ]);
};
<|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {
    // Time how long tasks take. Can help when optimizing build times
    require('time-grunt')(grunt);
	require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),

		express: {
			all: {
				options: {
					port: 9000,
					hostname: "0.0.0.0",
					bases: ['_site'],
					livereload: true,
				}
			}
		},
		shell: {
			jekyllBuild: {
				command: 'jekyll build'
			},
			jekyllServer: {
				command: 'jekyll server'
			},
			jekyllDeploy: {
				command: 'cp -a _site/. _deploy/'
			}
		},
		clean: {
			css: {
				src: [ 'css/*.css', '!css/style.min.css' ]
			},
			deploy: {
				src: [ '_deploy' ]
			}
		},
		sass: {
			jekyll: {
				files: {
					'css/style.css' : 'sass/style.scss'
				}
			}
		},
		cssmin: {
			minify: {
				expand: true,
				cwd: 'css/',
				src: ['*.css', '!*.min.css'],
				dest: 'css/',
				ext: '.min.css'
			}
		},
		watch: {
			css: {
				files: ['sass/**/*scss'],
				tasks: [
					'sass:jekyll',
					'cssmin',
					'clean:css',
					'shell:jekyllBuild',
				],
				options: {
					livereload: true
				}
			},
			jekyllSources: {
		        files: [
					'*.html',
					'*.yml',
					'assets/js/**.js',
					'_posts/**',
					'_includes/**'
		          ],
		        tasks: [
		        	'shell:jekyllBuild',
		        ],
		        options: {
		        	livereload: true
		        }
		      },
		},
		open: {
			all: {
				path: 'http://localhost:<%= express.all.options.port%>/index.html'
			}
		},
		sync: {
			deploy: {
				files: [{
					cwd: '_site',
					src: [ '**' ],
					dest: '_deploy',
				}],
				verbose: true
			}
		},
		changelog: {}
	});

	grunt.registerTask('default', [ 'watch' ]);

	grunt.registerTask('server', [
		'express',
		'open',
		'watch'
	]);

	grunt.registerTask('build', [
		'sass:jekyll',
		'cssmin',
		'clean:css',
		'shell:jekyllBuild'
	]);

	grunt.registerTask('deploy', [
		'sync:deploy',
		//'clean:deploy',
		//'shell:jekyllDeploy',
	]);

	grunt.registerTask('version', 'changelog');

}<commit_msg>updated gruntfile to watch .json and .js files in main dir with livereload<commit_after>'use strict';

module.exports = function(grunt) {
    // Time how long tasks take. Can help when optimizing build times
    require('time-grunt')(grunt);
	require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),

		express: {
			all: {
				options: {
					port: 9000,
					hostname: "0.0.0.0",
					bases: ['_site'],
					livereload: true,
				}
			}
		},
		shell: {
			jekyllBuild: {
				command: 'jekyll build'
			},
			jekyllServer: {
				command: 'jekyll server'
			},
			jekyllDeploy: {
				command: 'cp -a _site/. _deploy/'
			}
		},
		clean: {
			css: {
				src: [ 'css/*.css', '!css/style.min.css' ]
			},
			deploy: {
				src: [ '_deploy' ]
			}
		},
		sass: {
			jekyll: {
				files: {
					'css/style.css' : 'sass/style.scss'
				}
			}
		},
		cssmin: {
			minify: {
				expand: true,
				cwd: 'css/',
				src: ['*.css', '!*.min.css'],
				dest: 'css/',
				ext: '.min.css'
			}
		},
		watch: {
			css: {
				files: ['sass/**/*scss'],
				tasks: [
					'sass:jekyll',
					'cssmin',
					'clean:css',
					'shell:jekyllBuild',
				],
				options: {
					livereload: true
				}
			},
			jekyllSources: {
		        files: [
					'*.html',
					'*.yml',
					'*.md',
					'assets/js/**.js',
					'_posts/**',
					'_includes/**'
		          ],
		        tasks: [
		        	'shell:jekyllBuild',
		        ],
		        options: {
		        	livereload: true
		        }
		      },
		      config: {
		      	files: ['*.json', '*.js'],
		      	options: {
		      		livereload: true
		      	}
		      }
		},
		open: {
			all: {
				path: 'http://localhost:<%= express.all.options.port%>/index.html'
			}
		},
		sync: {
			deploy: {
				files: [{
					cwd: '_site',
					src: [ '**' ],
					dest: '_deploy',
				}],
				verbose: true
			}
		},
		changelog: {
			options: {
				repository: '<%= pkg.repository.url %>'
			}
		}
	});

	grunt.registerTask('default', [ 'watch' ]);

	grunt.registerTask('server', [
		'express',
		'open',
		'watch'
	]);

	grunt.registerTask('build', [
		'sass:jekyll',
		'cssmin',
		'clean:css',
		'shell:jekyllBuild'
	]);

	grunt.registerTask('deploy', [
		'sync:deploy',
		//'clean:deploy',
		//'shell:jekyllDeploy',
	]);

	grunt.registerTask('version', 'changelog');

}<|endoftext|>


<commit_before>var pkg = require('./package.json');
var version = pkg.version;
var forms = pkg.formsversion;
var now = new Date();

console.log(version, forms);

var uglifyConfig = {
  files: {}
};
uglifyConfig.files['dist/' + now.valueOf() + '/bic.min.js'] = ['dist/' + now.valueOf() + '/bic.js'];

module.exports = function (grunt) {
  "use strict";
  grunt.initConfig({

    concurrent: {
      background: ['hapi:http', 'watch'],
      options: {
        logConcurrentOutput: true
      }
    },

    hapi: {
      test: {
        options: {
          server: require('path').resolve('tests/support/server.js'),
          bases: {},
          noasync: false
        }
      },
      http: {
        options: {
          server: require('path').resolve('tests/support/server.js'),
          bases: {},
          noasync: true
        }
      }
    },

    watch: {
      src: {
        files: ['src/**', 'tests/**'],
        tasks: ['build-dev', 'eslint', 'mocha:tests']
      }
    },

    eslint: {
      target: [
          'src/**/*.js',
          'tests/**/*.js'
      ],
      options: {
        configFile: '.eslintrc'
      }
    },

    mocha: {
      tests: {
        options: {
          urls: [
            'http://localhost:9998/tests/index.html'
          ]
        }
      },
      options: {
        bail: true,
        log: true
      }
    },

    clean: ['build'],

    requirejs: {
      outside: {
        options: {
          baseUrl: 'src',
          name: 'feature',
          include: ['feature', 'pollUntil', 'BlinkGap'],
          exclude: ['implementations'],
          out: 'build/outside.js',
          optimize: "none",
          paths: {
            feature: '../node_modules/amd-feature/feature',
            pollUntil: '../node_modules/poll-until/poll-until',
            BlinkGap: '../node_modules/blinkgap-utils/BMP.BlinkGap'
          },
          shim: {
            BlinkGap: {
              deps: ['pollUntil'],
              exports: 'BMP.BlinkGap'
            }
          }
        }
      },
      compile: {
        options: {
          baseUrl: 'src',
          name: '../node_modules/almond/almond',
          include: ['main', 'router', 'auth', 'geolocation'],
          out: 'build/bic.js',
          optimize: "none",
          paths: {
            geolocation: '../node_modules/geolocation/geolocation',
            text: '../node_modules/text/text',
            domReady: '../node_modules/domReady/domReady',
            feature: '../node_modules/amd-feature/feature',
            'es5-shim': 'empty:',
            uuid: '../node_modules/node-uuid/uuid',
            authentication: '../node_modules/offlineLogin/authentication',
            sjcl: '../node_modules/sjcl/sjcl'
          },
          wrap: {
            startFile: [
              'src/frag/00-config.js',
              'src/frag/05-implementations.js',
              'build/outside.js',
              'src/frag/10-start.frag'
            ],
            endFile: 'src/frag/99-end.frag'
          }//,
          // wrap: true,
          //insertRequire: ["main"]
        }
      },
      options: {
        uglify: {
          max_line_length: 80
        },
        uglify2: {
          output: {
            max_line_len: 80
          },
          warnings: false
        }
      }
    },

    'saucelabs-mocha': {
      all: { options: require('./saucelabs') }
    },

    copy: {
      main: {
        files: [
          {
            src: 'build/bic.js',
            dest: 'dist/' + now.valueOf() + '/bic.js'
          },
          {
            src: 'src/buildFiles/files/*',
            dest: 'dist/' + now.valueOf() + '/',
            filter: 'isFile',
            expand: true,
            flatten: true
          }
        ]
      },
      dev: {
        files: [
          {
            src: 'build/bic.js',
            dest: 'tests/support/bic.js'
          }
        ]
      }
    },

    uglify: {
      bic: uglifyConfig,
      options: {
        sourceMap: true,
        sourceMapIncludeSources: true,
        preserveComments: 'some',
        beautify: {
          ascii_only: true,
          max_line_len: 80
        },
        compress: {
          screw_ie8: false,
          properties: false
        },
        mangle: {
          screw_ie8: false
        }
      }
    },

    mustache_render: {
      versions: {
        files : [
          {
            template: 'src/buildFiles/templates/versions.json',
            dest: 'dist/' + now.valueOf() + '/versions.json',
            data: {
              timestamp: now.valueOf(),
              datestamp: now.toISOString(),
              version: version
            }
          },
          {
            template: 'src/buildFiles/templates/appcache.mustache',
            dest: 'dist/' + now.valueOf() + '/appcache.mustache',
            data: {
              forms: forms
            }
          },
        ]
      }
    },

    replace: {
      bicVersion: {
        src: [
          'src/model-application.js'
        ],
        overwrite: true,
        replacements: [
          {
            from: /window\.BMP\.BIC3\.version = '.+?'/,
            to: 'window.BMP.BIC3.version = \'' + version + '\''
          }
        ]
      },
      formsVersion: {
        src: [
          'src/frag/00-config.js'
        ],
        overwrite: true,
        replacements: [
          {
            from: /blink\/forms\/3\/.*\/forms3jqm\.min/,
            to: 'blink/forms/3/' + forms + '/forms3jqm.min'
          }
        ]
      }
    }

  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-eslint');
  grunt.loadNpmTasks('grunt-mocha');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-concurrent');
  grunt.loadNpmTasks('grunt-saucelabs');
  grunt.loadNpmTasks('grunt-hapi');
  grunt.loadNpmTasks('grunt-mustache-render');
  grunt.loadNpmTasks('grunt-text-replace');

  grunt.registerTask('test', ['build', 'eslint', 'hapi:test', 'mocha']);
  grunt.registerTask('travis', ['test', 'saucelabs-mocha']);

  grunt.registerTask('build', ['clean', 'replace', 'requirejs', 'copy:main', 'clean', 'uglify', 'mustache_render']);
  grunt.registerTask('build-dev', ['clean', 'requirejs', 'copy:dev', 'clean']);
  grunt.registerTask('develop', ['concurrent']);
  grunt.registerTask('default', ['test']);

};
<commit_msg>ESLint: fix linting issues<commit_after>/*eslint-env node*/
'use strict';
var pkg = require('./package.json');
var version = pkg.version;
var forms = pkg.formsversion;
var now = new Date();

var uglifyConfig = {
  files: {}
};

console.log(version, forms);

uglifyConfig.files['dist/' + now.valueOf() + '/bic.min.js'] = ['dist/' + now.valueOf() + '/bic.js'];

module.exports = function (grunt) {
  grunt.initConfig({

    concurrent: {
      background: ['hapi:http', 'watch'],
      options: {
        logConcurrentOutput: true
      }
    },

    hapi: {
      test: {
        options: {
          server: require('path').resolve('tests/support/server.js'),
          bases: {},
          noasync: false
        }
      },
      http: {
        options: {
          server: require('path').resolve('tests/support/server.js'),
          bases: {},
          noasync: true
        }
      }
    },

    watch: {
      src: {
        files: ['src/**', 'tests/**'],
        tasks: ['build-dev', 'eslint', 'mocha:tests']
      }
    },

    eslint: {
      target: [
          'src/**/*.js',
          'tests/**/*.js'
      ],
      options: {
        configFile: '.eslintrc'
      }
    },

    mocha: {
      tests: {
        options: {
          urls: [
            'http://localhost:9998/tests/index.html'
          ]
        }
      },
      options: {
        bail: true,
        log: true
      }
    },

    clean: ['build'],

    requirejs: {
      outside: {
        options: {
          baseUrl: 'src',
          name: 'feature',
          include: ['feature', 'pollUntil', 'BlinkGap'],
          exclude: ['implementations'],
          out: 'build/outside.js',
          optimize: "none",
          paths: {
            feature: '../node_modules/amd-feature/feature',
            pollUntil: '../node_modules/poll-until/poll-until',
            BlinkGap: '../node_modules/blinkgap-utils/BMP.BlinkGap'
          },
          shim: {
            BlinkGap: {
              deps: ['pollUntil'],
              exports: 'BMP.BlinkGap'
            }
          }
        }
      },
      compile: {
        options: {
          baseUrl: 'src',
          name: '../node_modules/almond/almond',
          include: ['main', 'router', 'auth', 'geolocation'],
          out: 'build/bic.js',
          optimize: "none",
          paths: {
            geolocation: '../node_modules/geolocation/geolocation',
            text: '../node_modules/text/text',
            domReady: '../node_modules/domReady/domReady',
            feature: '../node_modules/amd-feature/feature',
            'es5-shim': 'empty:',
            uuid: '../node_modules/node-uuid/uuid',
            authentication: '../node_modules/offlineLogin/authentication',
            sjcl: '../node_modules/sjcl/sjcl'
          },
          wrap: {
            startFile: [
              'src/frag/00-config.js',
              'src/frag/05-implementations.js',
              'build/outside.js',
              'src/frag/10-start.frag'
            ],
            endFile: 'src/frag/99-end.frag'
          }//,
          // wrap: true,
          //insertRequire: ["main"]
        }
      },
      options: {
        uglify: {
          'max_line_length': 80
        },
        uglify2: {
          output: {
            'max_line_len': 80
          },
          warnings: false
        }
      }
    },

    'saucelabs-mocha': {
      all: { options: require('./saucelabs') }
    },

    copy: {
      main: {
        files: [
          {
            src: 'build/bic.js',
            dest: 'dist/' + now.valueOf() + '/bic.js'
          },
          {
            src: 'src/buildFiles/files/*',
            dest: 'dist/' + now.valueOf() + '/',
            filter: 'isFile',
            expand: true,
            flatten: true
          }
        ]
      },
      dev: {
        files: [
          {
            src: 'build/bic.js',
            dest: 'tests/support/bic.js'
          }
        ]
      }
    },

    uglify: {
      bic: uglifyConfig,
      options: {
        sourceMap: true,
        sourceMapIncludeSources: true,
        preserveComments: 'some',
        beautify: {
          'ascii_only': true,
          'max_line_len': 80
        },
        compress: {
          'screw_ie8': false,
          properties: false
        },
        mangle: {
          'screw_ie8': false
        }
      }
    },

    'mustache_render': {
      versions: {
        files: [
          {
            template: 'src/buildFiles/templates/versions.json',
            dest: 'dist/' + now.valueOf() + '/versions.json',
            data: {
              timestamp: now.valueOf(),
              datestamp: now.toISOString(),
              version: version
            }
          },
          {
            template: 'src/buildFiles/templates/appcache.mustache',
            dest: 'dist/' + now.valueOf() + '/appcache.mustache',
            data: {
              forms: forms
            }
          }
        ]
      }
    },

    replace: {
      bicVersion: {
        src: [
          'src/model-application.js'
        ],
        overwrite: true,
        replacements: [
          {
            from: /window\.BMP\.BIC3\.version = '.+?'/,
            to: 'window.BMP.BIC3.version = \'' + version + '\''
          }
        ]
      },
      formsVersion: {
        src: [
          'src/frag/00-config.js'
        ],
        overwrite: true,
        replacements: [
          {
            from: /blink\/forms\/3\/.*\/forms3jqm\.min/,
            to: 'blink/forms/3/' + forms + '/forms3jqm.min'
          }
        ]
      }
    }

  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-eslint');
  grunt.loadNpmTasks('grunt-mocha');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-concurrent');
  grunt.loadNpmTasks('grunt-saucelabs');
  grunt.loadNpmTasks('grunt-hapi');
  grunt.loadNpmTasks('grunt-mustache-render');
  grunt.loadNpmTasks('grunt-text-replace');

  grunt.registerTask('test', ['build', 'eslint', 'hapi:test', 'mocha']);
  grunt.registerTask('travis', ['test', 'saucelabs-mocha']);

  grunt.registerTask('build', ['clean', 'replace', 'requirejs', 'copy:main', 'clean', 'uglify', 'mustache_render']);
  grunt.registerTask('build-dev', ['clean', 'requirejs', 'copy:dev', 'clean']);
  grunt.registerTask('develop', ['concurrent']);
  grunt.registerTask('default', ['test']);

};
<|endoftext|>


<commit_before>'use strict';
var fs = require('fs');
var spawn = require('child_process').spawn;
var test = require('ava');
var imageSize = require('image-size');
var concat = require('concat-stream');
var date = require('easydate');
var PNG = require('png-js');
var Pageres = require('../');
var Server = require('./serverForCookieTests');

process.chdir(__dirname);

test('expose a constructor', function (t) {
	t.plan(1);
	t.assert(typeof Pageres === 'function');
});

test('add a source', function (t) {
	t.plan(1);

	var pageres = new Pageres()
		.src('yeoman.io', ['1280x1024', '1920x1080']);

	t.assert(pageres._src[0].url === 'yeoman.io');
});

test('set destination directory', function (t) {
	t.plan(1);

	var pageres = new Pageres()
		.dest('tmp');

	t.assert(pageres._dest === 'tmp');
});

test('generate screenshots', function (t) {
	t.plan(5);

	var pageres = new Pageres()
		.src('yeoman.io', ['480x320', '1024x768', 'iphone 5s'])
		.src('todomvc.com', ['1280x1024', '1920x1080']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams.length === 5);
		t.assert(streams[0].filename === 'todomvc.com-1280x1024.png');
		t.assert(streams[4].filename === 'yeoman.io-320x568.png');

		streams[0].once('data', function (data) {
			t.assert(data.length > 1000);
		});
	});
});

test('remove special characters from the URL to create a valid filename', function (t) {
	t.plan(3);

	var pageres = new Pageres()
		.src('http://www.microsoft.com/?query=pageres*|<>:"\\', ['1024x768']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams.length === 1);
		t.assert(streams[0].filename === 'microsoft.com!query=pageres-1024x768.png');
	});
});

test('have a `delay` option', function (t) {
	t.plan(2);

	var pageres = new Pageres({ delay: 2 })
		.src('http://todomvc.com', ['1024x768']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);

		var now = new Date();

		streams[0].once('data', function () {
			t.assert((new Date()) - now > 2000);
		});
	});
});

test('crop image using the `crop` option', function (t) {
	t.plan(4);

	var pageres = new Pageres({ crop: true })
		.src('http://todomvc.com', ['1024x768']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams[0].filename === 'todomvc.com-1024x768-cropped.png');

		streams[0].pipe(concat(function (data) {
			var size = imageSize(data);
			t.assert(size.width === 1024);
			t.assert(size.height === 768);
		}));
	});
});

test('rename image using the `name` option', function (t) {
	t.plan(3);

	var pageres = new Pageres()
		.src('http://todomvc.com', ['1024x768'], { name: '<%= date %> - <%= url %>' });

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams.length === 1);
		t.assert(streams[0].filename === date('Y-M-d') + ' - todomvc.com.png');
	});
});

test('capture a DOM element using the `selector` option', function (t) {
	t.plan(5);

	var pageres = new Pageres({ selector: '.page-header' })
		.src('http://yeoman.io', ['1024x768']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams[0].filename === 'yeoman.io-1024x768.png');

		streams[0].pipe(concat(function (data) {
			var size = imageSize(data);
			t.assert(size.width === 1024);
			t.assert(size.height === 80);
			t.assert(data.length > 10000);
		}));
	});
});

test('support local relative files', function (t) {
	t.plan(3);

	var pageres = new Pageres()
		.src('fixture.html', ['1024x768']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams[0].filename === 'fixture.html-1024x768.png');

		streams[0].once('data', function (data) {
			t.assert(data.length > 1000);
		});
	});
});

test('fetch resolutions from w3counter', function (t) {
	t.plan(3);

	var pageres = new Pageres()
		.src('yeoman.io', ['w3counter']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams.length === 10);

		streams[0].once('data', function (data) {
			t.assert(data.length > 1000);
		});
	});
});

test('save image', function (t) {
	t.plan(3);

	var pageres = new Pageres()
		.src('http://todomvc.com', ['1024x768'])
		.dest(__dirname);

	pageres.run(function (err) {
		t.assert(!err, err);
		t.assert(fs.existsSync('todomvc.com-1024x768.png'));

		fs.unlink('todomvc.com-1024x768.png', function (err) {
			t.assert(!err);
		});
	});
});

test('generate screenshot using the CLI', function (t) {
	t.plan(2);

	spawn('../cli.js', ['yeoman.io', '320x240'], {stdio:'inherit'})
		.on('close', function () {
			t.assert(fs.existsSync('yeoman.io-320x240.png'));

			fs.unlink('yeoman.io-320x240.png', function (err) {
				t.assert(!err);
			});
		});
});

function cookieTest (port, input, t) {
	t.plan(6);
	var server = new Server(port);
	var filename = 'localhost!' + port + '-320x480.png';

	var pageres = new Pageres({cookies: [input]})
		.src('http://localhost:' + port, ['320x480'])
		.dest(__dirname);

	pageres.run(function(err) {
		server.close();

		t.assert(!err, err);
		t.assert(fs.existsSync(filename));

		PNG.decode(filename, function(pixels) {
			fs.unlinkSync(filename);
			t.assert(pixels[0] === 0);
			t.assert(pixels[1] === 0);
			t.assert(pixels[2] === 0);
			t.assert(pixels[3] === 255);
		});
	});
}

test('send cookie', cookieTest.bind(null, 5000, 'pageresColor=black; Path=/; Domain=localhost'));

test('send cookie using an object', cookieTest.bind(null, 5001, {
	name: 'pageresColor',
	value: 'black',
	domain: 'localhost'
}));
<commit_msg>Cookie tests shouldn't write to disk<commit_after>'use strict';
var fs = require('fs');
var spawn = require('child_process').spawn;
var test = require('ava');
var imageSize = require('image-size');
var concat = require('concat-stream');
var date = require('easydate');
var PNG = require('png-js');
var Pageres = require('../');
var Server = require('./serverForCookieTests');

process.chdir(__dirname);

test('expose a constructor', function (t) {
	t.plan(1);
	t.assert(typeof Pageres === 'function');
});

test('add a source', function (t) {
	t.plan(1);

	var pageres = new Pageres()
		.src('yeoman.io', ['1280x1024', '1920x1080']);

	t.assert(pageres._src[0].url === 'yeoman.io');
});

test('set destination directory', function (t) {
	t.plan(1);

	var pageres = new Pageres()
		.dest('tmp');

	t.assert(pageres._dest === 'tmp');
});

test('generate screenshots', function (t) {
	t.plan(5);

	var pageres = new Pageres()
		.src('yeoman.io', ['480x320', '1024x768', 'iphone 5s'])
		.src('todomvc.com', ['1280x1024', '1920x1080']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams.length === 5);
		t.assert(streams[0].filename === 'todomvc.com-1280x1024.png');
		t.assert(streams[4].filename === 'yeoman.io-320x568.png');

		streams[0].once('data', function (data) {
			t.assert(data.length > 1000);
		});
	});
});

test('remove special characters from the URL to create a valid filename', function (t) {
	t.plan(3);

	var pageres = new Pageres()
		.src('http://www.microsoft.com/?query=pageres*|<>:"\\', ['1024x768']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams.length === 1);
		t.assert(streams[0].filename === 'microsoft.com!query=pageres-1024x768.png');
	});
});

test('have a `delay` option', function (t) {
	t.plan(2);

	var pageres = new Pageres({ delay: 2 })
		.src('http://todomvc.com', ['1024x768']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);

		var now = new Date();

		streams[0].once('data', function () {
			t.assert((new Date()) - now > 2000);
		});
	});
});

test('crop image using the `crop` option', function (t) {
	t.plan(4);

	var pageres = new Pageres({ crop: true })
		.src('http://todomvc.com', ['1024x768']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams[0].filename === 'todomvc.com-1024x768-cropped.png');

		streams[0].pipe(concat(function (data) {
			var size = imageSize(data);
			t.assert(size.width === 1024);
			t.assert(size.height === 768);
		}));
	});
});

test('rename image using the `name` option', function (t) {
	t.plan(3);

	var pageres = new Pageres()
		.src('http://todomvc.com', ['1024x768'], { name: '<%= date %> - <%= url %>' });

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams.length === 1);
		t.assert(streams[0].filename === date('Y-M-d') + ' - todomvc.com.png');
	});
});

test('capture a DOM element using the `selector` option', function (t) {
	t.plan(5);

	var pageres = new Pageres({ selector: '.page-header' })
		.src('http://yeoman.io', ['1024x768']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams[0].filename === 'yeoman.io-1024x768.png');

		streams[0].pipe(concat(function (data) {
			var size = imageSize(data);
			t.assert(size.width === 1024);
			t.assert(size.height === 80);
			t.assert(data.length > 10000);
		}));
	});
});

test('support local relative files', function (t) {
	t.plan(3);

	var pageres = new Pageres()
		.src('fixture.html', ['1024x768']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams[0].filename === 'fixture.html-1024x768.png');

		streams[0].once('data', function (data) {
			t.assert(data.length > 1000);
		});
	});
});

test('fetch resolutions from w3counter', function (t) {
	t.plan(3);

	var pageres = new Pageres()
		.src('yeoman.io', ['w3counter']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams.length === 10);

		streams[0].once('data', function (data) {
			t.assert(data.length > 1000);
		});
	});
});

test('save image', function (t) {
	t.plan(3);

	var pageres = new Pageres()
		.src('http://todomvc.com', ['1024x768'])
		.dest(__dirname);

	pageres.run(function (err) {
		t.assert(!err, err);
		t.assert(fs.existsSync('todomvc.com-1024x768.png'));

		fs.unlink('todomvc.com-1024x768.png', function (err) {
			t.assert(!err);
		});
	});
});

test('generate screenshot using the CLI', function (t) {
	t.plan(2);

	spawn('../cli.js', ['yeoman.io', '320x240'], {stdio:'inherit'})
		.on('close', function () {
			t.assert(fs.existsSync('yeoman.io-320x240.png'));

			fs.unlink('yeoman.io-320x240.png', function (err) {
				t.assert(!err);
			});
		});
});

function cookieTest (port, input, t) {
	t.plan(6);
	var server = new Server(port);
	var filename = 'localhost!' + port + '-320x480.png';

	var pageres = new Pageres({cookies: [input]})
		.src('http://localhost:' + port, ['320x480']);

	pageres.run(function (err, streams) {
		t.assert(!err, err);
		t.assert(streams[0].filename === filename);

		streams[0].pipe(concat(function (data) {
			server.close();
			var png = new PNG(data);
			png.decode(function (pixels) {
				t.assert(pixels[0] === 0);
				t.assert(pixels[1] === 0);
				t.assert(pixels[2] === 0);
				t.assert(pixels[3] === 255);
			});
		}));
	});
}

test('send cookie', cookieTest.bind(null, 5000, 'pageresColor=black; Path=/; Domain=localhost'));

test('send cookie using an object', cookieTest.bind(null, 5001, {
	name: 'pageresColor',
	value: 'black',
	domain: 'localhost'
}));
<|endoftext|>


<commit_before>const app = require('./server-config.js');
const port = process.env.PORT || 8080;
const redis = require('redis');
const bluebird = require('bluebird');
bluebird.promisifyAll(redis.RedisClient.prototype);

const redisClient = redis.createClient();

const server = app.listen(port);

console.log('Server now listening on port ' + port);

module.exports = {'server': server,
									'redis': redisClient}<commit_msg>(feat) crossed out redis.createClient prior to int<commit_after>const app = require('./server-config.js');
const port = process.env.PORT || 8080;
const redis = require('redis');
const bluebird = require('bluebird');
bluebird.promisifyAll(redis.RedisClient.prototype);

const redisCl = null;
//UNCOMMENT to run/////////////////////////
// = redis.createClient();

const server = app.listen(port);

console.log('Server now listening on port ' + port);

module.exports = {'server': server,
									'redis': redisCl}<|endoftext|>