{"size": 1291, "ext": "js", "max_stars_repo_path": "test/unit/fh3/app/test_undeploy.js", "max_stars_repo_name": "alanmoran/fh-fhc", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/unit/fh3/app/test_undeploy.js", "max_issues_repo_name": "alanmoran/fh-fhc", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/unit/fh3/app/test_undeploy.js", "max_forks_repo_name": "alanmoran/fh-fhc", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.4680851064, "max_line_length": 75, "alphanum_fraction": 0.6165762974}
var undeploy = require('cmd/fh3/app/undeploy.js');
var assert = require('assert');
var url = require('url');

module.exports = {
  'test app undeploy command happy path': function (done) {
    var params = {
      env: "dev",
      domain: "testing",
      id: "j7hslnrb257zkr4qzjndoqkl"
    };

    undeploy.preCmd(params, function (err, parsed) {
      // If embed flag is not set we must send false
      assert.equal(err, null);
      assert.equal(parsed.embed, false);

      var queryUrl = undeploy.url(parsed);
      var urlParts = url.parse(queryUrl);

      // Make sure that the URL is parseable
      assert.equal(typeof urlParts.pathname, 'string');

      // Make sure it calls the `deleteapp` endpoint
      assert.equal(urlParts.pathname.indexOf('api/v2/mbaas/deleteapp'), 0);
      assert.equal(urlParts.pathname.indexOf(params.domain) > 0, true);

      done();
    });
  },

  'test app undeploy command with embed flag set': function (done) {
    var params = {
      env: "dev",
      domain: "testing",
      embed: '',
      id: "j7hslnrb257zkr4qzjndoqkl"
    };

    undeploy.preCmd(params, function (err, parsed) {
      assert.equal(err, null);
      // If embed flag is not set we must send false
      assert.equal(parsed.embed, true);
      done();
    });
  }
};