<commit_before>var api = require('../api');

api.setPackagePath('testlibs');

suite('API Calls', function() {
  test('Normalize', function(done) {
    api.normalize('jquery').then(function(normalized) {
      assert(normalized === 'github:components/jquery@2.1.3');
      done();
    }, done);
  });

  test('Import', function(done) {
    api.dlLoader()
    .then(function() {
      return api.install('text', '^0.0.2');
    })
    .then(function() {
      api.import('text').then(function(text) {
        assert(text.translate);
        done();
      }, done);
    }, done);
  });
});
<commit_msg>test fixes<commit_after>var api = require('../api');

api.setPackagePath('testlibs');

suite('API Calls', function() {
  test('Normalize', function(done) {
    api.normalize('jquery').then(function(normalized) {
      assert(normalized === System.baseURL + 'jspm_packages/github/components/jquery@2.1.3.js');
      done();
    })
    .catch(done);
  });

  test('Import', function(done) {
    api.dlLoader()
    .then(function() {
      return api.install('text', '^0.0.2');
    })
    .then(function() {
      return api.import('text').then(function(text) {
        assert(text.translate);
        done();
      });
    })
    .catch(done);
  });
});
<|endoftext|>


<commit_before>'use strict';

var path = require('path');
var assert = require('yeoman-generator').assert;
var helpers = require('yeoman-generator').test;
var exec = require('child_process').exec;
var chaiAssert = require('chai').assert;
var utils = require('../util');

function basicFileCheck () {
  assert.file([
    'gulpfile.js',
    'bower.json',
    'package.json',
    'server/routes.js',
    'server/server.js',
    'server/config/express.js',
    'server/config/environment/index.js',
    'server/config/environment/development.js',
    'server/config/environment/production.js',
    'server/config/environment/test.js',
    'client/index.html',
    'client/app.js',
    'client/assets/favicon.ico',
    'client/styles/app.scss',
    'client/views/home/home.controller.js',
    'client/views/home/home.html',
    'client/views/home/home.js',
    'README.md',
    '.editorconfig',
    '.gitignore'
  ]);
}

describe('Launching app generator tests', function () {

  describe('', function () {

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'mongo',
        modules: [],
        sockets: false
      }, done);

    });

    it('should creates all the files', basicFileCheck);

    it('should check name in some files', function () {
      assert.fileContent('README.md', '# test');
      assert.fileContent('client/index.html', 'ng-app="test"');
      assert.fileContent('client/app.js', 'angular.module(\'test\'');
    });

    it('should have mongo dependency', function () {
      assert.fileContent('package.json', 'mongoose');
    });

    it('should have mongo connect', function () {
      assert.fileContent('server/server.js', 'mongoose.connect(config.mongo.uri, config.mongo.options);');
    });

    it('should not have request dependency', function () {
      assert.noFileContent('package.json', 'request');
    });

    it('should not have tests files', function () {
      assert.noFile([
        '.jscsrc',
        '.jshintrc',
        'server/.jshintrc',
        'client/.jshintrc',
        'client/views/login/login.spec.js',
        'client/views/login/login.e2e.js',
        'client/views/signup/signup.spec.js',
        'client/views/signup/signup.e2e.js',
        'client/views/home/home.spec.js',
        'client/views/home/home.e2e.js',
        'karma.conf.js',
        'protractor.conf.js'
      ]);
    });

    it('should not have the tests dependencies', function () {
      assert.noFileContent('package.json', 'mocha');
      assert.noFileContent('package.json', 'karma');
      assert.noFileContent('package.json', 'phantomjs');
      assert.noFileContent('package.json', 'jasmine');
      assert.noFileContent('package.json', 'protractor');
      assert.noFileContent('package.json', 'should');
      assert.noFileContent('package.json', 'supertest');
      assert.noFileContent('package.json', 'jscs');
      assert.noFileContent('package.json', 'jshint');
    });

    it('should not have the tests gulp tasks', function () {
      assert.noFileContent('gulpfile.js', 'gulp.task(\'test\'');
      assert.noFileContent('gulpfile.js', 'gulp.task(\'control\'');
      assert.noFileContent('gulpfile.js', 'gulp.task(\'e2e\'');
      assert.noFileContent('gulpfile.js', 'gulp.task(\'e2e:update\'');
    });
  });

  describe('', function () {

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'mongo',
        modules: [],
        sockets: false,
        auth: true,
        tests: ['e2e', 'control', 'karma', 'mocha']
      }, done);

    });

    it('should creates all the files', basicFileCheck);

    it('should create the tests files', function () {
      assert.file([
        '.jscsrc',
        '.jshintrc',
        'server/.jshintrc',
        'client/.jshintrc',
        'client/views/login/login.spec.js',
        'client/views/login/login.e2e.js',
        'client/views/signup/signup.spec.js',
        'client/views/signup/signup.e2e.js',
        'client/views/home/home.spec.js',
        'client/views/home/home.e2e.js',
        'karma.conf.js',
        'protractor.conf.js'
      ]);
    });

    it('should check the package tests dependencies', function () {
      assert.fileContent('package.json', 'mocha');
      assert.fileContent('package.json', 'karma');
      assert.fileContent('package.json', 'phantomjs');
      assert.fileContent('package.json', 'jasmine');
      assert.fileContent('package.json', 'protractor');
      assert.fileContent('package.json', 'should');
      assert.fileContent('package.json', 'supertest');
      assert.fileContent('package.json', 'jscs');
      assert.fileContent('package.json', 'jshint');
    });

    it('should check the gulp tasks', function () {
      assert.fileContent('gulpfile.js', 'gulp.task(\'test\'');
      assert.fileContent('gulpfile.js', 'gulp.task(\'control\'');
      assert.fileContent('gulpfile.js', 'gulp.task(\'e2e\'');
      assert.fileContent('gulpfile.js', 'gulp.task(\'e2e:update\'');
    });

  });

  describe('', function () {

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'restock',
        modules: ['ngCookies', 'ngSanitize']
      }, done);

    });

    it('should create all the files', basicFileCheck);

    it('should have request dependency', function () {
      assert.fileContent('package.json', 'request');
    });

    it('should not have mongo dependency', function () {
      assert.noFileContent('package.json', 'mongoose');
    });

    it('should not have mongo connect', function () {
      assert.noFileContent('server/server.js', 'mongoose.connect(config.mongo.uri, config.mongo.options);');
    });

    it('should have loaded client dependencies', function () {
      assert.file('bower.json');
      assert.fileContent('bower.json', '"angular-cookies":');
      assert.fileContent('bower.json', '"angular-sanitize":');
    });

  });

  describe('', function () {

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'mongo',
        modules: [],
        sockets: true
      }, done);

    });

    it('should have socket dependency, config and requires', function () {
      assert.fileContent('package.json', '"socket.io":');
      assert.fileContent('bower.json', '"angular-socket-io":');
      assert.fileContent('client/index.html', 'socket.io/socket.io.js');
      assert.fileContent('client/app.js', 'btford.socket-io');
      assert.file('server/config/sockets.js');
      assert.fileContent('server/server.js', 'var socket = require(\'socket.io\')');
      assert.fileContent('server/server.js', 'require(\'./config/sockets.js\')(socket);');
    });

  });

  describe('', function () {

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'json',
        modules: ['ngResource', 'ngAnimate']
      }, done);

    });

    it('should create all the files', basicFileCheck);

    it('should not have request dependency', function () {
      assert.noFileContent('package.json', 'request');
    });

    it('should not have mongo dependency', function () {
      assert.noFileContent('package.json', 'mongoose');
    });

    it('should not have mongo connect', function () {
      assert.noFileContent('server/server.js', 'mongoose.connect(config.mongo.uri, config.mongo.options);');
    });

    it('should have loaded client dependencies', function () {
      assert.file('bower.json');
      assert.fileContent('bower.json', '"angular-resource":');
      assert.fileContent('bower.json', '"angular-animate":');
    });
  });

  describe('', function () {

    var bangDir = process.cwd();

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'json',
        modules: []
      }, done);

    });

    it('should test a generation in an already generated directory', function (done) {

      var tmpBang = helpers.createGenerator('bangular', [bangDir + '/app'], false, { skipInstall: true });

      helpers.mockPrompt(tmpBang, { skipConfig: true });
      tmpBang.conflicter.force = true;
      tmpBang.run(done);

    });

  });

  describe('', function () {

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'mongo',
        modules: [],
        sockets: true,
        auth: true
      }, done);

    });

    it('should test for auth files', function () {

      assert.file([
        'client/views/signup/signup.controller.js',
        'client/views/signup/signup.html',
        'client/views/signup/signup.js',
        'client/views/login/login.controller.js',
        'client/views/login/login.html',
        'client/views/login/login.js',
        'client/services/auth',
        'server/auth'
      ]);

      assert.fileContent('server/routes.js', 'app.use(\'/auth\', require(\'./auth\'));');
      assert.fileContent('server/config/express.js', 'express-session');
      assert.fileContent('server/config/express.js', 'app.use(session({');
      assert.fileContent('package.json', 'passport');
      assert.fileContent('package.json', 'passport-local');
      assert.fileContent('package.json', 'connect-mongo');

      assert.fileContent('client/index.html', 'nav-bar');
      assert.fileContent('bower.json', 'angular-cookies');
    });
  });

  describe('', function () {

    before(function (done) {

      this.timeout(240000);
      var dir;

      helpers.run(path.join(__dirname, '../app'))
        .inDir(path.join(__dirname, './mock'), function (d) {
          dir = d;
          var cb = this.async();
          exec('cp ' + path.join(__dirname, '/files/.yo-rc.json') + ' ' + dir, function () {
            cb();
          });
        })
        .withPrompt({
          name: 'Test',
          backend: 'mongo',
          modules: [],
          sockets: true,
          auth: true,
          tests: ['e2e', 'karma', 'mocha', 'control']
        })
        .on('end', function () {
          exec('cp ' + path.join(__dirname, '/files/protractor.conf.js') + ' ' + dir, done);
        });
    });

    it('should successfully pass the gulp control command', function (done) {
      this.timeout(30000);
      exec('gulp control', function (err, stdout) {
        chaiAssert.include(stdout, ' Starting \'control\'...\n[', 'Start should not be followed by newlines.');
        chaiAssert.notInclude(stdout, 'Task \'control\' is not in your gulpfile');
        done();
      });
    });

    it('should successfully pass the server tests', function (done) {
      this.timeout(30000);
      exec('gulp test --server', function (err, stdout) {
        chaiAssert.notMatch(stdout, /((?=.*[1-9])\d+(\.\d+)?) failing\n/, 'Output should not have failing tests.');
        chaiAssert.notInclude(stdout, 'Task \'test\' is not in your gulpfile');
        done();
      });
    });

    it('should successfully pass the karma tests', function (done) {
      this.timeout(30000);
      exec('gulp test --client', function (err, stdout) {
        chaiAssert.notMatch(stdout, /\(((?=.*[1-9])\d+(\.\d+)?) FAILED\)/, 'Output should not contain failed tests.');
        chaiAssert.notInclude(stdout, 'Task \'test\' is not in your gulpfile');
        done();
      });
    });

    it('should build the app and check some files', function (done) {
      this.timeout(70000);
      exec('gulp build', function (err) {

        assert.file([
          'dist/package.json',
          'dist/server/server.js',
          'dist/server/routes.js',
          'dist/client/index.html'
        ]);

        assert.noFileContent('dist/client/index.html', 'livereload');
        done(err);
      });
    });

    it('should update the webdriver and pass e2e tests', function (done) {
      this.timeout(70000);
      exec('gulp e2e:update', function (err, stdout) {
        chaiAssert.notInclude(stdout, 'Task \'e2e:update\' is not in your gulpfile');
        exec('gulp e2e', { timeout: 30000 }, function (err, stdout) {
          chaiAssert.include(stdout, '3 tests, 3 assertions, 0 failures');
          chaiAssert.notMatch(stdout, /\(((?=.*[1-9])\d+(\.\d+)?) failures\)/, 'Output should not contain failed tests.');
          done();
        });
      });
    });

    after(function (done) {
      exec('cd .. && rm -rf ./mock', function () {
        done();
      });
    });

  });

});
<commit_msg>chore(tests): reverting timeouts commit for strange reasons<commit_after>'use strict';

