{"size": 1795, "ext": "js", "max_stars_repo_path": "test/test-bundle.js", "max_stars_repo_name": "proxv/jsbundle", "max_stars_repo_stars_event_min_datetime": "2015-05-27T07:05:28.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-31T02:59:05.000Z", "max_issues_repo_path": "test/test-bundle.js", "max_issues_repo_name": "proxv/jsbundle", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/test-bundle.js", "max_forks_repo_name": "proxv/jsbundle", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 5, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.7910447761, "max_line_length": 80, "alphanum_fraction": 0.5821727019}
var vows = require('vows');
var assert = require('assert');
var path = require('path');
var vm = require('vm');
var jsbundle = require('../jsbundle');
var _ = require('underscore');
var BUNDLE_DIR = __dirname + '/fixtures/';

function execute(code, env) {
  env.global = env;
  try {
    vm.runInNewContext(code, env);
  } catch (e) {
    console.error(code);
    assert.equal(e.message, void 0);
  }
}

vows.describe('bundle').addBatch({
  "no mangled names": {
    topic: jsbundle.compileBundle(BUNDLE_DIR),

    "find all modules": function(bundled) {
      assert.equal(typeof bundled, 'string');
      assert.match(bundled, /moduleFns\["[^"]+abc.js"\]/);
      assert.match(bundled, /moduleFns\["[^"]+def.js"\]/);
      assert.match(bundled, /moduleFns\["[^"]+ghi.js"\]/);
      assert.match(bundled, /moduleFns\["[^"]+underscore.js"\]/);
    },

    "execute bundled code": function(bundled) {
      var env = {
        console: {
          log: function() {}
        }
      };
      assert.equal(typeof bundled, 'string');
      execute(bundled, env);
      _.each(env.output, function(outputLine) {
        assert.match(outputLine, /^assertion succeeded:|^all \d+ tests passed/);
      });
    }
  },

  "mangled names": {
    topic: function() {
      var config = jsbundle.parseConfig(__dirname + '/fixtures/');
      config.mangleNames = true;
      return (new jsbundle.Bundle(config)).compile();
    },

    "execute bundled code": function(bundled) {
      var env = {
        console: {
          log: function() {}
        }
      };
      assert.equal(typeof bundled, 'string');
      execute(bundled, env);
      _.each(env.output, function(outputLine) {
        assert.match(outputLine, /^assertion succeeded:|^all \d+ tests passed/);
      });
    }
  }
}).export(module);