var path = require('path');
var assert = require('yeoman-generator').assert;
var helpers = require('yeoman-generator').test;
var exec = require('child_process').exec;
var chaiAssert = require('chai').assert;
var utils = require('../util');

function basicFileCheck () {
  assert.file([
    'gulpfile.js',
    'bower.json',
    'package.json',
    'server/routes.js',
    'server/server.js',
    'server/config/express.js',
    'server/config/environment/index.js',
    'server/config/environment/development.js',
    'server/config/environment/production.js',
    'server/config/environment/test.js',
    'client/index.html',
    'client/app.js',
    'client/assets/favicon.ico',
    'client/styles/app.scss',
    'client/views/home/home.controller.js',
    'client/views/home/home.html',
    'client/views/home/home.js',
    'README.md',
    '.editorconfig',
    '.gitignore'
  ]);
}

describe('Launching app generator tests', function () {

  describe('', function () {

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'mongo',
        modules: [],
        sockets: false
      }, done);

    });

    it('should creates all the files', basicFileCheck);

    it('should check name in some files', function () {
      assert.fileContent('README.md', '# test');
      assert.fileContent('client/index.html', 'ng-app="test"');
      assert.fileContent('client/app.js', 'angular.module(\'test\'');
    });

    it('should have mongo dependency', function () {
      assert.fileContent('package.json', 'mongoose');
    });

    it('should have mongo connect', function () {
      assert.fileContent('server/server.js', 'mongoose.connect(config.mongo.uri, config.mongo.options);');
    });

    it('should not have request dependency', function () {
      assert.noFileContent('package.json', 'request');
    });

    it('should not have tests files', function () {
      assert.noFile([
        '.jscsrc',
        '.jshintrc',
        'server/.jshintrc',
        'client/.jshintrc',
        'client/views/login/login.spec.js',
        'client/views/login/login.e2e.js',
        'client/views/signup/signup.spec.js',
        'client/views/signup/signup.e2e.js',
        'client/views/home/home.spec.js',
        'client/views/home/home.e2e.js',
        'karma.conf.js',
        'protractor.conf.js'
      ]);
    });

    it('should not have the tests dependencies', function () {
      assert.noFileContent('package.json', 'mocha');
      assert.noFileContent('package.json', 'karma');
      assert.noFileContent('package.json', 'phantomjs');
      assert.noFileContent('package.json', 'jasmine');
      assert.noFileContent('package.json', 'protractor');
      assert.noFileContent('package.json', 'should');
      assert.noFileContent('package.json', 'supertest');
      assert.noFileContent('package.json', 'jscs');
      assert.noFileContent('package.json', 'jshint');
    });

    it('should not have the tests gulp tasks', function () {
      assert.noFileContent('gulpfile.js', 'gulp.task(\'test\'');
      assert.noFileContent('gulpfile.js', 'gulp.task(\'control\'');
      assert.noFileContent('gulpfile.js', 'gulp.task(\'e2e\'');
      assert.noFileContent('gulpfile.js', 'gulp.task(\'e2e:update\'');
    });
  });

  describe('', function () {

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'mongo',
        modules: [],
        sockets: false,
        auth: true,
        tests: ['e2e', 'control', 'karma', 'mocha']
      }, done);

    });

    it('should creates all the files', basicFileCheck);

    it('should create the tests files', function () {
      assert.file([
        '.jscsrc',
        '.jshintrc',
        'server/.jshintrc',
        'client/.jshintrc',
        'client/views/login/login.spec.js',
        'client/views/login/login.e2e.js',
        'client/views/signup/signup.spec.js',
        'client/views/signup/signup.e2e.js',
        'client/views/home/home.spec.js',
        'client/views/home/home.e2e.js',
        'karma.conf.js',
        'protractor.conf.js'
      ]);
    });

    it('should check the package tests dependencies', function () {
      assert.fileContent('package.json', 'mocha');
      assert.fileContent('package.json', 'karma');
      assert.fileContent('package.json', 'phantomjs');
      assert.fileContent('package.json', 'jasmine');
      assert.fileContent('package.json', 'protractor');
      assert.fileContent('package.json', 'should');
      assert.fileContent('package.json', 'supertest');
      assert.fileContent('package.json', 'jscs');
      assert.fileContent('package.json', 'jshint');
    });

    it('should check the gulp tasks', function () {
      assert.fileContent('gulpfile.js', 'gulp.task(\'test\'');
      assert.fileContent('gulpfile.js', 'gulp.task(\'control\'');
      assert.fileContent('gulpfile.js', 'gulp.task(\'e2e\'');
      assert.fileContent('gulpfile.js', 'gulp.task(\'e2e:update\'');
    });

  });

  describe('', function () {

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'restock',
        modules: ['ngCookies', 'ngSanitize']
      }, done);

    });

    it('should create all the files', basicFileCheck);

    it('should have request dependency', function () {
      assert.fileContent('package.json', 'request');
    });

    it('should not have mongo dependency', function () {
      assert.noFileContent('package.json', 'mongoose');
    });

    it('should not have mongo connect', function () {
      assert.noFileContent('server/server.js', 'mongoose.connect(config.mongo.uri, config.mongo.options);');
    });

    it('should have loaded client dependencies', function () {
      assert.file('bower.json');
      assert.fileContent('bower.json', '"angular-cookies":');
      assert.fileContent('bower.json', '"angular-sanitize":');
    });

  });

  describe('', function () {

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'mongo',
        modules: [],
        sockets: true
      }, done);

    });

    it('should have socket dependency, config and requires', function () {
      assert.fileContent('package.json', '"socket.io":');
      assert.fileContent('bower.json', '"angular-socket-io":');
      assert.fileContent('client/index.html', 'socket.io/socket.io.js');
      assert.fileContent('client/app.js', 'btford.socket-io');
      assert.file('server/config/sockets.js');
      assert.fileContent('server/server.js', 'var socket = require(\'socket.io\')');
      assert.fileContent('server/server.js', 'require(\'./config/sockets.js\')(socket);');
    });

  });

  describe('', function () {

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'json',
        modules: ['ngResource', 'ngAnimate']
      }, done);

    });

    it('should create all the files', basicFileCheck);

    it('should not have request dependency', function () {
      assert.noFileContent('package.json', 'request');
    });

    it('should not have mongo dependency', function () {
      assert.noFileContent('package.json', 'mongoose');
    });

    it('should not have mongo connect', function () {
      assert.noFileContent('server/server.js', 'mongoose.connect(config.mongo.uri, config.mongo.options);');
    });

    it('should have loaded client dependencies', function () {
      assert.file('bower.json');
      assert.fileContent('bower.json', '"angular-resource":');
      assert.fileContent('bower.json', '"angular-animate":');
    });
  });

  describe('', function () {

    var bangDir = process.cwd();

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'json',
        modules: []
      }, done);

    });

    it('should test a generation in an already generated directory', function (done) {

      var tmpBang = helpers.createGenerator('bangular', [bangDir + '/app'], false, { skipInstall: true });

      helpers.mockPrompt(tmpBang, { skipConfig: true });
      tmpBang.conflicter.force = true;
      tmpBang.run(done);

    });

  });

  describe('', function () {

    before(function (done) {

      utils.scaffold({
        name: 'Test',
        backend: 'mongo',
        modules: [],
        sockets: true,
        auth: true
      }, done);

    });

    it('should test for auth files', function () {

      assert.file([
        'client/views/signup/signup.controller.js',
        'client/views/signup/signup.html',
        'client/views/signup/signup.js',
        'client/views/login/login.controller.js',
        'client/views/login/login.html',
        'client/views/login/login.js',
        'client/services/auth',
        'server/auth'
      ]);

      assert.fileContent('server/routes.js', 'app.use(\'/auth\', require(\'./auth\'));');
      assert.fileContent('server/config/express.js', 'express-session');
      assert.fileContent('server/config/express.js', 'app.use(session({');
      assert.fileContent('package.json', 'passport');
      assert.fileContent('package.json', 'passport-local');
      assert.fileContent('package.json', 'connect-mongo');

      assert.fileContent('client/index.html', 'nav-bar');
      assert.fileContent('bower.json', 'angular-cookies');
    });
  });

  describe('', function () {

    before(function (done) {

      this.timeout(240000);
      var dir;

      helpers.run(path.join(__dirname, '../app'))
        .inDir(path.join(__dirname, './mock'), function (d) {
          dir = d;
          var cb = this.async();
          exec('cp ' + path.join(__dirname, '/files/.yo-rc.json') + ' ' + dir, function () {
            cb();
          });
        })
        .withPrompt({
          name: 'Test',
          backend: 'mongo',
          modules: [],
          sockets: true,
          auth: true,
          tests: ['e2e', 'karma', 'mocha', 'control']
        })
        .on('end', function () {
          exec('cp ' + path.join(__dirname, '/files/protractor.conf.js') + ' ' + dir, done);
        });
    });

    it('should successfully pass the gulp control command', function (done) {
      this.timeout(20000);
      exec('gulp control', function (err, stdout) {
        chaiAssert.include(stdout, ' Starting \'control\'...\n[', 'Start should not be followed by newlines.');
        chaiAssert.notInclude(stdout, 'Task \'control\' is not in your gulpfile');
        done();
      });
    });

    it('should successfully pass the server tests', function (done) {
      this.timeout(20000);
      exec('gulp test --server', function (err, stdout) {
        chaiAssert.notMatch(stdout, /((?=.*[1-9])\d+(\.\d+)?) failing\n/, 'Output should not have failing tests.');
        chaiAssert.notInclude(stdout, 'Task \'test\' is not in your gulpfile');
        done();
      });
    });

    it('should successfully pass the karma tests', function (done) {
      this.timeout(20000);
      exec('gulp test --client', function (err, stdout) {
        chaiAssert.notMatch(stdout, /\(((?=.*[1-9])\d+(\.\d+)?) FAILED\)/, 'Output should not contain failed tests.');
        chaiAssert.notInclude(stdout, 'Task \'test\' is not in your gulpfile');
        done();
      });
    });

    it('should build the app and check some files', function (done) {
      this.timeout(60000);
      exec('gulp build', function (err) {

        assert.file([
          'dist/package.json',
          'dist/server/server.js',
          'dist/server/routes.js',
          'dist/client/index.html'
        ]);

        assert.noFileContent('dist/client/index.html', 'livereload');
        done(err);
      });
    });

    it('should update the webdriver and pass e2e tests', function (done) {
      this.timeout(60000);
      exec('gulp e2e:update', function (err, stdout) {
        chaiAssert.notInclude(stdout, 'Task \'e2e:update\' is not in your gulpfile');
        exec('gulp e2e', { timeout: 30000 }, function (err, stdout) {
          chaiAssert.include(stdout, '3 tests, 3 assertions, 0 failures');
          chaiAssert.notMatch(stdout, /\(((?=.*[1-9])\d+(\.\d+)?) failures\)/, 'Output should not contain failed tests.');
          done();
        });
      });
    });

    after(function (done) {
      exec('cd .. && rm -rf ./mock', function () {
        done();
      });
    });

  });

});
<|endoftext|>


<commit_before>var reut = require("reut")
  , RoilApp = require("../src/app")
  , WebResource = require("../src/resource")
  , EventEmitter = require("events").EventEmitter

reut.suite("App class")
.setup(setupApp)
.test("run and shutdown methods", function(t, f) {
  var app = f.app
    , server = app.server
  app.run()
  t.ok(server)
  t.typeOf(server.use, 'function')
  app.shutdown()
})
.test("loadPlugin", function(t, f) {
  var app = f.app
    , dummyPlugin = t.called(function(roil) {
        t.is(roil, app)
      })
  app.loadPlugin(dummyPlugin)
})
.test("Exposing resource classes", function(t, f) {
  var r = f.app.resource
  t.typeOf(r.File, 'function')
  t.typeOf(r.WebResource, 'function')
})

reut.suite("Resource: dep and rules")
.setup(function(f) {
  setupApp(f)
  f.someResource = WebResource.new('/foo/bar')
})
.teardown(function(f) {
  WebResource.instances = {}
})
.test("addResource then matchResource", function(t, f) {
  var app = f.app
    , someResource = f.someResource
  app.addResource(someResource)
  app.matchResource(WebResource, t.cb(function(r) {
    t.is(r, someResource)
  }))
})
.test("matchResource then addResource", function(t, f) {
  var app = f.app
    , anotherRes
  app.matchResource(WebResource, t.cb(function(r) {
    t.is(r, anotherRes)
  }))
  anotherRes = WebResource.new("/holy/crap")
  app.addResource(anotherRes)
})
.test("addResource more than once", function(t, f) {
  var app = f.app
    , r = app.resource
    , someResource = f.someResource
    , count = 0
  app.matchResource(r.WebResource, function(r) {
    count++
  })
  app.addResource(someResource)
  app.addResource(someResource)
  app.addResource(someResource)
  t.is(count, 1)
})
.test("attachWorkspace()", function(t, f) {
  var app = f.app
    , ws = new EventEmitter
    , blah = {}
  app.addResource = t.cb(function(r) {
    t.is(r, blah)
  })
  app.attachWorkspace(ws)
  ws.emit("BC:resource", blah)
})

function setupApp(f) {
  f.conf = {
    port: 8913
  , plugIns: []
  }
  f.app = new RoilApp(f.conf)
}
<commit_msg>Cleanup a bit<commit_after>var reut = require("reut")
  , RoilApp = require("../src/app")
  , WebResource = require("../src/resource")
  , EventEmitter = require("events").EventEmitter

reut.suite("App class")
.setup(setupApp)
.test("run and shutdown methods", function(t, f) {
  var app = f.app
    , server = app.server
  app.run()
  t.ok(server)
  t.typeOf(server.use, 'function')
  app.shutdown()
})
.test("loadPlugin", function(t, f) {
  var app = f.app
    , dummyPlugin = t.called(function(roil) {
        t.is(roil, app)
      })
  app.loadPlugin(dummyPlugin)
})
.test("Exposing resource classes", function(t, f) {
  var r = f.app.resource
  t.typeOf(r.File, 'function')
  t.typeOf(r.WebResource, 'function')
})

reut.suite("Resource: dep and rules")
.setup(function(f) {
  setupApp(f)
  f.someResource = WebResource.new('/foo/bar')
})
.teardown(function(f) {
  WebResource.instances = {}
})
.test("addResource then matchResource", function(t, f) {
  var app = f.app
    , someResource = f.someResource
  app.addResource(someResource)
  app.matchResource(WebResource, t.cb(function(r) {
    t.is(r, someResource)
  }))
})
.test("matchResource then addResource", function(t, f) {
  var app = f.app
    , anotherRes
  app.matchResource(WebResource, t.cb(function(r) {
    t.is(r, anotherRes)
  }))
  anotherRes = WebResource.new("/holy/crap")
  app.addResource(anotherRes)
})
.test("addResource more than once", function(t, f) {
  var app = f.app
    , klass = app.resource.WebResource
    , someResource = f.someResource
    , count = 0
  app.matchResource(klass, function(r) {
    count++
  })
  app.addResource(someResource)
  app.addResource(someResource)
  app.addResource(someResource)
  t.is(count, 1)
})
.test("attachWorkspace()", function(t, f) {
  var app = f.app
    , ws = new EventEmitter
    , blah = {}
  app.addResource = t.cb(function(r) {
    t.is(r, blah)
  })
  app.attachWorkspace(ws)
  ws.emit("BC:resource", blah)
})

function setupApp(f) {
  f.conf = {
    port: 8913
  , plugIns: []
  }
  f.app = new RoilApp(f.conf)
}
<|endoftext|>


<commit_before>require.config({
    urlArgs: (new Date()).getTime().toString().substring(8),
    paths: {
        "appcore": "dependencies/appcore",
        "jquery": "dependencies/jquery/jquery"
    }
});

require([
        "appcore/appcore",
        "appcore/core/modules/util/models/promise",
        "appcore/core/modules/events/helpers/event-helper",
        "appcore/core/modules/util/helpers/uuid-helper"
    ],
    function(Ac, Promise, EventHelper) {

    /*
     *  PROMISES
     */

    /*
    //Promise creation (method #1)
    var testX = Promise.convert(function(callback, error, value) {
        setTimeout(function() {
            value = 10;
            console.log("Initial value = " + value);
            callback(value);
        }, 0);
    });

    //Promise creation (method #2)
    function testY1(value) {
        return new Promise(function(resolve, reject) {
            setTimeout(function() {
                value += 1;
                alert("value + 1 = " + value);
                resolve(value);
            }, 25);
        });
    }

    function testY2(value) {
        return new Promise(function(resolve, reject) {
            setTimeout(function() {
                value += 2;
                alert("value + 2 = " + value);
                resolve(value);
            }, 50);
        });
    }

    function testY3(value) {
        return new Promise(function(resolve, reject) {
            setTimeout(function() {
                value += 3;
                alert("value + 3 = " + value);
                resolve(value);
            }, 75);
        });
    }

    //Test usage
    testX()
    .then(testY1)
    .then(testY2)
    .then(testY3)
    .then(function(value) {
        alert("Final value = " + value);
    });

    /*
     *  HELPERS
     */

    /*
    //Test usage
    console.log(Ac.Helper.get("Uuid").generateUuid());

    /*
     *  MODELS
     */

    //Model definition
    var User = Ac.Model.create(["name", "age", "sex"], function(name, age) {
        this.set({
            name: name,
            age: age
        });
    });

    var Pet = Ac.Model.create(["name", "type"], function(name, type) {
        this.set({
            name: name,
            type: type
        });
    });

    //Model method definition
    User.addMethod("greet", function() {
        console.log("Hello, I am " + this.getName() + " and I am " + this.getAge() + "!");
    });

    //Model static method definition
    User.addStaticMethod("test", function() {
        console.log("Testing the User class");
    });
    /*
    //Model validation
    User.setValidationRules({
        age: [
            {
                required: true
            },
            {
                type: "int"
            },
            {
                minValue: 0,
            },
            {
                maxValue: 100,
                message: "Surely a person can't be that old?"
            }
        ],
        name: [
            {
                type: "string"
            }
        ]
    });

    //Test usage
    var userA = new User("Alan", 12);
    var userB = new User("Bob", 15);

    userA.greet();
    userB.greet();
    userA.set("name", "Adrian");
    userB.set({ name: "Bill" });
    userA.greet();
    userB.greet();
    User.test();

    console.log("User validation rules", User.getValidationRules());
    console.log("Validating userB #1", userB.validate());
    userB.setName(0);
    userB.setAge(111);
    console.log("Validating userB #2", userB.validate());

    console.log("Pet valiation rules", Pet.getValidationRules());

    /*
     * EVENTS
     */

    /*
    //Event triggers
    User.addMethod("grow", function() {
        this.set("age", this.get("age") + 1);
        this.trigger("grow", { age: this.get("age") });
    });

    User.addMethod("talk", function(message) {
        this.trigger("talk", { message: message });
    });

    //Event observers
    EventHelper.observe(userA, "grow", function(event) {
        console.log(event.getTarget().getName() + " has grown to " + event.getTarget().getAge() + " years old.");
    });

    EventHelper.observe(userA, "talk", function(event) {
        console.log(event.getTarget().getName() + " has said \"" + event.getData().message + "\".");
    });

    EventHelper.observe(userB, "grow", function(event) {
        console.log(event.getTarget().getName() + " has grown to " + event.getTarget().getAge() + " years old.");
    });

    //Test usage
    userA.grow();
    userA.grow();
    userA.grow();
    userB.grow();
    userB.grow();
    userA.talk("Sup bro?");

    /*
     * DATA BINDING
     */

    var userC = new User("Alan", 12);

    //Define view
    var view1 = Ac.View.create("#input-text");
    var view2 = Ac.View.create("#header-title");
    var view3 = Ac.View.create("#footer");

    //Data binding creation
    view1.addDataBinding(userC, "name", "value");
    view2.addDataBinding(userC, "name", "innerHTML");
    view3.addDataBinding(userC, function() { return "©2014 " + userC.getName() + ". All rights reserved." }, "innerHTML", false);

    //Test usage
    userC.setName("Aaron");
});

/*
require(["appcore/app"], function(App) {
    //Define models
    var User = App.Model.create(
        {
            name: "string",
            email: "email",
            tasks: Collection
        },
        function(name, email) {
            this.set({
                name: name,
                email: email
            });
        }
    );

    User.addMethod("hasTasks", function() {
        return this.tasks.hasItems();
    });

    var Task = App.Model.create({
        description: "string",
        status: "boolean"
    });

    //Define controllers
    var UsersController = App.Controller.create(User);

    UsersController.addAction("index", function() {
        var people = this.getCollectionItems();

        var view = App.View.create("#content", template);
        view.bind(people);
    });

    UsersController.addAction("create", function() {
        this.observe("#submit", "click", function() {
            var user = new User(document.querySelector("#input-name").value, document.querySelector("#input-email").value);

            if (user.isValid()) {
                this.getCollection().add(user);
                this.persistCollection(function(response) {
                    if (response.status === 1) {
                        App.go("/");
                    }
                    else {
                        document.querySelector("#notice").innerHTML = "Error: A problem was encountered while saving the record."
                    }
                });
            }
        });
    });

    UsersController.addAction("view", function(id) {
        var user = this.getCollection().find(id);

        var view = App.View.create("#content", template);
        view.render(user);
    });

    UsersController.addAction("update", function() {
        var user = this.getCollection().find(id);

        this.observe("#submit", "click", function() {
            user.setName(document.querySelector("#input-name").value);
            user.setEmail(document.querySelector("#input-email").value);

            if (user.isValid()) {
                this.getCollection().add(user);
                this.persistCollection(function(response) {
                    if (response.status === 1) {
                        App.go("/");
                    }
                    else {
                        document.querySelector("#notice").innerHTML = "Error: A problem was encountered while saving the record."
                    }
                });
            }
        });
    });

    UsersController.addAction("delete", function(id) {
        this.getCollection().delete(id);
        this.persistCollection(function(response) {
            if (response.status === 1) {
                App.go("/");
            }
            else {
                document.querySelector("#notice").innerHTML = "Error: A problem was encountered while saving the record."
            }
        });
    });

    UsersController.addAction

    App.setBaseUrl("http://localhost/alvinteh_appcore/test");
    App.Route.add("/", UsersController.getActions());

    view1.addDataBinding(p1, function() { return p1.getName() + "!!!"; }, "value");
    view2.addDataBinding(p1, "name", "innerHTML");
});
*/<commit_msg>Updated test code to match new model creation method signature.<commit_after>require.config({
    urlArgs: (new Date()).getTime().toString().substring(8),
    paths: {
        "appcore": "dependencies/appcore",
        "jquery": "dependencies/jquery/jquery"
    }
});

require([
        "appcore/appcore",
        "appcore/core/modules/util/models/promise",
        "appcore/core/modules/events/helpers/event-helper",
        "appcore/core/modules/util/helpers/uuid-helper"
    ],
    function(Ac, Promise, EventHelper) {

    /*
     *  PROMISES
     */

    /*
    //Promise creation (method #1)
    var testX = Promise.convert(function(callback, error, value) {
        setTimeout(function() {
            value = 10;
            console.log("Initial value = " + value);
            callback(value);
        }, 0);
    });

    //Promise creation (method #2)
    function testY1(value) {
        return new Promise(function(resolve, reject) {
            setTimeout(function() {
                value += 1;
                alert("value + 1 = " + value);
                resolve(value);
            }, 25);
        });
    }

    function testY2(value) {
        return new Promise(function(resolve, reject) {
            setTimeout(function() {
                value += 2;
                alert("value + 2 = " + value);
                resolve(value);
            }, 50);
        });
    }

    function testY3(value) {
        return new Promise(function(resolve, reject) {
            setTimeout(function() {
                value += 3;
                alert("value + 3 = " + value);
                resolve(value);
            }, 75);
        });
    }

    //Test usage
    testX()
    .then(testY1)
    .then(testY2)
    .then(testY3)
    .then(function(value) {
        alert("Final value = " + value);
    });

    /*
     *  HELPERS
     */

    /*
    //Test usage
    console.log(Ac.Helper.get("Uuid").generateUuid());

    /*
     *  MODELS
     */

    //Model definition
    var User = Ac.Model.create("User", ["name", "age", "sex"], function(name, age) {
        this.set({
            name: name,
            age: age
        });
    });

    var Pet = Ac.Model.create("Pet", ["name", "type"], function(name, type) {
        this.set({
            name: name,
            type: type
        });
    });

    //Model method definition
    User.addMethod("greet", function() {
        console.log("Hello, I am " + this.getName() + " and I am " + this.getAge() + "!");
    });

    //Model static method definition
    User.addStaticMethod("test", function() {
        console.log("Testing the User class");
    });
    /*
    //Model validation
    User.setValidationRules({
        age: [
            {
                required: true
            },
            {
                type: "int"
            },
            {
                minValue: 0,
            },
            {
                maxValue: 100,
                message: "Surely a person can't be that old?"
            }
        ],
        name: [
            {
                type: "string"
            }
        ]
    });

    //Test usage
    var userA = new User("Alan", 12);
    var userB = new User("Bob", 15);

    userA.greet();
    userB.greet();
    userA.set("name", "Adrian");
    userB.set({ name: "Bill" });
    userA.greet();
    userB.greet();
    User.test();

    console.log("User validation rules", User.getValidationRules());
    console.log("Validating userB #1", userB.validate());
    userB.setName(0);
    userB.setAge(111);
    console.log("Validating userB #2", userB.validate());

    console.log("Pet valiation rules", Pet.getValidationRules());

    /*
     * EVENTS
     */

    /*
    //Event triggers
    User.addMethod("grow", function() {
        this.set("age", this.get("age") + 1);
        this.trigger("grow", { age: this.get("age") });
    });

    User.addMethod("talk", function(message) {
        this.trigger("talk", { message: message });
    });

    //Event observers
    EventHelper.observe(userA, "grow", function(event) {
        console.log(event.getTarget().getName() + " has grown to " + event.getTarget().getAge() + " years old.");
    });

    EventHelper.observe(userA, "talk", function(event) {
        console.log(event.getTarget().getName() + " has said \"" + event.getData().message + "\".");
    });

    EventHelper.observe(userB, "grow", function(event) {
        console.log(event.getTarget().getName() + " has grown to " + event.getTarget().getAge() + " years old.");
    });

    //Test usage
    userA.grow();
    userA.grow();
    userA.grow();
    userB.grow();
    userB.grow();
    userA.talk("Sup bro?");

    /*
     * DATA BINDING
     */

    var userC = new User("Alan", 12);

    //Define view
    var view1 = Ac.View.create("#input-text");
    var view2 = Ac.View.create("#header-title");
    var view3 = Ac.View.create("#footer");

    //Data binding creation
    view1.addDataBinding(userC, "name", "value");
    view2.addDataBinding(userC, "name", "innerHTML");
    view3.addDataBinding(userC, function() { return "©2014 " + userC.getName() + ". All rights reserved." }, "innerHTML", false);

    //Test usage
    userC.setName("Aaron");
});

/*
require(["appcore/app"], function(App) {
    //Define models
    var User = App.Model.create(
        {
            name: "string",
            email: "email",
            tasks: Collection
        },
        function(name, email) {
            this.set({
                name: name,
                email: email
            });
        }
    );

    User.addMethod("hasTasks", function() {
        return this.tasks.hasItems();
    });

    var Task = App.Model.create({
        description: "string",
        status: "boolean"
    });

    //Define controllers
    var UsersController = App.Controller.create(User);

    UsersController.addAction("index", function() {
        var people = this.getCollectionItems();

        var view = App.View.create("#content", template);
        view.bind(people);
    });

    UsersController.addAction("create", function() {
        this.observe("#submit", "click", function() {
            var user = new User(document.querySelector("#input-name").value, document.querySelector("#input-email").value);

            if (user.isValid()) {
                this.getCollection().add(user);
                this.persistCollection(function(response) {
                    if (response.status === 1) {
                        App.go("/");
                    }
                    else {
                        document.querySelector("#notice").innerHTML = "Error: A problem was encountered while saving the record."
                    }
                });
            }
        });
    });

    UsersController.addAction("view", function(id) {
        var user = this.getCollection().find(id);

        var view = App.View.create("#content", template);
        view.render(user);
    });

    UsersController.addAction("update", function() {
        var user = this.getCollection().find(id);

        this.observe("#submit", "click", function() {
            user.setName(document.querySelector("#input-name").value);
            user.setEmail(document.querySelector("#input-email").value);

            if (user.isValid()) {
                this.getCollection().add(user);
                this.persistCollection(function(response) {
                    if (response.status === 1) {
                        App.go("/");
                    }
                    else {
                        document.querySelector("#notice").innerHTML = "Error: A problem was encountered while saving the record."
                    }
                });
            }
        });
    });

    UsersController.addAction("delete", function(id) {
        this.getCollection().delete(id);
        this.persistCollection(function(response) {
            if (response.status === 1) {
                App.go("/");
            }
            else {
                document.querySelector("#notice").innerHTML = "Error: A problem was encountered while saving the record."
            }
        });
    });

    UsersController.addAction

    App.setBaseUrl("http://localhost/alvinteh_appcore/test");
    App.Route.add("/", UsersController.getActions());

    view1.addDataBinding(p1, function() { return p1.getName() + "!!!"; }, "value");
    view2.addDataBinding(p1, "name", "innerHTML");
});
*/<|endoftext|>


<commit_before>/**
 * @license
 * Copyright (c) 2016 The IBM Research Emergent Solutions authors. All rights reserved.
 * This code may only be used under the MIT style license found at https://ibmresearch.github.io/LICENSE.txt
 * The complete set of authors may be found at https://ibmresearch.github.io/AUTHORS.txt
 * The complete set of contributors may be found at https://ibmresearch.github.io/CONTRIBUTORS.txt
 */

'use strict';

const path = require('path');

const assert = require('yeoman-assert');
const helpers = require('yeoman-test');

describe('generator-polymer-init-ibm-application:app', () => {
  before(() => {
    return helpers.run(path.join(__dirname, '../generators/app'))
      .withPrompts({
        applicationId: 'ibm-application',
        applicationName: 'Application',
        applicationDescription: 'Application description'
      })
      .toPromise();
  });

  it('creates files', () => {
    assert.file([
      'gulp-tasks/clean.js',
      'gulp-tasks/images.js',
      'gulp-tasks/lint.js',
      'gulp-tasks/project.js',
      'images/manifest/icon-144x144.png',
      'images/manifest/icon-192x192.png',
      'images/manifest/icon-48x48.png',
      'images/manifest/icon-512x512.png',
      'images/manifest/icon-72x72.png',
      'images/manifest/icon-96x96.png',
      'images/favicon.ico',
      'src/page-404/page-404.html',
      'src/page-home/page-home.html',
      'src/app-icons.html',
      'src/app-shell.html',
      'src/app-styles.html',
      'test/.eslintrc.json',
      'test/index.html',
      '.eslintrc.json',
      '.gitignore',
      'bower.json',
      'gulpfile.js',
      'index.html',
      'LICENSE',
      'manifest.json',
      'package.json',
      'polymer.json',
      'README.md',
      'service-worker.js'
    ]);
  });
});
<commit_msg>Remove gulp-tasks folder<commit_after>/**
 * @license
 * Copyright (c) 2016 The IBM Research Emergent Solutions authors. All rights reserved.
 * This code may only be used under the MIT style license found at https://ibmresearch.github.io/LICENSE.txt
 * The complete set of authors may be found at https://ibmresearch.github.io/AUTHORS.txt
 * The complete set of contributors may be found at https://ibmresearch.github.io/CONTRIBUTORS.txt
 */

'use strict';

const path = require('path');

const assert = require('yeoman-assert');
const helpers = require('yeoman-test');

describe('generator-polymer-init-ibm-application:app', () => {
  before(() => {
    return helpers.run(path.join(__dirname, '../generators/app'))
      .withPrompts({
        applicationId: 'ibm-application',
        applicationName: 'Application',
        applicationDescription: 'Application description'
      })
      .toPromise();
  });

  it('creates files', () => {
    assert.file([
      'images/manifest/icon-144x144.png',
      'images/manifest/icon-192x192.png',
      'images/manifest/icon-48x48.png',
      'images/manifest/icon-512x512.png',
      'images/manifest/icon-72x72.png',
      'images/manifest/icon-96x96.png',
      'images/favicon.ico',
      'src/page-404/page-404.html',
      'src/page-home/page-home.html',
      'src/app-icons.html',
      'src/app-shell.html',
      'src/app-styles.html',
      'test/.eslintrc.json',
      'test/index.html',
      '.eslintrc.json',
      '.gitignore',
      'bower.json',
      'gulpfile.js',
      'index.html',
      'LICENSE',
      'manifest.json',
      'package.json',
      'polymer.json',
      'README.md',
      'service-worker.js'
    ]);
  });
});
<|endoftext|>


<commit_before>'use strict'
const path = require('path')
const assert = require('yeoman-assert')
const helpers = require('yeoman-test')
const fs = require('fs-extra')
const exec = require('child_process').exec

describe('generator-style-guider:app - npm', () => {
  before(() => {
    return helpers.run(path.join(__dirname, '../generators/app'))
      .withPrompts({
        name: 'my-styles',
        depManager: 'npm',
        husky: true
      })
  })

  it('creates files', () => {
    assert.file([
      'package.json',
      'scss/my-styles.scss'
    ])
  })
})

describe('generator-style-guider:app - yarn', () => {
  before(() => {
    return helpers.run(path.join(__dirname, '../generators/app'))
      .withPrompts({
        name: 'My Styles',
        depManager: 'yarn',
        husky: true
      })
  })

  it('creates files', () => {
    assert.file([
      'package.json',
      'scss/my-styles.scss'
    ])
  })
})

describe('generator-style-guider:app - npm w/ install', () => {
  before((done) => {
    return helpers.run(path.join(__dirname, '../generators/app'))
      .inTmpDir(dir => {
        fs.writeFileSync(path.join(dir, '.npmrc'), 'loglevel=warn\nprogress=false')
      })
      .withPrompts({
        name: 'my-styles',
        depManager: 'npm',
        husky: false
      })
      .withOptions({ skipInstall: false })
      .then((dir) => {
        return exec('npm run lint', function (error, stdout, stderr) {
          console.log(stdout)
          if (error) {
            console.log(stderr)
            assert(false)
          }
          assert(true)
          done()
        })
      })
  })

  it('Install dependencies then build docs', () => {
    assert.file([
      'index.html',
      'dist/my-styles.min.css',
      'dist/my-styles.min.js',
      'docs/css/docs.css',
      'docs/js/scripts.js'
    ])
  })
})

describe('generator-style-guider:app - yarn w/ install', () => {
  before(() => {
    return helpers.run(path.join(__dirname, '../generators/app'))
      .withPrompts({
        name: 'My Styles',
        depManager: 'yarn',
        husky: true
      })
      .withOptions({ skipInstall: false })
  })

  it('Install dependencies then build docs', () => {
    assert.file([
      'index.html',
      'dist/my-styles.min.css',
      'dist/my-styles.min.js',
      'docs/css/docs.css',
      'docs/js/scripts.js'
    ])
  })
})
<commit_msg>Pass options object to exec<commit_after>'use strict'
const path = require('path')
const assert = require('yeoman-assert')
const helpers = require('yeoman-test')
const fs = require('fs-extra')
const exec = require('child_process').exec

describe('generator-style-guider:app - npm', () => {
  before(() => {
    return helpers.run(path.join(__dirname, '../generators/app'))
      .withPrompts({
        name: 'my-styles',
        depManager: 'npm',
        husky: true
      })
  })

  it('creates files', () => {
    assert.file([
      'package.json',
      'scss/my-styles.scss'
    ])
  })
})

describe('generator-style-guider:app - yarn', () => {
  before(() => {
    return helpers.run(path.join(__dirname, '../generators/app'))
      .withPrompts({
        name: 'My Styles',
        depManager: 'yarn',
        husky: true
      })
  })

  it('creates files', () => {
    assert.file([
      'package.json',
      'scss/my-styles.scss'
    ])
  })
})

describe('generator-style-guider:app - npm w/ install', () => {
  before((done) => {
    return helpers.run(path.join(__dirname, '../generators/app'))
      .inTmpDir(dir => {
        fs.writeFileSync(path.join(dir, '.npmrc'), 'loglevel=warn\nprogress=false')
      })
      .withPrompts({
        name: 'my-styles',
        depManager: 'npm',
        husky: false
      })
      .withOptions({ skipInstall: false })
      .then((dir) => {
        return exec('npm run lint', {}, function (error, stdout, stderr) {
          console.log(stdout)
          if (error) {
            console.log(stderr)
            assert(false)
          }
          assert(true)
          done()
        })
      })
  })

  it('Install dependencies then build docs', () => {
    assert.file([
      'index.html',
      'dist/my-styles.min.css',
      'dist/my-styles.min.js',
      'docs/css/docs.css',
      'docs/js/scripts.js'
    ])
  })
})

describe('generator-style-guider:app - yarn w/ install', () => {
  before(() => {
    return helpers.run(path.join(__dirname, '../generators/app'))
      .withPrompts({
        name: 'My Styles',
        depManager: 'yarn',
        husky: true
      })
      .withOptions({ skipInstall: false })
  })

  it('Install dependencies then build docs', () => {
    assert.file([
      'index.html',
      'dist/my-styles.min.css',
      'dist/my-styles.min.js',
      'docs/css/docs.css',
      'docs/js/scripts.js'
    ])
  })
})
<|endoftext|>


<commit_before>/* eslint-disable func-names */
/* eslint-env mocha */
'use strict';
var path = require('path');
var assert = require('yeoman-assert');
var helpers = require('yeoman-generator').test;

describe('generator-eslint-init:app', function () {
  before(function (done) {
    helpers.run(path.join(__dirname, '../generators/app'))
      .withOptions({ someOption: true })
      .withPrompts({ someAnswer: true })
      .on('end', done);
  });

  it('creates files', function () {
    assert.file('.eslintrc.json');
  });
});
<commit_msg>do you test?<commit_after>/* eslint-disable func-names */
/* eslint-env mocha */
'use strict';
var path = require('path');
var assert = require('yeoman-assert');
var helpers = require('yeoman-generator').test;
var stringify = function stringify(obj) { return JSON.stringify(obj, null, 2); };

var generator = function() {
  return helpers.run(path.join(__dirname, '../generators/app'));
};

describe('generator-eslint-init:app', function () {
  it('creates files', function(done) {
    generator().on('end', function() {
      assert.file('.eslintrc.json');
      done();
    });
  });

  it('creates empty files with zero input', function(done) {
    generator().on('end', function() {
      assert.fileContent('.eslintrc.json', '{}');
      done();
    });
  });

  describe('cli', function() {
    describe('extends', function() {
      it('uses one extends from arguments', function(done) {
        generator().withArguments(['airbnb']).on('end', function() {
          assert.fileContent('.eslintrc.json', /"extends": "airbnb"/);
          done();
        });
      });
      it('uses several extends array from arguments', function(done) {
        generator().withArguments(['airbnb', 'meow']).on('end', function() {
          assert.fileContent('.eslintrc.json', /"extends":[\n"airbnb", "meow"\n]/);
          done();
        });
      });
    });

    describe('plugins', function() {
      it('uses plugins string with one item from options', function(done) {
        generator().withOptions({ plugins: 'purr'}).on('end', function() {
          assert.fileContent('.eslintrc.json', /"plugins":[\n"purr" \n]/);
          done();
        });
      });

      it('uses plugins string from options', function(done) {
        generator().withOptions({ plugins: 'purr,scratch'}).on('end', function() {
          assert.fileContent('.eslintrc.json', /"plugins":[\n"purr", "scratch"\n]/);
          done();
        });
      });

      it('uses plugins array with one item from options', function(done) {
        generator().withOptions({ plugins: ['purr']}).on('end', function() {
          assert.fileContent('.eslintrc.json', /"plugins":[\n"purr" \n]/);
          done();
        });
      });

      it('uses plugins array from options', function(done) {
        generator().withOptions({ plugins: ['purr', 'scratch']}).on('end', function() {
          assert.fileContent('.eslintrc.json', /"plugins":[\n"purr", "scratch"\n]/);
          done();
        });
      });
    });
  });

  describe('compose', function() {
    it('uses config option', function(done) {
      generator().withOptions({ config: { key: 'val' }}).on('end', function() {
        assert.fileContent('.eslintrc.json', /"key": "val"/);
        done();
      });
    });

    it('uses config.extends string option', function(done) {
      generator().withOptions({ config: { extends: 'meow' }}).on('end', function() {
        assert.fileContent('.eslintrc.json', /"extends": "meow"/);
        done();
      });
    });

    it('uses config.extends array option', function(done) {
      generator().withOptions({ config: { extends: ['meow', 'purr'] }}).on('end', function() {
        assert.fileContent('.eslintrc.json', /"extends":[\n"meow", "purr"\n]/);
        done();
      });
    });

    it('uses config.plugins array option', function(done) {
      generator().withOptions({ config: { plugins: ['meow', 'purr'] }}).on('end', function() {
        assert.fileContent('.eslintrc.json', /"plugins":[\n"meow", "purr"\n]/);
        done();
      });
    });
  });

  it('install extends and plugins with proper prefixes', function(done) {
    var pkg = {
      name: 'name',
      description: 'desc',
      repository: 'iamstarkov/generator-eslint-init',
      license: 'MIT',
    };
    generator()
      .withOptions({ skipInstall: false })
      .withOptions({ config: {
        extends: 'airbnb',
        plugins: ['require-path-exists']
      }})
      .on('ready', function(gen) {
        gen.fs.write(gen.destinationPath('package.json'), stringify(pkg));
      }.bind(this))
      .on('end', function() {
        assert.file('package.json');
        assert.fileContent('package.json', /eslint/);
        assert.fileContent('package.json', /eslint-config-airbnb/);
        assert.fileContent('package.json', /eslint-plugin-require-path-exists/);
        done();
      });
  });
});
<|endoftext|>


<commit_before>/**
 * @license
 * Copyright (c) 2016 The IBM Research authors. All rights reserved.
 * This code may only be used under the MIT style license found at https://ibmresearch.github.io/LICENSE.txt
 * The complete set of authors may be found at https://ibmresearch.github.io/AUTHORS.txt
 * The complete set of contributors may be found at https://ibmresearch.github.io/CONTRIBUTORS.txt
 */

'use strict';

const path = require('path');

const assert = require('yeoman-assert');
const helpers = require('yeoman-test');

describe('generator-polymer-init-ibm-application:app', () => {
  before(() => {
    return helpers.run(path.join(__dirname, '../generators/app'))
      .withPrompts({
        applicationId: 'ibm-application',
        applicationName: 'Application',
        applicationDescription: 'Application description'
      })
      .toPromise();
  });

  it('creates files', () => {
    assert.file([
      'images/manifest/icon-144x144.png',
      'images/manifest/icon-192x192.png',
      'images/manifest/icon-48x48.png',
      'images/manifest/icon-512x512.png',
      'images/manifest/icon-72x72.png',
      'images/manifest/icon-96x96.png',
      'images/favicon.ico',
      'src/page-404/page-404.html',
      'src/page-home/page-home.html',
      'src/app-icons.html',
      'src/app-shell.html',
      'src/app-styles.html',
      'test/.eslintrc.json',
      'test/index.html',
      '.eslintrc.json',
      '.gitignore',
      'bower.json',
      'gulpfile.js',
      'index.html',
      'LICENSE',
      'manifest.json',
      'package.json',
      'polymer.json',
      'README.md',
      'service-worker.js',
      'sw-precache-config.js'
    ]);
  });
});
<commit_msg>Fix test<commit_after>/**
 * @license
 * Copyright (c) 2016 The IBM Research authors. All rights reserved.
 * This code may only be used under the MIT style license found at https://ibmresearch.github.io/LICENSE.txt
 * The complete set of authors may be found at https://ibmresearch.github.io/AUTHORS.txt
 * The complete set of contributors may be found at https://ibmresearch.github.io/CONTRIBUTORS.txt
 */

'use strict';

const path = require('path');

const assert = require('yeoman-assert');
const helpers = require('yeoman-test');

describe('generator-polymer-init-ibm-application:app', () => {
  before(() => {
    return helpers.run(path.join(__dirname, '../generators/app'))
      .withPrompts({
        applicationId: 'ibm-application',
        applicationName: 'Application',
        applicationDescription: 'Application description'
      })
      .toPromise();
  });

  it('creates files', () => {
    assert.file([
      'images/manifest/icon-144x144.png',
      'images/manifest/icon-192x192.png',
      'images/manifest/icon-48x48.png',
      'images/manifest/icon-512x512.png',
      'images/manifest/icon-72x72.png',
      'images/manifest/icon-96x96.png',
      'images/favicon.ico',
      'src/page-home/page-home.html',
      'src/page-not-found/page-not-found.html',
      'src/app-icons.html',
      'src/app-shell.html',
      'src/app-styles.html',
      'test/.eslintrc.json',
      'test/index.html',
      '.eslintrc.json',
      '.gitignore',
      'bower.json',
      'gulpfile.js',
      'index.html',
      'LICENSE',
      'manifest.json',
      'package.json',
      'polymer.json',
      'README.md',
      'service-worker.js',
      'sw-precache-config.js'
    ]);
  });
});
<|endoftext|>


<commit_before>"use strict";

const
    cli = require("../lib/cli"),
    expect = require("code").expect,
    fs = require("fs"),
    path = require("path"),
    utils = require("./lib/test-utils.js");

const  // jscs: ignore requireMultipleVarDecl
    readFixture = utils.readFixture,
    run = utils.run;

/* eslint-disable max-len */

describe("cli", () =>
{
    const dir = "test/fixtures/cli";

    let executable;

    before(() => { executable = cli.getEnvironment().executable; });

    it("should generate an error if the file does not exist", () =>
    {
        const result = run(["--no-color", "foo.j"]);

        expect(result.output).to.match(/^acorn-objj: error: ENOENT: no such file or directory, open '.+'/);
        expect(result.exitCode).to.equal(1);
    });

    it("should generate an error if there is #! without --allow-hash-bang", () =>
    {
        const result = run(["--no-color", path.join(dir, "hash-bang.js")]);

        expect(result.output).to.equal(readFixture("cli/hash-bang.txt", true));
        expect(result.exitCode).to.equal(1);
    });

    it("should generate a stack trace with --stack-trace for thrown Error", () =>
    {
        const result = run(["--no-color", "--stack-trace", "foo.j"]);

        expect(result.output).to.match(/^acorn-objj: error: ENOENT: no such file or directory, open '.+?'\n\nError: ENOENT: no such file or directory, open '.+?'\n\s+at Error \(native\)/);
        expect(result.exitCode).to.equal(1);
    });

    it("should generate a stack trace with --stack-trace for thrown SyntaxError", () =>
    {
        const result = run(["--ecma", "5", "--stack-trace", "--no-color", path.join(dir, "ecma.js")]);

        expect(result.output).to.match(/^(.*\n)+1 error generated\.\n\nSyntaxError: Expected ';' after expression\n\s+at Parser.objj_semicolon \(.+?\n/g);
        expect(result.exitCode).to.equal(1);
    });

    it("should not generate an error if there is #! with --allow-hash-bang", () =>
    {
        expect(run(["--allow-hash-bang", path.join(dir, "hash-bang.js")]).output)
            .to.equal(readFixture("cli/hash-bang.json"));
    });

    it("should generate pretty-printed JSON by default", () =>
    {
        expect(run([path.join(dir, "compact.js")]).output)
            .to.equal(readFixture("cli/pretty.json"));
    });

    it("should generate compact JSON with --compact", () =>
    {
        expect(run(["--compact", path.join(dir, "compact.js")]).output)
            .to.equal(readFixture("cli/compact.json"));
    });

    it("should not parse ECMAScript 6 with --ecma 5", () =>
    {
        const result = run(["--ecma", "5", path.join(dir, "ecma.js")]);

        expect(result.output).to.equal(readFixture("cli/ecma.txt"));
        expect(result.exitCode).to.equal(1);
    });

    it("should parse EMCAScript 6 by default", () =>
    {
        expect(run([path.join(dir, "ecma.js")]).output)
            .to.equal(readFixture("cli/ecma.json"));
    });

    it("should show help with --help", () =>
    {
        const prefix =
            `${cli.getVersionString()} \nUsage: ${executable} [options] file\n\nParses a file and outputs an AST.`;

        expect(run(["--help"]).output).to.startWith(prefix);
    });

    it("should generate location data with --locations", () =>
    {
        expect(run(["--locations", path.join(dir, "compact.js")]).output)
            .to.equal(readFixture("cli/locations.json"));
    });

    it("should fail on Objective-J code with --no-objj", () =>
    {
        const result = run(["--no-objj", path.join(dir, "objj.j")]);

        expect(result.output).to.equal(readFixture("cli/objj.txt"));
        expect(result.exitCode).to.equal(1);
    });

    it("should not recognize Objective-J keywords with --no-objj", () =>
    {
        expect(run(["--no-objj", path.join(dir, "no-objj.js")]).output)
            .to.equal(readFixture("cli/no-objj.json"));
    });

    it("should not recognize objj keywords with --no-objj", () =>
    {
        run(["--no-objj", path.join(dir, "no-objj.js")]);
    });

    it("should not generate any output with --silent", () =>
    {
        let result = run(["--silent", path.join(dir, "compact.js")]);

        expect(result.exitCode).to.equal(0);
        expect(result.output).to.be.empty();

        result = run(["--ecma", "5", "--silent", path.join(dir, "ecma.js")]);

        expect(result.exitCode).to.equal(1);
        expect(result.output).to.be.empty();
    });

    it("should generate an error for missing semicolons with --strict-semicolons", () =>
    {
        const result = run(["--strict-semicolons", path.join(dir, "strict-semicolons.js")]);

        expect(result.output).to.equal(readFixture("cli/strict-semicolons.txt"));
        expect(result.exitCode).to.equal(1);
    });

    it("should generate an error for reserved words with --module", () =>
    {
        // --module forces strict mode
        const result = run(["--module", "--ecma", "5", path.join(dir, "module.js")]);

        expect(result.output).to.equal(readFixture("cli/module.txt"));
        expect(result.exitCode).to.equal(1);
    });

    it("should use an absolute file path in error messages if the path is not within the cwd", () =>
    {
        const cwd = process.cwd();

        process.chdir("lib");

        // --module forces strict mode
        const result = run(["--module", "--ecma", "5", path.join("..", dir, "module.js")]);

        process.chdir(cwd);

        // Extract the file path
        let file = result.output.trim(),
            pos = file.indexOf(":");

        if (pos > 0)
            file = file.substr(0, pos);
        else
            file = "";

        expect(path.isAbsolute(file)).to.be.true();
    });

    it("should show the executable name, version and acorn version with --version", () =>
    {
        expect(run(["--version"]).output).to.equal(cli.getVersionString() + "\n");
    });

    it("should generate an error if no input file is given", () =>
    {
        const result = run([]);

        expect(result.output).to.equal("acorn-objj: error: No input file\n");
        expect(result.exitCode).to.equal(1);
    });

    it("should generate an error if more than one input file is given", () =>
    {
        const result = run(["foo.js", "bar.js"]);

        expect(result.output).to.equal("acorn-objj: error: Only one file may be parsed at a time\n");
        expect(result.exitCode).to.equal(1);
    });

    it("should read from stdin if the input file is '-'", () =>
    {
        const fd = fs.openSync(path.join(dir, "compact.js"), "r"),
            stream = fs.createReadStream("", { fd });

        expect(run(["-"], { stdin: stream }).output)
            .to.equal(readFixture("cli/pretty.json"));
    });
});
<commit_msg>Forgot Windows paths could have : in them<commit_after>"use strict";

const
    cli = require("../lib/cli"),
    expect = require("code").expect,
    fs = require("fs"),
    path = require("path"),
    utils = require("./lib/test-utils.js");

const  // jscs: ignore requireMultipleVarDecl
    readFixture = utils.readFixture,
    run = utils.run;

/* eslint-disable max-len */

describe("cli", () =>
{
    const dir = "test/fixtures/cli";

    let executable;

    before(() => { executable = cli.getEnvironment().executable; });

    it("should generate an error if the file does not exist", () =>
    {
        const result = run(["--no-color", "foo.j"]);

        expect(result.output).to.match(/^acorn-objj: error: ENOENT: no such file or directory, open '.+'/);
        expect(result.exitCode).to.equal(1);
    });

    it("should generate an error if there is #! without --allow-hash-bang", () =>
    {
        const result = run(["--no-color", path.join(dir, "hash-bang.js")]);

        expect(result.output).to.equal(readFixture("cli/hash-bang.txt", true));
        expect(result.exitCode).to.equal(1);
    });

    it("should generate a stack trace with --stack-trace for thrown Error", () =>
    {
        const result = run(["--no-color", "--stack-trace", "foo.j"]);

        expect(result.output).to.match(/^acorn-objj: error: ENOENT: no such file or directory, open '.+?'\n\nError: ENOENT: no such file or directory, open '.+?'\n\s+at Error \(native\)/);
        expect(result.exitCode).to.equal(1);
    });

    it("should generate a stack trace with --stack-trace for thrown SyntaxError", () =>
    {
        const result = run(["--ecma", "5", "--stack-trace", "--no-color", path.join(dir, "ecma.js")]);

        expect(result.output).to.match(/^(.*\n)+1 error generated\.\n\nSyntaxError: Expected ';' after expression\n\s+at Parser.objj_semicolon \(.+?\n/g);
        expect(result.exitCode).to.equal(1);
    });

    it("should not generate an error if there is #! with --allow-hash-bang", () =>
    {
        expect(run(["--allow-hash-bang", path.join(dir, "hash-bang.js")]).output)
            .to.equal(readFixture("cli/hash-bang.json"));
    });

    it("should generate pretty-printed JSON by default", () =>
    {
        expect(run([path.join(dir, "compact.js")]).output)
            .to.equal(readFixture("cli/pretty.json"));
    });

    it("should generate compact JSON with --compact", () =>
    {
        expect(run(["--compact", path.join(dir, "compact.js")]).output)
            .to.equal(readFixture("cli/compact.json"));
    });

    it("should not parse ECMAScript 6 with --ecma 5", () =>
    {
        const result = run(["--ecma", "5", path.join(dir, "ecma.js")]);

        expect(result.output).to.equal(readFixture("cli/ecma.txt"));
        expect(result.exitCode).to.equal(1);
    });

    it("should parse EMCAScript 6 by default", () =>
    {
        expect(run([path.join(dir, "ecma.js")]).output)
            .to.equal(readFixture("cli/ecma.json"));
    });

    it("should show help with --help", () =>
    {
        const prefix =
            `${cli.getVersionString()} \nUsage: ${executable} [options] file\n\nParses a file and outputs an AST.`;

        expect(run(["--help"]).output).to.startWith(prefix);
    });

    it("should generate location data with --locations", () =>
    {
        expect(run(["--locations", path.join(dir, "compact.js")]).output)
            .to.equal(readFixture("cli/locations.json"));
    });

    it("should fail on Objective-J code with --no-objj", () =>
    {
        const result = run(["--no-objj", path.join(dir, "objj.j")]);

        expect(result.output).to.equal(readFixture("cli/objj.txt"));
        expect(result.exitCode).to.equal(1);
    });

    it("should not recognize Objective-J keywords with --no-objj", () =>
    {
        expect(run(["--no-objj", path.join(dir, "no-objj.js")]).output)
            .to.equal(readFixture("cli/no-objj.json"));
    });

    it("should not recognize objj keywords with --no-objj", () =>
    {
        run(["--no-objj", path.join(dir, "no-objj.js")]);
    });

    it("should not generate any output with --silent", () =>
    {
        let result = run(["--silent", path.join(dir, "compact.js")]);

        expect(result.exitCode).to.equal(0);
        expect(result.output).to.be.empty();

        result = run(["--ecma", "5", "--silent", path.join(dir, "ecma.js")]);

        expect(result.exitCode).to.equal(1);
        expect(result.output).to.be.empty();
    });

    it("should generate an error for missing semicolons with --strict-semicolons", () =>
    {
        const result = run(["--strict-semicolons", path.join(dir, "strict-semicolons.js")]);

        expect(result.output).to.equal(readFixture("cli/strict-semicolons.txt"));
        expect(result.exitCode).to.equal(1);
    });

    it("should generate an error for reserved words with --module", () =>
    {
        // --module forces strict mode
        const result = run(["--module", "--ecma", "5", path.join(dir, "module.js")]);

        expect(result.output).to.equal(readFixture("cli/module.txt"));
        expect(result.exitCode).to.equal(1);
    });

    it("should use an absolute file path in error messages if the path is not within the cwd", () =>
    {
        const cwd = process.cwd();

        process.chdir("lib");

        // --module forces strict mode
        const result = run(["--module", "--ecma", "5", path.join("..", dir, "module.js")]);

        process.chdir(cwd);

        // Extract the file path
        let file = result.output.trim(),
            pos = file.indexOf(path.join(dir, "module.js") + ":");

        if (pos > 0)
            file = file.substr(0, pos);
        else
            file = "";

        expect(path.isAbsolute(file)).to.be.true();
    });

    it("should show the executable name, version and acorn version with --version", () =>
    {
        expect(run(["--version"]).output).to.equal(cli.getVersionString() + "\n");
    });

    it("should generate an error if no input file is given", () =>
    {
        const result = run([]);

        expect(result.output).to.equal("acorn-objj: error: No input file\n");
        expect(result.exitCode).to.equal(1);
    });

    it("should generate an error if more than one input file is given", () =>
    {
        const result = run(["foo.js", "bar.js"]);

        expect(result.output).to.equal("acorn-objj: error: Only one file may be parsed at a time\n");
        expect(result.exitCode).to.equal(1);
    });

    it("should read from stdin if the input file is '-'", () =>
    {
        const fd = fs.openSync(path.join(dir, "compact.js"), "r"),
            stream = fs.createReadStream("", { fd });

        expect(run(["-"], { stdin: stream }).output)
            .to.equal(readFixture("cli/pretty.json"));
    });
});
<|endoftext|>


<commit_before>// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

require("chromedriver");
const {Builder, By, until, logging, Capabilities}
  = require('selenium-webdriver');
var chrome = require('selenium-webdriver/chrome');
var assert = require("assert");
var fs = require("fs");
var os = require("os");

var extensionData = fs.readFileSync(process.env.TEST_EXTENSION_CRX)
  .toString("base64");
var chromeLog = os.tmpdir() + "/chrome.log";
var chromedriverLog = os.tmpdir() + "/chromedriver.log";

logging.getLogger("").setLevel(logging.Level.DEBUG);
logging.installConsoleHandler();

chrome.setDefaultService(new chrome.ServiceBuilder()
  .loggingTo(chromedriverLog)
  .enableVerboseLogging()
  .build());

function makeExtensionUrl(page) {
  var url = []
  url.push(
    "chrome-extension://",
    process.env.TEST_EXTENSION_ID,
    "/",
    page,
  );
  return url.join("");
}

function printLogs(entries) {
  var i;
  for (i = 0; i < entries.length; i++) {
    console.log(entries[i].message);
  }
}

describe('End-to-end Tests For SSH Agent', function () {
  let driver
  this.timeout(10000);

  beforeEach(async function() {
    logPrefs = new logging.Preferences();
    logPrefs.setLevel(logging.Type.BROWSER, logging.Level.DEBUG);
    driver = await new Builder()
      .setChromeOptions(new chrome.Options()
        .addExtensions(extensionData)
        .setChromeLogFile(chromeLog))
      .withCapabilities(new Capabilities().setLoggingPrefs(logPrefs))
      .forBrowser('chrome')
      .build();
  })

  it('successfully manages keys via the Options UI', async function() {
    await driver.get(makeExtensionUrl("html/options.html?test"));

    fail = await driver.wait(until.elementLocated(By.id('failureCount')))
      .getText();
    body = await driver.wait(until.elementLocated(By.id('body'))).getText();
    assert.equal(parseInt(fail), 0, body);
  })

  afterEach(async function() {
    if (this.currentTest.state === 'failed' && fs.existsSync(chromedriverLog)) {
      console.log("**** chromedriver log ****\n" + fs.readFileSync(chromedriverLog))
    }
    if (this.currentTest.state === 'failed' && fs.existsSync(chromeLog)) {
      console.log("**** chrome log ****\n" + fs.readFileSync(chromeLog))
    }
    printLogs(await driver.manage().logs().get(logging.Type.BROWSER));
    await driver.quit();
  })
})
<commit_msg>Be more lenient in when we show logs; only suppress on pass<commit_after>// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

require("chromedriver");
const {Builder, By, until, logging, Capabilities}
  = require('selenium-webdriver');
var chrome = require('selenium-webdriver/chrome');
var assert = require("assert");
var fs = require("fs");
var os = require("os");

var extensionData = fs.readFileSync(process.env.TEST_EXTENSION_CRX)
  .toString("base64");
var chromeLog = os.tmpdir() + "/chrome.log";
var chromedriverLog = os.tmpdir() + "/chromedriver.log";

logging.getLogger("").setLevel(logging.Level.DEBUG);
logging.installConsoleHandler();

chrome.setDefaultService(new chrome.ServiceBuilder()
  .loggingTo(chromedriverLog)
  .enableVerboseLogging()
  .build());

function makeExtensionUrl(page) {
  var url = []
  url.push(
    "chrome-extension://",
    process.env.TEST_EXTENSION_ID,
    "/",
    page,
  );
  return url.join("");
}

function printLogs(entries) {
  var i;
  for (i = 0; i < entries.length; i++) {
    console.log(entries[i].message);
  }
}

describe('End-to-end Tests For SSH Agent', function () {
  let driver
  this.timeout(10000);

  beforeEach(async function() {
    logPrefs = new logging.Preferences();
    logPrefs.setLevel(logging.Type.BROWSER, logging.Level.DEBUG);
    driver = await new Builder()
      .setChromeOptions(new chrome.Options()
        .addExtensions(extensionData)
        .setChromeLogFile(chromeLog))
      .withCapabilities(new Capabilities().setLoggingPrefs(logPrefs))
      .forBrowser('chrome')
      .build();
  })

  it('successfully manages keys via the Options UI', async function() {
    await driver.get(makeExtensionUrl("html/options.html?test"));

    fail = await driver.wait(until.elementLocated(By.id('failureCount')))
      .getText();
    body = await driver.wait(until.elementLocated(By.id('body'))).getText();
    assert.equal(parseInt(fail), 0, body);
  })

  afterEach(async function() {
    if (this.currentTest.state !== 'passed' && fs.existsSync(chromedriverLog)) {
      console.log("**** chromedriver log ****\n" + fs.readFileSync(chromedriverLog))
    }
    if (this.currentTest.state !== 'passed' && fs.existsSync(chromeLog)) {
      console.log("**** chrome log ****\n" + fs.readFileSync(chromeLog))
    }
    printLogs(await driver.manage().logs().get(logging.Type.BROWSER));
    await driver.quit();
  })
})
<|endoftext|>


<commit_before>/*global describe*/
/*global it*/
var expect = require('chai').expect,
    $ = require('jquery'),
    foo = require('../src/js/foo');

describe('foo module', function(){
  it ('should get right value', function() {

    expect(foo.hello()).to.equal('Hello!');

  });
});

describe('DOM module', function(){
  it ('should get right value', function() {

    var type;

    type = typeof window;
    expect(type).to.equal('object');

    type = typeof $;
    expect(type).to.equal('function');

  });
});
<commit_msg>Fix test/foo.js<commit_after>/*global describe*/
/*global it*/
var expect = require('chai').expect,
    foo = require('../src/js/foo');

describe('foo module', function(){
  it ('should get right value', function() {

    expect(foo.hello()).to.equal('Hello!');

  });
});

describe('DOM module', function(){
  it ('should get right value', function() {

    var type;

    type = typeof window;
    expect(type).to.equal('object');

  });
});
<|endoftext|>