<commit_before>var tap = require("tap")
  , test = tap.test
  , plan = tap.plan
  , account
  , creature
  , resource;

//
// Utility testing functions
//
function isEmpty(o){
  for(var i in o){
      if(o.hasOwnProperty(i)){
          return false;
      }
  }
  return true;
}

//
// Testing metadata
//
var testDatasource = "memory";

test("load resource module", function (t) {
  resource = require('../');
  t.ok(resource, "object loaded");
  t.end();
});

//
// A simple data object to use for testing resource properties of type "object"
//
var data = {
  "foo": "bar",
  "abc": 123,
  "data" : {
    "prop1" : "foo",
    "prop2" : "bar"
  }
},
items = [
  { "foo": "bar" },
  { "abc": 123 }
];

test("define creature resource - with datasource config", function (t) {
  creature = resource.define('creature', { config: { datasource: testDatasource }});

  creature.property('life', {
    "type": "number"
  });

  creature.property('metadata', {
    "type": "object"
  });

  creature.property('items', {
    "type": "array",
    "default": []
  });

  creature.property('itemsNoDefault', {
    "type": "array"
  });

  creature.property('moreItems', {
    "type": "array",
    "default": ['a', 'b', 'c']
  });

  t.type(creature.config, 'object', 'configuration defined - creature.config is object');
  t.equal(testDatasource, creature.config.datasource, ('configuration defined - creature.config.datasource == "' + testDatasource + '"'));

  t.type(creature.methods, 'object', 'methods defined - creature.methods is object');
  t.type(creature.methods.create, 'function', 'methods defined - methods.create is function');
  t.type(creature.methods.get, 'function', 'methods defined - methods.get is function');
  t.type(creature.methods.find, 'function', 'methods defined - methods.find is function');
  t.type(creature.methods.destroy, 'function', 'methods defined - methods.destroy is function');

  t.type(creature.create, 'function', 'methods hoisted - creature.create is function');
  t.type(creature.get, 'function', 'methods hoisted - creature.get is function');
  t.type(creature.find, 'function', 'methods hoisted - creature.find is function');
  t.type(creature.destroy, 'function', 'methods hoisted - creature.destroy is function');

  t.end();
});

test("define account resource - with datasource config", function (t) {
  account = resource.define('account', { config: { datasource: testDatasource }});

  account.property('name', {
    "type": "string"
  });

  account.property('email', {
    "type": "string"
  });

  t.type(account.config, 'object', 'configuration defined - account.config is object');
  t.equal(testDatasource, account.config.datasource, ('configuration defined - account.config.datasource == "' + testDatasource + '"'));

  t.end();
});

test("define space resource - with datasource config", function(t) {
  space = resource.define('space', { config: { datasource: testDatasource }});

  space.property('id', {
    description: 'the name of the space',
    type: 'string',
    required: true
  });

  space.property('resources', {
    description: 'the resources present in this space',
    type: 'object',
    default: {}
  });

  space.property('metadata', {
    description: 'additional metadata',
    type: 'object',
    default: data
  });

  t.type(space.config, 'object', 'configuration defined - space.config is object');
  t.equal(testDatasource, space.config.datasource, ('configuration defined - space.config.datasource == "' + testDatasource + '"'));

  t.type(space.methods, 'object', 'methods defined - space.methods is object');
  t.type(space.methods.create, 'function', 'methods defined - methods.create is function');
  t.type(space.methods.get, 'function', 'methods defined - methods.get is function');
  t.type(space.methods.find, 'function', 'methods defined - methods.find is function');
  t.type(space.methods.destroy, 'function', 'methods defined - methods.destroy is function');

  t.type(space.create, 'function', 'methods hoisted - space.create is function');
  t.type(space.get, 'function', 'methods hoisted - space.get is function');
  t.type(space.find, 'function', 'methods hoisted - space.find is function');
  t.type(space.destroy, 'function', 'methods hoisted - space.destroy is function');

  t.end();
});

test("executing creature.all", function (t) {
  creature.all(function (err, result) {
    t.equal(result.length, 0, 'no creatures');
    t.end();
  });
});

test("executing creature.create", function (t) {
  creature.create({
    id: 'bobby',
    metadata: data,
    items: items // array property currently has serialization issue
  }, function (err, result) {
    t.type(err, 'null', 'no error');
    t.type(result, 'object', 'result is object');
    t.equal(result.id, 'bobby', 'id is correct');
    t.type(result.metadata, 'object', 'metadata is object');
    t.equal(result.moreItems[0], 'a', 'default array item set');
    t.equal(result.metadata.foo, 'bar');
    t.equal(result.metadata.abc, 123);
    t.equal(result.metadata.data.prop1, 'foo');
    t.equal(result.metadata.data.prop2, 'bar');
    t.type(result.items, Array, 'items is array');
    t.type(result.itemsNoDefault, Array, 'items is array');
    t.end();
  });
});

test("executing creature.create - when already created", function (t) {
  creature.create({
    id: 'bobby',
    metadata: data,
    items: items // array property current has serialization issue
  }, function (err, result) {
    t.type(err, 'object', 'an error');
    t.equal(result.id, 'bobby', 'bobby already exists');
    t.equal(err.message, 'bobby already exists', 'bobby already exists');
    t.end();
  });
});

test("executing creature.get", function (t) {
  creature.get('bobby', function (err, result) {
    t.type(err, 'null', 'no error');
    t.type(result, 'object', 'result is object');
    t.type(result.metadata, 'object', 'metadata is object');
    t.equal(result.metadata.foo, 'bar');
    t.equal(result.metadata.abc, 123);
    t.equal(result.metadata.data.prop1, 'foo');
    t.equal(result.metadata.data.prop2, 'bar');
    t.type(result.items, Array, 'items is array');
    t.end();
  });
});

test("executing creature.all", function (t) {
  creature.all(function (err, result) {
    t.equal(result.length, 1, 'one creature');
    t.end();
  });
});

test("executing creature.create - with bad input", function (t) {
  creature.create({ id: 'larry', life: "abc" }, function (err, result) {
    t.type(err, 'object', 'continues correct validation error - err is object');
    t.type(err.errors, 'object', 'continues correct validation error - err.errors is object');
    t.equal(err.errors.length, 1, 'continues correct validation error - one validation error');
    t.equal(err.errors[0].attribute, 'type', 'continues correct validation error - attribute == "type"');
    t.equal(err.errors[0].property, 'life', 'continues correct validation error - property == "life"');
    t.equal(err.errors[0].expected, 'number', 'continues correct validation error - expected == "number"');
    t.equal(err.errors[0].actual, 'string', 'continues correct validation error - actual == "string"');
    t.end();
  });
});

test("executing creature.get", function (t) {
  creature.get('larry', function (err, result) {
    t.type(err, 'object', 'could not find larry');
    t.end();
  });
});

test("executing creature.all", function (t) {
  creature.all(function (err, result) {
    t.equal(result.length, 1);
    t.end();
  });
});

test("executing creature.update", function (t) {
  creature.update({ id: 'bobby', life: 9999 , items: items }, function (err, result) {
    t.type(err, 'null', 'updated bobby - no error');
    t.type(result, 'object', 'updated bobby - result is object');
    t.equal(result.life, 9999, 'updated bobby - result.life == 9999');
    t.type(result.items, Array, 'items is array');
    t.end();
  });
});

test("executing create.update - when creature does not exist", function (t) {
  creature.update({ id: 'larry' }, function (err, result) {
    t.type(err, 'object', 'an error');
    t.equal(!result, true, 'no result');
    t.equal(err.message, 'larry not found', 'could not find larry');
    t.end();
  });
});

test("executing creature.updateOrCreate - with a new id", function (t) {
  creature.updateOrCreate({ id: 'larry', items: items  }, function (err, result) {
    t.type(err, 'null', 'created larry - no error');
    t.type(result, 'object', 'created larry - result is object');
    t.type(result.items, Array, 'items is array');
    t.end();
  });
});

test("executing create.updateOrCreate = with existing id", function (t) {
  creature.updateOrCreate({ id: 'bobby', life: 5, items: items  }, function (err, result) {
    t.type(err, 'null', 'updated bobby - no error');
    t.type(result, 'object', 'updated bobby - result is object');
    t.equal(result.life, 5, 'updated bobby - result.life == 5');
    t.type(result.items, Array, 'items is array');
    t.end();
  });
});

test("executing account.create with same id as a creature", function (t) {
  account.create({
    id: 'bobby'
  }, function (err, result) {
    t.type(err, 'null', 'no error');
    t.type(result, 'object', 'result is object');
    t.equal(result.id, 'bobby', 'id is correct');
    t.end();
  });
});

test("creating a space", function(t) {
  space.create({id: "big"}, function (err, result) {
    t.type(err, 'null', 'no error');
    t.type(result, 'object', 'space instance is object');
    t.type(result.id, 'string', 'space instance id is string');
    t.equal(result.id, 'big', 'space instance id is correct');
    t.type(result.resources, 'object', 'space instance resources is object');
    t.equal(isEmpty(result.resources), true, 'space instance resources is empty');
    t.end();
  });
});

test("add creature to space", function(t) {
  space.get('big', function(err, _space) {
    t.type(err, 'null', 'no error');
    _space.resources['creature'] = ['bobby'];
    _space.metadata.foo = "tar";
    _space.save(function (err, result) {
      t.type(err, 'null', 'no error');
      t.type(result, 'object', 'space instance is object');
      t.type(result.id, 'string', 'space instance id is string');
      t.equal(result.id, 'big', 'space instance id is correct');
      t.type(result.resources, 'object', 'space instance resources is object');
      t.equal(result.metadata.foo, 'tar', 'metadata property saved');
      t.equal(result.resources.creature.length, 1, 'space instance resources is correct');
      t.equal(result.resources.creature[0], 'bobby', 'space instance resources is correct');
      t.end();
    });
  });
});

test("create another new space", function(t) {
  space.create({id: "big2"}, function (err, result) {
    t.type(err, 'null', 'no error');
    t.type(result, 'object', 'space instance is object');
    t.type(result.id, 'string', 'space instance id is string');
    t.equal(result.id, 'big2', 'space instance id is correct');
    t.type(result.resources, 'object', 'space instance resources is object');
    t.equal(result.metadata.foo, 'bar', 'default metadata preserved');
    t.equal(isEmpty(result.resources), true, 'space instance resources is empty');
    t.end();
  });
});

test("executing space.destroy", function (t) {
  t.plan(2);
  space.destroy('big', function (err, result) {
    t.type(result, 'null', 'destroyed space big');
  });
  space.destroy('big2', function (err, result) {
    t.type(result, 'null', 'destroyed space big2');
  });
});

test("executing space.all", function (t) {
  space.all(function (err, result) {
    t.equal(result.length, 0, 'no spaces');
    t.end();
  });
});

test("executing creature.destroy", function (t) {
  t.plan(2);
  creature.destroy('bobby', function (err, result) {
    t.type(result, 'null', 'destroyed bobby');
  });
  creature.destroy('larry', function (err, result) {
    t.type(result, 'null', 'destroyed larry');
  });
});

test("executing account.destroy", function (t) {
  t.plan(1);
  account.destroy('bobby', function (err, result) {
    t.type(result, 'null', 'destroyed bobby');
  });
});

test("executing creature.get", function (t) {
  creature.get('bobby', function (err, result) {
    t.type(err, 'object', 'could not find bobby');
    t.end();
  });
});

test("executing creature.all", function (t) {
  creature.all(function (err, result) {
    t.equal(result.length, 0, 'no creatures');
    t.end();
  });
});

/*
test("persist creature to couchdb", function (t) {
  creature.persist({ name: "big-test", type: "couchdb", options: { cache: false }});
  t.end();
});
*/<commit_msg>[persist] [test] added test for creature.create without id<commit_after>var tap = require("tap")
  , test = tap.test
  , plan = tap.plan
  , account
  , creature
  , resource;

//
// Utility testing functions
//
function isEmpty(o){
  for(var i in o){
      if(o.hasOwnProperty(i)){
          return false;
      }
  }
  return true;
}

//
// Testing metadata
//
var testDatasource = "memory";

test("load resource module", function (t) {
  resource = require('../');
  t.ok(resource, "object loaded");
  t.end();
});

//
// A simple data object to use for testing resource properties of type "object"
//
var data = {
  "foo": "bar",
  "abc": 123,
  "data" : {
    "prop1" : "foo",
    "prop2" : "bar"
  }
},
items = [
  { "foo": "bar" },
  { "abc": 123 }
];

test("define creature resource - with datasource config", function (t) {
  creature = resource.define('creature', { config: { datasource: testDatasource }});

  creature.property('life', {
    "type": "number"
  });

  creature.property('metadata', {
    "type": "object"
  });

  creature.property('items', {
    "type": "array",
    "default": []
  });

  creature.property('itemsNoDefault', {
    "type": "array"
  });

  creature.property('moreItems', {
    "type": "array",
    "default": ['a', 'b', 'c']
  });

  t.type(creature.config, 'object', 'configuration defined - creature.config is object');
  t.equal(testDatasource, creature.config.datasource, ('configuration defined - creature.config.datasource == "' + testDatasource + '"'));

  t.type(creature.methods, 'object', 'methods defined - creature.methods is object');
  t.type(creature.methods.create, 'function', 'methods defined - methods.create is function');
  t.type(creature.methods.get, 'function', 'methods defined - methods.get is function');
  t.type(creature.methods.find, 'function', 'methods defined - methods.find is function');
  t.type(creature.methods.destroy, 'function', 'methods defined - methods.destroy is function');

  t.type(creature.create, 'function', 'methods hoisted - creature.create is function');
  t.type(creature.get, 'function', 'methods hoisted - creature.get is function');
  t.type(creature.find, 'function', 'methods hoisted - creature.find is function');
  t.type(creature.destroy, 'function', 'methods hoisted - creature.destroy is function');

  t.end();
});

test("define account resource - with datasource config", function (t) {
  account = resource.define('account', { config: { datasource: testDatasource }});

  account.property('name', {
    "type": "string"
  });

  account.property('email', {
    "type": "string"
  });

  t.type(account.config, 'object', 'configuration defined - account.config is object');
  t.equal(testDatasource, account.config.datasource, ('configuration defined - account.config.datasource == "' + testDatasource + '"'));

  t.end();
});

test("define space resource - with datasource config", function(t) {
  space = resource.define('space', { config: { datasource: testDatasource }});

  space.property('id', {
    description: 'the name of the space',
    type: 'string',
    required: true
  });

  space.property('resources', {
    description: 'the resources present in this space',
    type: 'object',
    default: {}
  });

  space.property('metadata', {
    description: 'additional metadata',
    type: 'object',
    default: data
  });

  t.type(space.config, 'object', 'configuration defined - space.config is object');
  t.equal(testDatasource, space.config.datasource, ('configuration defined - space.config.datasource == "' + testDatasource + '"'));

  t.type(space.methods, 'object', 'methods defined - space.methods is object');
  t.type(space.methods.create, 'function', 'methods defined - methods.create is function');
  t.type(space.methods.get, 'function', 'methods defined - methods.get is function');
  t.type(space.methods.find, 'function', 'methods defined - methods.find is function');
  t.type(space.methods.destroy, 'function', 'methods defined - methods.destroy is function');

  t.type(space.create, 'function', 'methods hoisted - space.create is function');
  t.type(space.get, 'function', 'methods hoisted - space.get is function');
  t.type(space.find, 'function', 'methods hoisted - space.find is function');
  t.type(space.destroy, 'function', 'methods hoisted - space.destroy is function');

  t.end();
});

test("executing creature.all", function (t) {
  creature.all(function (err, result) {
    t.equal(result.length, 0, 'no creatures');
    t.end();
  });
});

test("executing creature.create", function (t) {
  creature.create({
    id: 'bobby',
    metadata: data,
    items: items // array property currently has serialization issue
  }, function (err, result) {
    t.type(err, 'null', 'no error');
    t.type(result, 'object', 'result is object');
    t.equal(result.id, 'bobby', 'id is correct');
    t.type(result.metadata, 'object', 'metadata is object');
    t.equal(result.moreItems[0], 'a', 'default array item set');
    t.equal(result.metadata.foo, 'bar');
    t.equal(result.metadata.abc, 123);
    t.equal(result.metadata.data.prop1, 'foo');
    t.equal(result.metadata.data.prop2, 'bar');
    t.type(result.items, Array, 'items is array');
    t.type(result.itemsNoDefault, Array, 'items is array');
    t.end();
  });
});

test("executing creature.create - when already created", function (t) {
  creature.create({
    id: 'bobby',
    metadata: data,
    items: items // array property current has serialization issue
  }, function (err, result) {
    t.type(err, 'object', 'an error');
    t.equal(result.id, 'bobby', 'bobby already exists');
    t.equal(err.message, 'bobby already exists', 'bobby already exists');
    t.end();
  });
});

test("executing creature.create - without an id", function (t) {
  creature.create({
    metadata: data,
    items: items // array property currently has serialization issue
  }, function (err, result) {
    t.type(err, 'null', 'no error');
    t.type(result, 'object', 'result is object');
    t.type(result.metadata, 'object', 'metadata is object');
    t.equal(result.moreItems[0], 'a', 'default array item set');
    t.equal(result.metadata.foo, 'bar');
    t.equal(result.metadata.abc, 123);
    t.equal(result.metadata.data.prop1, 'foo');
    t.equal(result.metadata.data.prop2, 'bar');
    t.type(result.items, Array, 'items is array');
    t.type(result.itemsNoDefault, Array, 'items is array');
    t.end();
  });
})

test("executing creature.get", function (t) {
  creature.get('bobby', function (err, result) {
    t.type(err, 'null', 'no error');
    t.type(result, 'object', 'result is object');
    t.type(result.metadata, 'object', 'metadata is object');
    t.equal(result.metadata.foo, 'bar');
    t.equal(result.metadata.abc, 123);
    t.equal(result.metadata.data.prop1, 'foo');
    t.equal(result.metadata.data.prop2, 'bar');
    t.type(result.items, Array, 'items is array');
    t.end();
  });
});

test("executing creature.all", function (t) {
  creature.all(function (err, result) {
    t.equal(result.length, 2, 'one creature');
    t.end();
  });
});

test("executing creature.create - with bad input", function (t) {
  creature.create({ id: 'larry', life: "abc" }, function (err, result) {
    t.type(err, 'object', 'continues correct validation error - err is object');
    t.type(err.errors, 'object', 'continues correct validation error - err.errors is object');
    t.equal(err.errors.length, 1, 'continues correct validation error - one validation error');
    t.equal(err.errors[0].attribute, 'type', 'continues correct validation error - attribute == "type"');
    t.equal(err.errors[0].property, 'life', 'continues correct validation error - property == "life"');
    t.equal(err.errors[0].expected, 'number', 'continues correct validation error - expected == "number"');
    t.equal(err.errors[0].actual, 'string', 'continues correct validation error - actual == "string"');
    t.end();
  });
});

test("executing creature.get", function (t) {
  creature.get('larry', function (err, result) {
    t.type(err, 'object', 'could not find larry');
    t.end();
  });
});

test("executing creature.all", function (t) {
  creature.all(function (err, result) {
    t.equal(result.length, 2);
    t.end();
  });
});

test("executing creature.update", function (t) {
  creature.update({ id: 'bobby', life: 9999 , items: items }, function (err, result) {
    t.type(err, 'null', 'updated bobby - no error');
    t.type(result, 'object', 'updated bobby - result is object');
    t.equal(result.life, 9999, 'updated bobby - result.life == 9999');
    t.type(result.items, Array, 'items is array');
    t.end();
  });
});

test("executing create.update - when creature does not exist", function (t) {
  creature.update({ id: 'larry' }, function (err, result) {
    t.type(err, 'object', 'an error');
    t.equal(!result, true, 'no result');
    t.equal(err.message, 'larry not found', 'could not find larry');
    t.end();
  });
});

test("executing creature.updateOrCreate - with a new id", function (t) {
  creature.updateOrCreate({ id: 'larry', items: items  }, function (err, result) {
    t.type(err, 'null', 'created larry - no error');
    t.type(result, 'object', 'created larry - result is object');
    t.type(result.items, Array, 'items is array');
    t.end();
  });
});

test("executing create.updateOrCreate = with existing id", function (t) {
  creature.updateOrCreate({ id: 'bobby', life: 5, items: items  }, function (err, result) {
    t.type(err, 'null', 'updated bobby - no error');
    t.type(result, 'object', 'updated bobby - result is object');
    t.equal(result.life, 5, 'updated bobby - result.life == 5');
    t.type(result.items, Array, 'items is array');
    t.end();
  });
});

test("executing account.create with same id as a creature", function (t) {
  account.create({
    id: 'bobby'
  }, function (err, result) {
    t.type(err, 'null', 'no error');
    t.type(result, 'object', 'result is object');
    t.equal(result.id, 'bobby', 'id is correct');
    t.end();
  });
});

test("creating a space", function(t) {
  space.create({id: "big"}, function (err, result) {
    t.type(err, 'null', 'no error');
    t.type(result, 'object', 'space instance is object');
    t.type(result.id, 'string', 'space instance id is string');
    t.equal(result.id, 'big', 'space instance id is correct');
    t.type(result.resources, 'object', 'space instance resources is object');
    t.equal(isEmpty(result.resources), true, 'space instance resources is empty');
    t.end();
  });
});

test("add creature to space", function(t) {
  space.get('big', function(err, _space) {
    t.type(err, 'null', 'no error');
    _space.resources['creature'] = ['bobby'];
    _space.metadata.foo = "tar";
    _space.save(function (err, result) {
      t.type(err, 'null', 'no error');
      t.type(result, 'object', 'space instance is object');
      t.type(result.id, 'string', 'space instance id is string');
      t.equal(result.id, 'big', 'space instance id is correct');
      t.type(result.resources, 'object', 'space instance resources is object');
      t.equal(result.metadata.foo, 'tar', 'metadata property saved');
      t.equal(result.resources.creature.length, 1, 'space instance resources is correct');
      t.equal(result.resources.creature[0], 'bobby', 'space instance resources is correct');
      t.end();
    });
  });
});

test("create another new space", function(t) {
  space.create({id: "big2"}, function (err, result) {
    t.type(err, 'null', 'no error');
    t.type(result, 'object', 'space instance is object');
    t.type(result.id, 'string', 'space instance id is string');
    t.equal(result.id, 'big2', 'space instance id is correct');
    t.type(result.resources, 'object', 'space instance resources is object');
    t.equal(result.metadata.foo, 'bar', 'default metadata preserved');
    t.equal(isEmpty(result.resources), true, 'space instance resources is empty');
    t.end();
  });
});

test("executing space.destroy", function (t) {
  t.plan(2);
  space.destroy('big', function (err, result) {
    t.type(result, 'null', 'destroyed space big');
  });
  space.destroy('big2', function (err, result) {
    t.type(result, 'null', 'destroyed space big2');
  });
});

test("executing space.all", function (t) {
  space.all(function (err, result) {
    t.equal(result.length, 0, 'no spaces');
    t.end();
  });
});

test("executing creature.destroy", function (t) {
  t.plan(2);
  creature.destroy('bobby', function (err, result) {
    t.type(result, 'null', 'destroyed bobby');
  });
  creature.destroy('larry', function (err, result) {
    t.type(result, 'null', 'destroyed larry');
  });
});

test("executing account.destroy", function (t) {
  t.plan(1);
  account.destroy('bobby', function (err, result) {
    t.type(result, 'null', 'destroyed bobby');
  });
});

test("executing creature.get", function (t) {
  creature.get('bobby', function (err, result) {
    t.type(err, 'object', 'could not find bobby');
    t.end();
  });
});

test("executing creature.all", function (t) {
  creature.all(function (err, result) {
    t.equal(result.length, 1, 'no creatures');
    t.end();
  });
});

/*
test("persist creature to couchdb", function (t) {
  creature.persist({ name: "big-test", type: "couchdb", options: { cache: false }});
  t.end();
});
*/<|endoftext|>


<commit_before>const assert = require('chai').assert;
const Player = require('../lib/player');

describe('Player', () => {
  it('returns an object', () => {
    let player = new Player('name', 'color');
    assert.typeOf(player, 'object');
  });

  it('has a name', () => {
    let player = new Player('scott', 'color');
    assert.equal(player.name, 'scott');
  });

  it('has a color', () => {
    let player = new Player('name', 'blue');
    assert.equal(player.color, 'blue');
  });

  describe('addToScore', function() {
    it('increments the score', function() {
      var player = new Player('name', 'color');
      assert.equal(player.score, 0);
      player.addToScore();
      assert.equal(player.score, 1);
    });
  });

  describe('subtractFromScore', function() {
    it('decrements the score, does not go below zero', function() {
      var player = new Player('name', 'color');
      player.addToScore();
      assert.equal(player.score, 1);
      player.subtractFromScore();
      assert.equal(player.score, 0);
      player.subtractFromScore();
      assert.equal(player.score, 0);
    });
  });
});
<commit_msg>Refactor player test<commit_after>const assert = require('chai').assert;
const Player = require('../lib/player');

describe('Player', () => {
  it('returns an object', () => {
    let player = new Player('name', 'color');
    assert.typeOf(player, 'object');
  });

  it('has a name', () => {
    let player = new Player('scott', 'color');
    assert.equal(player.name, 'scott');
  });

  it('has a color', () => {
    let player = new Player('name', 'blue');
    assert.equal(player.color, 'blue');
  });

  describe('addToScore', function() {
    it('increments the score', function() {
      let player = new Player('name', 'color');
      assert.equal(player.score, 0);
      player.addToScore();
      assert.equal(player.score, 1);
    });
  });

  describe('subtractFromScore', function() {
    it('decrements the score, does not go below zero', function() {
      let player = new Player('name', 'color');
      player.addToScore();
      assert.equal(player.score, 1);
      player.subtractFromScore();
      assert.equal(player.score, 0);
      player.subtractFromScore();
      assert.equal(player.score, 0);
    });
  });
});
<|endoftext|>


<commit_before>var Webpack = require("webpack");
var Chai = require("chai");
var Config = require("../");

var expect = Chai.expect;

describe("Plugin:", function() {

    xdescribe("merge", function() {

        it("merges parameters, given an array for 'changes'", function() {

        });

        it("merges parameters at specific indexes, given a 'changes' object with numerical keys", function() {

        });

        it("throws if a 'changes' object is passed with non-numerical keys", function() {

        });

        it("throws if 'changes' isn't an object or array", function() {

        });

        it("merges a parameter at a specific index, given an 'index' integer", function() {

        });

        it("throws if 'index' isn't an integer", function() {

        });

    });

    xdescribe("set", function() {

        it("overwrites parameters, given an array for 'changes'", function() {

        });

        it("overwrites parameters at specific indexes, given a 'changes' object with numerical keys", function() {

        });

        it("throws if a 'changes' object is passed with non-numerical keys", function() {

        });

        it("overwrites a parameter at a specific index, given an 'index' integer", function() {

        });

        it("throws if 'index' isn't an integer", function() {

        });

    });

    xdescribe("get", function() {

        it("returns a clone of the internal plugin config", function() {

        });

    });

    xdescribe("resolve", function() {

    });

});
<commit_msg>Completed the implementation of the merge specs. - Added specs for the resolve function.<commit_after>var Webpack = require("webpack");
var Chai = require("chai");
var Types = require("./helpers/types");
var Config = require("../");

var expect = Chai.expect;
var types = Types();

describe("Plugin:", function() {

    xdescribe("merge", function() {

        it("merges parameters, given an array for 'changes'", function() {
            var plugin = Conifg.plugin({
                plugin: Webpack.definePlugin,
                parameters: [{a: 1}, 5, "test"]
            });

            plugin.merge([{b: 2}, 3, "merge"]);

            var actual = plugin.get();
            var expected = {
                plugin: Webpack.definePlugin,
                parameters: [{a: 1, b: 2}, 3, "merge"]
            };

            expect(actual).to.eql(expected);
        });

        it("merges parameters at specific indexes, given a 'changes' object with numerical keys", function() {
            var plugin = Config.plugin({
                plugin: Webpack.definePlugin,
                parameters: [{a: 1}, 5, "test"]
            });

            plugin.merge({
                0: {b: 2},
                2: {c: 3}
            });

            var actual = plugin.get();
            var expected = {
                plugin: Webpack.definePlugin,
                parameters: [{a: 1, b: 2}, 3, {c: 3}]
            };

            expect(actual).to.eql(expected);
        });

        it("throws if a 'changes' object is passed with non-numerical keys", function() {
            var error = "You must provide numerical keys when defining 'changes' as an object.";
            var plugin = Config.plugin({
                plugin: Webpack.definePlugin,
                parameters: [{a: 1}, 5, "test"]
            });

            Object.keys(types).forEach(function(type) {
                if (type == "int")
                    return;

                var key = types[type];
                var changes = {};

                changes[key] = "test";

                expect(function() {
                    plugin.merge(changes);
                }).to.throw(error);
            });
        });

        it("fills empty parameter indexes with 'undefined', given out of range keys", function() {
            var plugin = Config.plugin({
                plugin: Webpack.definePlugin,
                parameters: [{a: 1}, 5]
            });

            plugin.merge({
                0: {b: 2},
                4: "test"
            });

            var actual = plugin.get();
            var expected = {
                plugin: Webpack.definePlugin,
                parameters: [{a: 1}, 5, undefined, undefined, "test"]
            };

            expect(actual).to.eql(expected);
        });

        it("throws if 'changes' isn't an object or array", function() {
            var error = "You must provide either an object or array for 'changes'.";
            var plugin = Config.plugin({
                plugin: Webpack.definePlugin,
                parameters: [{a: 1}, 5, "test"]
            });

            Object.keys(types).forEach(function(type) {
                if (type == "object" || type == "array")
                    return;

                expect(function() {
                    plugin.merge(types[type]);
                }).to.throw(error);
            });
        });

        it("merges a parameter at a specific index, given an 'index' integer", function() {
            var plugin = Config.plugin({
                plugin: Webpack.definePlugin,
                parameters: [{a: 1}, 5, "test"]
            });

            plugin.merge(2, "merge");

            var actual = plugin.get();
            var expected = {
                plugin: Webpack.definePlugin,
                parameters: [{a: 1}, 5, "merge"]
            };

            expect(actual).to.eql(expected);
        });

        it("throws if 'index' isn't an integer", function() {
            var error = "You must provide an integer for 'index'.";
            var plugin = Config.plugin({
                plugin: Webpack.definePlugin,
                parameters: [{a: 1}, 5, "test"]
            });

            Object.keys(types).forEach(function(type) {
                if (type == "int")
                    return;

                expect(function() {
                    plugin.merge(types[type], {});
                }).to.throw(error);
            });
        });

    });

    xdescribe("set", function() {

        it("overwrites parameters, given an array for 'changes'", function() {

        });

        it("overwrites parameters at specific indexes, given a 'changes' object with numerical keys", function() {

        });

        it("throws if a 'changes' object is passed with non-numerical keys", function() {

        });

        it("overwrites a parameter at a specific index, given an 'index' integer", function() {

        });

        it("throws if 'index' isn't an integer", function() {

        });

    });

    xdescribe("get", function() {

        it("returns a clone of the internal plugin config", function() {

        });

    });

    xdescribe("resolve", function() {

        it("returns an instance of 'plugin'", function() {

        });

        it("applies 'parameters' upon initialisation", function() {

        });

        it("throws if 'plugin' isn't a function", function() {

        });

    });

});
<|endoftext|>


<commit_before>import document from 'global/document';

import QUnit from 'qunit';
import sinon from 'sinon';
import videojs from 'video.js';

import plugin from '../src/plugin';

const Tech = videojs.getComponent('Tech');

QUnit.test('the environment is sane', function(assert) {
  assert.strictEqual(typeof Array.isArray, 'function', 'es5 exists');
  assert.strictEqual(typeof sinon, 'object', 'sinon exists');
  assert.strictEqual(typeof videojs, 'function', 'videojs exists');
  assert.strictEqual(typeof plugin, 'function', 'plugin is a function');
});

QUnit.module('videojs-scene7', {

  beforeEach() {

    // Mock the environment's timers because certain things - particularly
    // player readiness - are asynchronous in video.js 5. This MUST come
    // before any player is created; otherwise, timers could get created
    // with the actual timer methods!
    this.clock = sinon.useFakeTimers();

    this.fixture = document.getElementById('qunit-fixture');
    this.video = document.createElement('video');
    this.fixture.appendChild(this.video);
    this.player = videojs(this.video);
  },

  afterEach() {
    this.player.dispose();
    this.clock.restore();
  }
});

QUnit.test('registers itself with video.js', function(assert) {
  assert.expect(1);

  assert.strictEqual(
    typeof Tech.getTech('Scene7'),
    'function',
    'videojs-scene7 tech plugin was registered'
  );

  // Tick the clock forward enough to trigger the player to be "ready".
  this.clock.tick(1);

  // assert.ok(
  //   this.player.hasClass('vjs-scene7'),
  //   'the plugin adds a class to the player'
  // );
});
<commit_msg>setup some unit tests<commit_after>import document from 'global/document';

import QUnit from 'qunit';
import sinon from 'sinon';
import videojs from 'video.js';

import plugin from '../src/plugin';

const Tech = videojs.getComponent('Tech');

/**
 * Returns a random integer between min (inclusive) and max (inclusive)
 * Using Math.round() will give you a non-uniform distribution!
 */
// function _getRandomInt(min, max) {
//   return Math.floor(Math.random() * (max - min + 1)) + min;
// }

/**
 * Returns a random alphanumeric string
 *
 * @return {string}
 *    starting with 'testRun' and 8 ASCII letters
 **/
function _getRandomAlphaString() {
  return 'testRun' + Math.random().toString(36).substring(8);
}

QUnit.test('the environment is sane', function(assert) {
  assert.strictEqual(typeof Array.isArray, 'function', 'es5 exists');
  assert.strictEqual(typeof sinon, 'object', 'sinon exists');
  assert.strictEqual(typeof videojs, 'function', 'videojs exists');
  assert.strictEqual(typeof plugin, 'function', 'plugin is a function');
});

QUnit.module('videojs-scene7', {

  beforeEach() {

    // Mock the environment's timers because certain things - particularly
    // player readiness - are asynchronous in video.js 5. This MUST come
    // before any player is created; otherwise, timers could get created
    // with the actual timer methods!
    this.clock = sinon.useFakeTimers();

    this.fixture = document.getElementById('qunit-fixture');
    this.video = document.createElement('video');
    this.fixture.appendChild(this.video);
    this.player = videojs(this.video);
  },

  afterEach() {
    this.player.dispose();
    this.clock.restore();
  }
});

QUnit.test('registers itself with video.js', function(assert) {
  assert.expect(1);

  assert.strictEqual(
    typeof Tech.getTech('Scene7'),
    'function',
    'videojs-scene7 tech plugin was registered'
  );

  // Tick the clock forward enough to trigger the player to be "ready".
  this.clock.tick(1);

  // assert.ok(
  //   this.player.hasClass('vjs-scene7'),
  //   'the plugin adds a class to the player'
  // );
});

QUnit.test('canPlayType()', function(assert) {
  const Scene7 = Tech.getTech('Scene7');

  assert.expect(3);

  assert.strictEqual(
    typeof Scene7.canPlayType,
    'function',
    'is a function.'
  );

  assert.strictEqual(
    Scene7.canPlayType('videojs/scene7'),
    'probably',
    'returns \'probably\' when the mime type is videojs/scene7.'
  );

  assert.strictEqual(
    Scene7.canPlayType(_getRandomAlphaString()),
    '',
    'returns an empty string when the video mime type is not a match.'
  );

  // Not implemented because we only want to support S7 video sets
  // assert.strictEqual(
  //   Scene7.canPlayType('video/mp4'),
  //   'maybe',
  //   'returns \'maybe\' when the mime type is video/mp4.'
  // );
});

QUnit.test('canPlaySource()', function(assert) {
  const Scene7 = Tech.getTech('Scene7');

  assert.expect(3);

  assert.strictEqual(
    typeof Scene7.canPlaySource,
    'function',
    'is a function.'
  );

  assert.strictEqual(
    Scene7.canPlaySource({
      src: 'https://example.com/video',
      type: 'videojs/scene7'}),
    'probably',
    'returns \'probably\' when the mime type is videojs/scene7.'
  );

  assert.strictEqual(
    Scene7.canPlayType({
      src: 'https://example.com/video',
      type: _getRandomAlphaString()}),
    '',
    'returns an empty string when the video mime type is not a match.'
  );

  // Not implemented because we only want to support S7 video sets
  // assert.strictEqual(
  //   Scene7.canPlayType('video/mp4'),
  //   'maybe',
  //   'returns \'maybe\' when the mime type is video/mp4.'
  // );
});
<|endoftext|>


<commit_before>/* eslint-env jest */

const squid = require('flying-squid')
const { firstVersion, lastVersion } = require('./common/parallel')

squid.supportedVersions.forEach((supportedVersion, i) => {
  if (!(i >= firstVersion && i <= lastVersion)) return

  const mcData = require('minecraft-data')(supportedVersion)
  const version = mcData.version

  const {
    detectFrame,
    findPotentialLines,
    findBorder,
    getAir,
    generateLine,
    generatePortal,
    makeWorldWithPortal
  } = squid.portal_detector(version.minecraftVersion)

  const { Vec3 } = require('vec3')

  describe('generate portal ' + version.minecraftVersion, () => {
    test('generate a line', () => {
      expect(generateLine(new Vec3(3, 1, 1), new Vec3(1, 0, 0), 2)).toEqual([new Vec3(3, 1, 1), new Vec3(4, 1, 1)])
    })

    test('generate a portal', () => {
      expect(generatePortal(new Vec3(2, 1, 1), new Vec3(1, 0, 0), 4, 5)).toEqual({
        bottom: generateLine(new Vec3(3, 1, 1), new Vec3(1, 0, 0), 2),
        left: generateLine(new Vec3(2, 2, 1), new Vec3(0, 1, 0), 3),
        right: generateLine(new Vec3(5, 2, 1), new Vec3(0, 1, 0), 3),
        top: generateLine(new Vec3(3, 5, 1), new Vec3(1, 0, 0), 2),
        air: generateLine(new Vec3(3, 2, 1), new Vec3(0, 1, 0), 3).concat(generateLine(new Vec3(4, 2, 1), new Vec3(0, 1, 0), 3))
      })
    })
  })

  describe('detect portal ' + version.minecraftVersion, () => {
    jest.setTimeout(60 * 1000)
    const portalData = []

    portalData.push({
      name: 'simple portal frame x',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(1, 0, 0),
      width: 4,
      height: 5,
      additionalAir: [],
      additionalObsidian: []
    })

    portalData.push({
      name: 'simple portal frame z',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(0, 0, 1),
      width: 4,
      height: 5,
      additionalAir: [],
      additionalObsidian: []
    })

    portalData.push({
      name: 'big simple portal frame x',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(1, 0, 0),
      width: 10,
      height: 10,
      additionalAir: [],
      additionalObsidian: []
    })

    portalData.push({
      name: 'simple portal frame x with borders',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(1, 0, 0),
      width: 4,
      height: 5,
      additionalAir: [],
      additionalObsidian: [new Vec3(2, 1, 1), new Vec3(5, 1, 1), new Vec3(2, 6, 1), new Vec3(5, 6, 1)]
    })

    const { bottom, left, right, top, air } = generatePortal(new Vec3(2, 1, 2), new Vec3(1, 0, 0), 4, 5)

    portalData.push({
      name: '2 portals',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(1, 0, 0),
      width: 4,
      height: 5,
      additionalAir: air,
      additionalObsidian: [].concat([], [bottom, left, right, top])
    })

    portalData.push({
      name: 'huge simple portal frame z',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(0, 0, 1),
      width: 50,
      height: 50,
      additionalAir: [],
      additionalObsidian: []
    })

    portalData.forEach(({ name, bottomLeft, direction, width, height, additionalAir, additionalObsidian }) => {
      const portal = generatePortal(bottomLeft, direction, width, height)
      const { bottom, left, right, top, air } = portal
      describe('Detect ' + name, () => {
        const expectedBorder = { bottom, left, right, top }

        let world
        beforeAll(async function () {
          world = await makeWorldWithPortal(portal, additionalAir, additionalObsidian)
        })

        describe('detect potential first lines', () => {
          test('detect potential first lines from bottom left', async () => {
            const potentialLines = await findPotentialLines(world, bottom[0], new Vec3(0, 1, 0))
            expect(potentialLines).toContainEqual({
              direction: direction,
              line: bottom
            })
          })

          test('detect potential first lines from bottom right', async () => {
            const potentialLines = await findPotentialLines(world, bottom[bottom.length - 1], new Vec3(0, 1, 0))
            expect(potentialLines).toContainEqual({
              direction: direction,
              line: bottom
            })
          })

          test('detect potential first lines from top left', async () => {
            const potentialLines = await findPotentialLines(world, top[0], new Vec3(0, -1, 0))
            expect(potentialLines).toContainEqual({
              direction: direction,
              line: top
            })
          })

          test('detect potential first lines from top right', async () => {
            const potentialLines = await findPotentialLines(world, top[top.length - 1], new Vec3(0, -1, 0))
            expect(potentialLines).toContainEqual({
              direction: direction,
              line: top
            })
          })

          test('detect potential first lines from left top', async () => {
            const potentialLines = await findPotentialLines(world, left[left.length - 1], direction)
            expect(potentialLines).toEqual([{
              direction: new Vec3(0, 1, 0),
              line: left
            }])
          })

          test('detect potential first lines from right bottom', async () => {
            const potentialLines = await findPotentialLines(world, right[0], direction.scaled(-1))
            expect(potentialLines).toEqual([{
              direction: new Vec3(0, 1, 0),
              line: right
            }])
          })
        })

        describe('find borders', () => {
          test('find borders from bottom', async () => {
            const border = await findBorder(world, {
              direction: direction,
              line: bottom
            }, new Vec3(0, 1, 0))
            expect(border).toEqual(expectedBorder)
          })

          test('find borders from top', async () => {
            const border = await findBorder(world, {
              direction: direction,
              line: top
            }, new Vec3(0, -1, 0))
            expect(border).toEqual(expectedBorder)
          })

          test('find borders from left', async () => {
            const border = await findBorder(world, {
              direction: new Vec3(0, 1, 0),
              line: left
            }, direction)
            expect(border).toEqual(expectedBorder)
          })
          test('find borders from right', async () => {
            const border = await findBorder(world, {
              direction: new Vec3(0, 1, 0),
              line: right
            }, direction.scaled(-1))
            expect(border).toEqual(expectedBorder)
          })
        })

        describe('detect portals', () => {
          test('detect portals from bottom left', async () => {
            const portals = await detectFrame(world, bottom[0], new Vec3(0, 1, 0))
            expect(portals).toEqual([portal])
          })
          test('detect portals from top left', async () => {
            const portals = await detectFrame(world, top[0], new Vec3(0, -1, 0))
            expect(portals).toEqual([portal])
          })
          test('detect portals from right top', async () => {
            const portals = await detectFrame(world, right[right.length - 1], direction.scaled(-1))
            expect(portals).toEqual([portal])
          })
        })

        test('get air', () => {
          const foundAir = getAir(expectedBorder)
          expect(foundAir).toEqual(air)
        })
      })
    })
  })

  describe("doesn't detect non-portal " + version.minecraftVersion, () => {
    const portalData = []

    portalData.push({
      name: 'simple portal frame x with one obsidian in the middle',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(1, 0, 0),
      width: 5,
      height: 5,
      additionalAir: [],
      additionalObsidian: [new Vec3(4, 3, 1)]
    })

    portalData.forEach(({ name, bottomLeft, direction, width, height, additionalAir, additionalObsidian }) => {
      const portal = generatePortal(bottomLeft, direction, width, height)
      const { bottom, right, top } = portal
      describe("doesn't detect detect " + name, () => {
        let world
        beforeAll(async function () {
          world = await makeWorldWithPortal(portal, additionalAir, additionalObsidian)
        })

        describe("doesn't detect portals", () => {
          test("doesn't detect portals from bottom left", async () => {
            const portals = await detectFrame(world, bottom[0], new Vec3(0, 1, 0))
            expect(portals).toEqual([])
          })
          test("doesn't detect portals from top left", async () => {
            const portals = await detectFrame(world, top[0], new Vec3(0, -1, 0))
            expect(portals).toEqual([])
          })
          test("doesn't detect portals from right top", async () => {
            const portals = await detectFrame(world, right[right.length - 1], direction.scaled(-1))
            expect(portals).toEqual([])
          })
        })
      })
    })
  })
})
<commit_msg>Fix (unused?) concat in tests<commit_after>/* eslint-env jest */

const squid = require('flying-squid')
const { firstVersion, lastVersion } = require('./common/parallel')

squid.supportedVersions.forEach((supportedVersion, i) => {
  if (!(i >= firstVersion && i <= lastVersion)) return

  const mcData = require('minecraft-data')(supportedVersion)
  const version = mcData.version

  const {
    detectFrame,
    findPotentialLines,
    findBorder,
    getAir,
    generateLine,
    generatePortal,
    makeWorldWithPortal
  } = squid.portal_detector(version.minecraftVersion)

  const { Vec3 } = require('vec3')

  describe('generate portal ' + version.minecraftVersion, () => {
    test('generate a line', () => {
      expect(generateLine(new Vec3(3, 1, 1), new Vec3(1, 0, 0), 2)).toEqual([new Vec3(3, 1, 1), new Vec3(4, 1, 1)])
    })

    test('generate a portal', () => {
      expect(generatePortal(new Vec3(2, 1, 1), new Vec3(1, 0, 0), 4, 5)).toEqual({
        bottom: generateLine(new Vec3(3, 1, 1), new Vec3(1, 0, 0), 2),
        left: generateLine(new Vec3(2, 2, 1), new Vec3(0, 1, 0), 3),
        right: generateLine(new Vec3(5, 2, 1), new Vec3(0, 1, 0), 3),
        top: generateLine(new Vec3(3, 5, 1), new Vec3(1, 0, 0), 2),
        air: generateLine(new Vec3(3, 2, 1), new Vec3(0, 1, 0), 3).concat(generateLine(new Vec3(4, 2, 1), new Vec3(0, 1, 0), 3))
      })
    })
  })

  describe('detect portal ' + version.minecraftVersion, () => {
    jest.setTimeout(60 * 1000)
    const portalData = []

    portalData.push({
      name: 'simple portal frame x',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(1, 0, 0),
      width: 4,
      height: 5,
      additionalAir: [],
      additionalObsidian: []
    })

    portalData.push({
      name: 'simple portal frame z',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(0, 0, 1),
      width: 4,
      height: 5,
      additionalAir: [],
      additionalObsidian: []
    })

    portalData.push({
      name: 'big simple portal frame x',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(1, 0, 0),
      width: 10,
      height: 10,
      additionalAir: [],
      additionalObsidian: []
    })

    portalData.push({
      name: 'simple portal frame x with borders',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(1, 0, 0),
      width: 4,
      height: 5,
      additionalAir: [],
      additionalObsidian: [new Vec3(2, 1, 1), new Vec3(5, 1, 1), new Vec3(2, 6, 1), new Vec3(5, 6, 1)]
    })

    const { bottom, left, right, top, air } = generatePortal(new Vec3(2, 1, 2), new Vec3(1, 0, 0), 4, 5)

    portalData.push({
      name: '2 portals',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(1, 0, 0),
      width: 4,
      height: 5,
      additionalAir: air,
      additionalObsidian: [].concat(bottom, left, right, top)
    })

    portalData.push({
      name: 'huge simple portal frame z',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(0, 0, 1),
      width: 50,
      height: 50,
      additionalAir: [],
      additionalObsidian: []
    })

    portalData.forEach(({ name, bottomLeft, direction, width, height, additionalAir, additionalObsidian }) => {
      const portal = generatePortal(bottomLeft, direction, width, height)
      const { bottom, left, right, top, air } = portal
      describe('Detect ' + name, () => {
        const expectedBorder = { bottom, left, right, top }

        let world
        beforeAll(async function () {
          world = await makeWorldWithPortal(portal, additionalAir, additionalObsidian)
        })

        describe('detect potential first lines', () => {
          test('detect potential first lines from bottom left', async () => {
            const potentialLines = await findPotentialLines(world, bottom[0], new Vec3(0, 1, 0))
            expect(potentialLines).toContainEqual({
              direction: direction,
              line: bottom
            })
          })

          test('detect potential first lines from bottom right', async () => {
            const potentialLines = await findPotentialLines(world, bottom[bottom.length - 1], new Vec3(0, 1, 0))
            expect(potentialLines).toContainEqual({
              direction: direction,
              line: bottom
            })
          })

          test('detect potential first lines from top left', async () => {
            const potentialLines = await findPotentialLines(world, top[0], new Vec3(0, -1, 0))
            expect(potentialLines).toContainEqual({
              direction: direction,
              line: top
            })
          })

          test('detect potential first lines from top right', async () => {
            const potentialLines = await findPotentialLines(world, top[top.length - 1], new Vec3(0, -1, 0))
            expect(potentialLines).toContainEqual({
              direction: direction,
              line: top
            })
          })

          test('detect potential first lines from left top', async () => {
            const potentialLines = await findPotentialLines(world, left[left.length - 1], direction)
            expect(potentialLines).toEqual([{
              direction: new Vec3(0, 1, 0),
              line: left
            }])
          })

          test('detect potential first lines from right bottom', async () => {
            const potentialLines = await findPotentialLines(world, right[0], direction.scaled(-1))
            expect(potentialLines).toEqual([{
              direction: new Vec3(0, 1, 0),
              line: right
            }])
          })
        })

        describe('find borders', () => {
          test('find borders from bottom', async () => {
            const border = await findBorder(world, {
              direction: direction,
              line: bottom
            }, new Vec3(0, 1, 0))
            expect(border).toEqual(expectedBorder)
          })

          test('find borders from top', async () => {
            const border = await findBorder(world, {
              direction: direction,
              line: top
            }, new Vec3(0, -1, 0))
            expect(border).toEqual(expectedBorder)
          })

          test('find borders from left', async () => {
            const border = await findBorder(world, {
              direction: new Vec3(0, 1, 0),
              line: left
            }, direction)
            expect(border).toEqual(expectedBorder)
          })
          test('find borders from right', async () => {
            const border = await findBorder(world, {
              direction: new Vec3(0, 1, 0),
              line: right
            }, direction.scaled(-1))
            expect(border).toEqual(expectedBorder)
          })
        })

        describe('detect portals', () => {
          test('detect portals from bottom left', async () => {
            const portals = await detectFrame(world, bottom[0], new Vec3(0, 1, 0))
            expect(portals).toEqual([portal])
          })
          test('detect portals from top left', async () => {
            const portals = await detectFrame(world, top[0], new Vec3(0, -1, 0))
            expect(portals).toEqual([portal])
          })
          test('detect portals from right top', async () => {
            const portals = await detectFrame(world, right[right.length - 1], direction.scaled(-1))
            expect(portals).toEqual([portal])
          })
        })

        test('get air', () => {
          const foundAir = getAir(expectedBorder)
          expect(foundAir).toEqual(air)
        })
      })
    })
  })

  describe("doesn't detect non-portal " + version.minecraftVersion, () => {
    const portalData = []

    portalData.push({
      name: 'simple portal frame x with one obsidian in the middle',
      bottomLeft: new Vec3(2, 1, 1),
      direction: new Vec3(1, 0, 0),
      width: 5,
      height: 5,
      additionalAir: [],
      additionalObsidian: [new Vec3(4, 3, 1)]
    })

    portalData.forEach(({ name, bottomLeft, direction, width, height, additionalAir, additionalObsidian }) => {
      const portal = generatePortal(bottomLeft, direction, width, height)
      const { bottom, right, top } = portal
      describe("doesn't detect detect " + name, () => {
        let world
        beforeAll(async function () {
          world = await makeWorldWithPortal(portal, additionalAir, additionalObsidian)
        })

        describe("doesn't detect portals", () => {
          test("doesn't detect portals from bottom left", async () => {
            const portals = await detectFrame(world, bottom[0], new Vec3(0, 1, 0))
            expect(portals).toEqual([])
          })
          test("doesn't detect portals from top left", async () => {
            const portals = await detectFrame(world, top[0], new Vec3(0, -1, 0))
            expect(portals).toEqual([])
          })
          test("doesn't detect portals from right top", async () => {
            const portals = await detectFrame(world, right[right.length - 1], direction.scaled(-1))
            expect(portals).toEqual([])
          })
        })
      })
    })
  })
})
<|endoftext|>


<commit_before>var app = require('../app');
var supertest = require('supertest');
var assert = require('assert');

describe('Pruebas de Series', function () {

	it('GET / devuelve todas las series', function (done) {
		supertest(app)
		.get('/api/series')
		.expect(200)
		.expect(function (req) {
			assert(req.text.indexOf("The Big Bang Theory") != -1);
			assert(req.text.indexOf("Breaking Bad") != -1);
		})
		.end(done);
	});

});<commit_msg>GET serie<commit_after>var app = require('../app');
var supertest = require('supertest');
var assert = require('assert');

describe('Pruebas de Series', function () {

	it('GET / devuelve todas las series', function (done) {
		supertest(app)
		.get('/api/series')
		.expect(200)
		.expect(function (req) {
			assert(req.text.indexOf("The Big Bang Theory") != -1);
			assert(req.text.indexOf("Breaking Bad") != -1);
		})
		.end(done);
	});

	it('GET /:id id no numérico', function (done) {
		supertest(app)
		.get('/api/series/uno')
		.expect(400)
		.expect("Error: El id no es un número", done);
	});

	it('GET /:id devuelve la serie', function (done) {
		supertest(app)
		.get('/api/series/1')
		.expect(200)
		.expect(function (req) {
			assert.equal("The Big Bang Theory", req.body.title);
			assert.equal("descripción de la serie The Big Bang Theory", req.body.description);
			assert.equal(9, req.body.temporadas.length);
		})
		.end(done);
	});

});<|endoftext|>


<commit_before>
$.fn.slider.defaults.duration = 0;
var testx = function() {};

suite('fidel-slider', function() {
  var slider1;

  setup(function() {
    $('#fixture').empty().html($('#clone').clone());

    slider1 = $('#fixture .slider1');
  });

  suite('init', function() {

    test('$().slider exists', function() {

      assert.equal(typeof slider1.slider, 'function');
    });

    test('set initial page from options', function() {
      slider1.slider({ page: 2 });
      assert.equal(slider1.slider('getCurrentPage'), 2);
    });

  });

  suite('itemsPerPage', function() {

    test('pageCount with default settings', function() {

      var s = slider1.slider().data('slider');
      assert.equal(s.pageCount, 4);
    });

    test('pageCount with itemsPerPage = 2', function() {

      var s = slider1.slider({ itemsPerPage: 2}).data('slider');
      assert.equal(s.pageCount, 2);
    });

    test('pageWidth', function() {

      var s = slider1.slider().data('slider');
      assert.equal(s.pageWidth, 250);
    });

    test('pageWidth with itemsPerPage = 2', function() {

      var s = slider1.slider({ itemsPerPage: 2}).data('slider');
      assert.equal(s.pageWidth, 500);
    });

    test('set width of slider', function() {
      slider1.slider();
      assert.equal(slider1.width(), 250);
    });

    test('set width of slider with itemsPerPage = 2', function() {
      slider1.slider({ itemsPerPage: 2});
      assert.equal(slider1.width(), 500);
    });

  });

  suite('api', function() {

    test('current page', function() {
      slider1.slider();
      assert.equal(slider1.slider('getCurrentPage'), 1);
    });

    test('next', function() {
      slider1.slider();
      slider1.slider('next');
      assert.equal(slider1.slider('getCurrentPage'), 2);
    });

    test('next takes a callback', function(done) {
      slider1.slider();
      slider1.slider('next', function() {
        assert.equal(parseInt(slider1.find('.container').css('left'), 10), -250);
        done();
      });
    });

    test('next past max pages', function(done) {
      slider1.slider();
      slider1.slider('next');
      slider1.slider('next');
      slider1.slider('next');
      slider1.slider('next');
      slider1.slider('next');
      slider1.slider('next', function() {
        done();
      });
      assert.equal(slider1.slider('getCurrentPage'), 4);
    });

    test('previous', function(done) {
      slider1.slider();
      slider1.slider('next');
      slider1.slider('previous', function() {
        assert.equal(parseInt(slider1.find('.container').css('left'), 10), 0);
        done();
      });
      assert.equal(slider1.slider('getCurrentPage'), 1);
    });

    test('previous if at first page', function() {
      slider1.slider();
      slider1.slider('previous');
      assert.equal(slider1.slider('getCurrentPage'), 1);
    });

    test('go', function(done) {
      slider1.slider();
      slider1.slider('go', 2, function() {
        assert.equal(parseInt(slider1.find('.container').css('left'), 10), -250);
        assert.equal(slider1.slider('getCurrentPage'), 2);
        done();
      });
    });

    test('go page that doesnt exist');

    test('first method goes to first slide', function(done) {
      slider1.slider();
      slider1.slider('first', function() {
        assert.equal(slider1.slider('getCurrentPage'), 1);
        done();
      });
    });

    test('last method goes to last slide', function(done) {
      slider1.slider();
      slider1.slider('last', function() {
        assert.equal(slider1.slider('getCurrentPage'), 4);
        done();
      });
    });

  });

  suite('buttons', function() {

    test('click to go next', function() {
      slider1.slider();
      $('#fixture [data-action=next]').click();
      assert.equal(slider1.slider('getCurrentPage'), 2);
    });

    test('click to go prev', function() {
      slider1.slider();
      $('#fixture [data-action=next]').click();
      $('#fixture [data-action=previous]').click();
      assert.equal(slider1.slider('getCurrentPage'), 1);
    });

    test('hide previous when on first page', function() {
      slider1.slider();
      assert.equal($('#fixture [data-action=previous]').css('display'), 'none');
    });

    test('hide next when on last page', function() {
      slider1.slider();
      slider1.slider('last');
      assert.equal($('#fixture [data-action=next]').css('display'), 'none');
    });

    test('show both buttons when if on any other page', function() {
      slider1.slider();
      slider1.slider('next');
      assert.equal($('#fixture [data-action=previous]').css('display'), 'inline-block');
    });

    test('data-action=go to jump to a page', function() {
      slider1.slider();
      $('#fixture [data-action=go]').click();
      assert.equal(slider1.slider('getCurrentPage'), 3);
    });

  });

  suite('events', function() {

    test('event when about to slide', function(done) {
      slider1.slider();
      slider1.on('beforeSlide', function(e, pageNumber) {
        assert.equal(slider1.find('.container').css('left'), '0px');
        assert.equal(pageNumber, 2);
        done();
      });
      slider1.slider('next');
    });

    test('event after sliding', function(done) {
      slider1.slider();
      slider1.on('slide', function(e, pageNumber) {
        assert.equal(parseInt(slider1.find('.container').css('left'), 10), -250);
        assert.equal(pageNumber, 2);
        done();
      });
      slider1.slider('next');
    });

    test('event when on first page', function(done) {
      slider1.slider();
      slider1.on('first', function(e, pageNumber) {
        assert.equal(pageNumber, 1);
        done();
      });
      slider1.slider('first');
    });

    test('event when on the last page', function(done) {
      slider1.slider();
      slider1.on('last', function(e, pageNumber) {
        assert.equal(pageNumber, 4);
        done();
      });
      slider1.slider('last');
    });

    test('event when going next', function(done) {
      slider1.slider();
      slider1.on('next', function(e, pageNumber) {
        assert.equal(pageNumber, 2);
        done();
      });
      slider1.slider('next');
    });

    test('event when going previous', function(done) {
      slider1.slider();
      slider1.on('previous', function(e, pageNumber) {
        assert.equal(pageNumber, 1);
        done();
      });
      slider1.slider('previous');
    });

  });

  suite('auto', function() {

    test('auto slide', function(done) {
      slider1.slider({ auto: true, autoDelay: 10 });
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 2);
        setTimeout(function() {
          assert.equal(slider1.slider('getCurrentPage'), 3);
          done();
        }, 10);
      }, 15);
    });

    test('stop on hover', function(done) {
      slider1.slider({ auto: true, autoDelay: 10 });
      slider1.mouseover();
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 1);
        done();
      }, 15);
    });

    test('continue on mouse out', function(done) {
      slider1.slider({ auto: true, autoDelay: 10 });
      slider1.mouseover();
      setTimeout(function() {
        slider1.mouseout();
      }, 5);
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 2);
        done();
      }, 20);
    });

    test('auto: false to disable', function(done) {
      slider1.slider({ auto: false });
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 1);
        done();
      }, 15);
    });

    test('wrap around automatically', function(done) {
      slider1.slider({ auto: 5 });
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 1);
        done();
      }, 5*5);
    });

    test('disable wrap', function(done) {
      slider1.slider({ auto: true, autoDelay: 5, wrap: false });
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 4);
        done();
      }, 5*5);
    });

    test('method to stop', function(done) {
      slider1.slider({ auto: true, autoDelay: 5 });
      slider1.slider('stop');
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 1);
        done();
      }, 7);
    });

    test('method to start', function(done) {
      slider1.slider({ autoDelay: 5 });
      slider1.slider('start');
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 2);
        done();
      }, 7);
    });

  });

});

<commit_msg>[test] tests mouseover/out triggering auto slide<commit_after>
$.fn.slider.defaults.duration = 0;
var testx = function() {};

suite('fidel-slider', function() {
  var slider1;

  setup(function() {
    $('#fixture').empty().html($('#clone').clone());

    slider1 = $('#fixture .slider1');
  });

  suite('init', function() {

    test('$().slider exists', function() {

      assert.equal(typeof slider1.slider, 'function');
    });

    test('set initial page from options', function() {
      slider1.slider({ page: 2 });
      assert.equal(slider1.slider('getCurrentPage'), 2);
    });

  });

  suite('itemsPerPage', function() {

    test('pageCount with default settings', function() {

      var s = slider1.slider().data('slider');
      assert.equal(s.pageCount, 4);
    });

    test('pageCount with itemsPerPage = 2', function() {

      var s = slider1.slider({ itemsPerPage: 2}).data('slider');
      assert.equal(s.pageCount, 2);
    });

    test('pageWidth', function() {

      var s = slider1.slider().data('slider');
      assert.equal(s.pageWidth, 250);
    });

    test('pageWidth with itemsPerPage = 2', function() {

      var s = slider1.slider({ itemsPerPage: 2}).data('slider');
      assert.equal(s.pageWidth, 500);
    });

    test('set width of slider', function() {
      slider1.slider();
      assert.equal(slider1.width(), 250);
    });

    test('set width of slider with itemsPerPage = 2', function() {
      slider1.slider({ itemsPerPage: 2});
      assert.equal(slider1.width(), 500);
    });

  });

  suite('api', function() {

    test('current page', function() {
      slider1.slider();
      assert.equal(slider1.slider('getCurrentPage'), 1);
    });

    test('next', function() {
      slider1.slider();
      slider1.slider('next');
      assert.equal(slider1.slider('getCurrentPage'), 2);
    });

    test('next takes a callback', function(done) {
      slider1.slider();
      slider1.slider('next', function() {
        assert.equal(parseInt(slider1.find('.container').css('left'), 10), -250);
        done();
      });
    });

    test('next past max pages', function(done) {
      slider1.slider();
      slider1.slider('next');
      slider1.slider('next');
      slider1.slider('next');
      slider1.slider('next');
      slider1.slider('next');
      slider1.slider('next', function() {
        done();
      });
      assert.equal(slider1.slider('getCurrentPage'), 4);
    });

    test('previous', function(done) {
      slider1.slider();
      slider1.slider('next');
      slider1.slider('previous', function() {
        assert.equal(parseInt(slider1.find('.container').css('left'), 10), 0);
        done();
      });
      assert.equal(slider1.slider('getCurrentPage'), 1);
    });

    test('previous if at first page', function() {
      slider1.slider();
      slider1.slider('previous');
      assert.equal(slider1.slider('getCurrentPage'), 1);
    });

    test('go', function(done) {
      slider1.slider();
      slider1.slider('go', 2, function() {
        assert.equal(parseInt(slider1.find('.container').css('left'), 10), -250);
        assert.equal(slider1.slider('getCurrentPage'), 2);
        done();
      });
    });

    test('go page that doesnt exist');

    test('first method goes to first slide', function(done) {
      slider1.slider();
      slider1.slider('first', function() {
        assert.equal(slider1.slider('getCurrentPage'), 1);
        done();
      });
    });

    test('last method goes to last slide', function(done) {
      slider1.slider();
      slider1.slider('last', function() {
        assert.equal(slider1.slider('getCurrentPage'), 4);
        done();
      });
    });

  });

  suite('buttons', function() {

    test('click to go next', function() {
      slider1.slider();
      $('#fixture [data-action=next]').click();
      assert.equal(slider1.slider('getCurrentPage'), 2);
    });

    test('click to go prev', function() {
      slider1.slider();
      $('#fixture [data-action=next]').click();
      $('#fixture [data-action=previous]').click();
      assert.equal(slider1.slider('getCurrentPage'), 1);
    });

    test('hide previous when on first page', function() {
      slider1.slider();
      assert.equal($('#fixture [data-action=previous]').css('display'), 'none');
    });

    test('hide next when on last page', function() {
      slider1.slider();
      slider1.slider('last');
      assert.equal($('#fixture [data-action=next]').css('display'), 'none');
    });

    test('show both buttons when if on any other page', function() {
      slider1.slider();
      slider1.slider('next');
      assert.equal($('#fixture [data-action=previous]').css('display'), 'inline-block');
    });

    test('data-action=go to jump to a page', function() {
      slider1.slider();
      $('#fixture [data-action=go]').click();
      assert.equal(slider1.slider('getCurrentPage'), 3);
    });

  });

  suite('events', function() {

    test('event when about to slide', function(done) {
      slider1.slider();
      slider1.on('beforeSlide', function(e, pageNumber) {
        assert.equal(slider1.find('.container').css('left'), '0px');
        assert.equal(pageNumber, 2);
        done();
      });
      slider1.slider('next');
    });

    test('event after sliding', function(done) {
      slider1.slider();
      slider1.on('slide', function(e, pageNumber) {
        assert.equal(parseInt(slider1.find('.container').css('left'), 10), -250);
        assert.equal(pageNumber, 2);
        done();
      });
      slider1.slider('next');
    });

    test('event when on first page', function(done) {
      slider1.slider();
      slider1.on('first', function(e, pageNumber) {
        assert.equal(pageNumber, 1);
        done();
      });
      slider1.slider('first');
    });

    test('event when on the last page', function(done) {
      slider1.slider();
      slider1.on('last', function(e, pageNumber) {
        assert.equal(pageNumber, 4);
        done();
      });
      slider1.slider('last');
    });

    test('event when going next', function(done) {
      slider1.slider();
      slider1.on('next', function(e, pageNumber) {
        assert.equal(pageNumber, 2);
        done();
      });
      slider1.slider('next');
    });

    test('event when going previous', function(done) {
      slider1.slider();
      slider1.on('previous', function(e, pageNumber) {
        assert.equal(pageNumber, 1);
        done();
      });
      slider1.slider('previous');
    });

  });

  suite('auto', function() {

    test('auto slide', function(done) {
      slider1.slider({ auto: true, autoDelay: 10 });
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 2);
        setTimeout(function() {
          assert.equal(slider1.slider('getCurrentPage'), 3);
          done();
        }, 10);
      }, 15);
    });

    test('stop on hover', function(done) {
      slider1.slider({ auto: true, autoDelay: 10 });
      slider1.mouseover();
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 1);
        done();
      }, 15);
    });

    test('continue on mouse out', function(done) {
      slider1.slider({ auto: true, autoDelay: 10 });
      slider1.mouseover();
      setTimeout(function() {
        slider1.mouseout();
      }, 5);
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 2);
        done();
      }, 20);
    });

    test('auto: false to disable', function(done) {
      slider1.slider({ auto: false });
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 1);
        done();
      }, 15);
    });

    test('wrap around automatically', function(done) {
      slider1.slider({ auto: 5 });
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 1);
        done();
      }, 5*5);
    });

    test('disable wrap', function(done) {
      slider1.slider({ auto: true, autoDelay: 5, wrap: false });
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 4);
        done();
      }, 5*5);
    });

    test('method to stop', function(done) {
      slider1.slider({ auto: true, autoDelay: 5 });
      slider1.slider('stop');
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 1);
        done();
      }, 7);
    });

    test('method to start', function(done) {
      slider1.slider({ autoDelay: 5 });
      slider1.slider('start');
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 2);
        setTimeout(function() {
          assert.equal(slider1.slider('getCurrentPage'), 3);
          done();
        }, 7);
      }, 7);
    });

    test('call start method and mouse over', function(done) {
      slider1.slider({ autoDelay: 5 });
      slider1.slider('start');
      slider1.mouseover();
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 1);
        slider1.mouseout();
        setTimeout(function() {
          assert.equal(slider1.slider('getCurrentPage'), 2);
          done();
        }, 7);
      }, 7);
    });

    test('mouseout doesnt start auto', function(done) {
      slider1.slider({ autoDelay: 5 });
      slider1.mouseover();
      slider1.mouseout();
      setTimeout(function() {
        assert.equal(slider1.slider('getCurrentPage'), 1);
        done();
      }, 7);
    });

  });

});

<|endoftext|>


<commit_before>var arr_sig_property = [
{
	testName		:	"VT299-1001 | Set bgColor :#FF0000| #FF0000",
	propertyName	:	"bgColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#FF0000",
	expectedResult	:	"#FF0000"
},
{
	testName		:	"VT299-1002 | Set bgColor :#0000FF| #0000FF",
	propertyName	:	"bgColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#0000FF",
	expectedResult	:	"#0000FF"
},
{
	testName		:	"VT299-1003 | Set bgColor :#000000| #000000",
	propertyName	:	"bgColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#000000",
	expectedResult	:	"#000000"
},
{
	testName		:	"VT299-1004 | Set bgColor :#FFFFFF| #FFFFFF",
	propertyName	:	"bgColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#FFFFFF",
	expectedResult	:	"#FFFFFF"
},
{
	testName		:	"VT299-1005 | Set border :false| false",
	propertyName	:	"border",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"false",
	expectedResult	:	"false"
},
{
	testName		:	"VT299-1006 | Set border :true| true",
	propertyName	:	"border",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"true",
	expectedResult	:	"true"
},
{
	testName		:	"VT299-1007 | Set compressionFormat :jpg| jpg",
	propertyName	:	"compressionFormat",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"jpg",
	expectedResult	:	"jpg"
},
{
	testName		:	"VT299-1008 | Set compressionFormat :png| png",
	propertyName	:	"compressionFormat",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"png",
	expectedResult	:	"png"
},
{
	testName		:	"VT299-1009 | Set compressionFormat :bmp| bmp",
	propertyName	:	"compressionFormat",
	sigTypes		:	"All",
	OSTypes			:	"WINDOWS APPLE",
	propertyValue	:	"bmp",
	expectedResult	:	"bmp"
},
{
	testName		:	"VT299-1010 | Set fileName :Test| Test",
	propertyName	:	"fileName",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"Test",
	expectedResult	:	"Test"
},
{
	testName		:	"VT299-1012 | Set fileName :Test123| Test123",
	propertyName	:	"fileName",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"Test123",
	expectedResult	:	"Test123"
},
{
	testName		:	"VT299-1013 | Set fileName :Test_123| Test_123",
	propertyName	:	"fileName",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"Test_123",
	expectedResult	:	"Test_123"
},
{
	testName		:	"VT299-1014 | Set fileName :123| 123",
	propertyName	:	"fileName",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"123",
	expectedResult	:	"123"
},
{
	testName		:	"VT299-1015 | Set fileName :signature| signature",
	propertyName	:	"fileName",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"signature",
	expectedResult	:	"signature"
},
{
	testName		:	"VT299-1016 | Set height :100| 100",
	propertyName	:	"height",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"100",
	expectedResult	:	"100"
},
{
	testName		:	"VT299-1017 | Set height :500| 500",
	propertyName	:	"height",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"500",
	expectedResult	:	"500"
},
{
	testName		:	"VT299-1018 | Set height :150| 150",
	propertyName	:	"height",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"150",
	expectedResult	:	"150"
},
{
	testName		:	"VT299-1019 | Set height :0| 0",
	propertyName	:	"height",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"0",
	expectedResult	:	"0"
},
{
	testName		:	"VT299-1020 | Set left :90| 90",
	propertyName	:	"left",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"90",
	expectedResult	:	"90"
},
{
	testName		:	"VT299-1021 | Set left :550| 550",
	propertyName	:	"left",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"550",
	expectedResult	:	"550"
},
{
	testName		:	"VT299-1022 | Set left :15| 15",
	propertyName	:	"left",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"15",
	expectedResult	:	"15"
},
{
	testName		:	"VT299-1022 | Set left :0| 0",
	propertyName	:	"left",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"0",
	expectedResult	:	"0"
},
{
	testName		:	"VT299-1023 | Set top :50| 50",
	propertyName	:	"top",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"50",
	expectedResult	:	"50"
},
{
	testName		:	"VT299-1024 | Set top :150| 150",
	propertyName	:	"top",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"150",
	expectedResult	:	"150"
},
{
	testName		:	"VT299-1025 | Set top :60| 60",
	propertyName	:	"top",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"60",
	expectedResult	:	"60"
},
{
	testName		:	"VT299-1026 | Set top :0| 0",
	propertyName	:	"top",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"0",
	expectedResult	:	"0"
},
{
	testName		:	"VT299-1027 | Set width :140| 140",
	propertyName	:	"width",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"140",
	expectedResult	:	"140"
},
{
	testName		:	"VT299-1028 | Set width :450| 450",
	propertyName	:	"width",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"450",
	expectedResult	:	"450"
},
{
	testName		:	"VT299-1029 | Set width :200| 200",
	propertyName	:	"width",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"200",
	expectedResult	:	"200"
},
{
	testName		:	"VT299-1030 | Set width :0| 0",
	propertyName	:	"width",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"0",
	expectedResult	:	"0"
},
{
	testName		:	"VT299-1031 | Set outputFormat :dataUri| dataUri",
	propertyName	:	"outputFormat",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"dataUri",
	expectedResult	:	"dataUri"
},
{
	testName		:	"VT299-1032 | Set outputFormat :image| image",
	propertyName	:	"outputFormat",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"image",
	expectedResult	:	"image"
},
{
	testName		:	"VT299-1033 | Set penColor :#FF000000| #FF000000",
	propertyName	:	"penColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#FF000000",
	expectedResult	:	"#FF000000"
},
{
	testName		:	"VT299-1034 | Set penColor :#FF00FF| #FF00FF",
	propertyName	:	"penColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#FF00FF",
	expectedResult	:	"#FF00FF"
},
{
	testName		:	"VT299-1035 | Set penColor :#000000| #000000",
	propertyName	:	"penColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#000000",
	expectedResult	:	"#000000"
},
{
	testName		:	"VT299-1036 | Set penColor :#FFFFFFFF| #FFFFFFFF",
	propertyName	:	"penColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#FFFFFFFF",
	expectedResult	:	"#FFFFFFFF"
},
{
	testName		:	"VT299-1037 | Set penWidth :1| 1",
	propertyName	:	"penWidth",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"1",
	expectedResult	:	"1"
},
{
	testName		:	"VT299-1038 | Set penWidth :5| 5",
	propertyName	:	"penWidth",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"5",
	expectedResult	:	"5"
},
{
	testName		:	"VT299-1039 | Set penWidth :0| 0",
	propertyName	:	"penWidth",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"0",
	expectedResult	:	"0"
},
{
	testName		:	"VT299-1040 | Set penWidth :10| 10",
	propertyName	:	"penWidth",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"10",
	expectedResult	:	"10"
},
{
	testName		:	"VT299-1041 | Set penWidth :2.5| 2.5",
	propertyName	:	"penWidth",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"2.5",
	expectedResult	:	"2.5"
}

];

var sigCallback = function (data){

};

var getApplicablePropertiesShow = function (){

	var finalSIGObj = [];

	for (var i = 0; i < arr_sig_property.length ; i++){

		if((arr_sig_property[i]['OSTypes'] == 'All') || (arr_sig_property[i]['OSTypes'].indexOf(Rho.System.platform) != -1)){
			var sigType = arr_sig_property[i]['sigTypes']

			if((sigType == "All") || (sigType == "show"))
			{
				finalSIGObj.push(arr_sig_property[i]);
			}
		}
	}

	return finalSIGObj;
}

var getApplicablePropertiesFullScreen = function (){

	var finalSIGObjtake = [];

	for (var i = 0; i < arr_sig_property.length ; i++){

		if((arr_sig_property[i]['OSTypes'] == 'All') || (arr_sig_property[i]['OSTypes'].indexOf(Rho.System.platform) != -1)){
			var sigType = arr_sig_property[i]['sigTypes']

			if(sigType == "All")
			{
				finalSIGObjtake.push(arr_sig_property[i]);
			}
		}
	}

	return finalSIGObjtake;
}

var ENABLE_TIMEOUT_VALUE = (Rho.System.platform == "ANDROID" ? 1000 : 1000);<commit_msg>added ARGB test to signature auto<commit_after>var arr_sig_property = [
{
	testName		:	"VT299-1001 | Set bgColor :#FF0000| #FF0000",
	propertyName	:	"bgColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#FF0000",
	expectedResult	:	"#FF0000"
},
{
	testName		:	"VT299-1002 | Set bgColor :#0000FFFF| #0000FFFF",
	propertyName	:	"bgColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#0000FFFF",
	expectedResult	:	"#0000FFFF"
},
{
	testName		:	"VT299-1003 | Set bgColor :#00000000| #00000000",
	propertyName	:	"bgColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#000000",
	expectedResult	:	"#000000"
},
{
	testName		:	"VT299-1004 | Set bgColor :#FFFFFF| #FFFFFF",
	propertyName	:	"bgColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#FFFFFF",
	expectedResult	:	"#FFFFFF"
},
{
	testName		:	"VT299-1005 | Set border :false| false",
	propertyName	:	"border",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"false",
	expectedResult	:	"false"
},
{
	testName		:	"VT299-1006 | Set border :true| true",
	propertyName	:	"border",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"true",
	expectedResult	:	"true"
},
{
	testName		:	"VT299-1007 | Set compressionFormat :jpg| jpg",
	propertyName	:	"compressionFormat",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"jpg",
	expectedResult	:	"jpg"
},
{
	testName		:	"VT299-1008 | Set compressionFormat :png| png",
	propertyName	:	"compressionFormat",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"png",
	expectedResult	:	"png"
},
{
	testName		:	"VT299-1009 | Set compressionFormat :bmp| bmp",
	propertyName	:	"compressionFormat",
	sigTypes		:	"All",
	OSTypes			:	"WINDOWS APPLE",
	propertyValue	:	"bmp",
	expectedResult	:	"bmp"
},
{
	testName		:	"VT299-1010 | Set fileName :Test| Test",
	propertyName	:	"fileName",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"Test",
	expectedResult	:	"Test"
},
{
	testName		:	"VT299-1012 | Set fileName :Test123| Test123",
	propertyName	:	"fileName",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"Test123",
	expectedResult	:	"Test123"
},
{
	testName		:	"VT299-1013 | Set fileName :Test_123| Test_123",
	propertyName	:	"fileName",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"Test_123",
	expectedResult	:	"Test_123"
},
{
	testName		:	"VT299-1014 | Set fileName :123| 123",
	propertyName	:	"fileName",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"123",
	expectedResult	:	"123"
},
{
	testName		:	"VT299-1015 | Set fileName :signature| signature",
	propertyName	:	"fileName",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"signature",
	expectedResult	:	"signature"
},
{
	testName		:	"VT299-1016 | Set height :100| 100",
	propertyName	:	"height",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"100",
	expectedResult	:	"100"
},
{
	testName		:	"VT299-1017 | Set height :500| 500",
	propertyName	:	"height",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"500",
	expectedResult	:	"500"
},
{
	testName		:	"VT299-1018 | Set height :150| 150",
	propertyName	:	"height",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"150",
	expectedResult	:	"150"
},
{
	testName		:	"VT299-1019 | Set height :0| 0",
	propertyName	:	"height",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"0",
	expectedResult	:	"0"
},
{
	testName		:	"VT299-1020 | Set left :90| 90",
	propertyName	:	"left",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"90",
	expectedResult	:	"90"
},
{
	testName		:	"VT299-1021 | Set left :550| 550",
	propertyName	:	"left",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"550",
	expectedResult	:	"550"
},
{
	testName		:	"VT299-1022 | Set left :15| 15",
	propertyName	:	"left",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"15",
	expectedResult	:	"15"
},
{
	testName		:	"VT299-1022 | Set left :0| 0",
	propertyName	:	"left",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"0",
	expectedResult	:	"0"
},
{
	testName		:	"VT299-1023 | Set top :50| 50",
	propertyName	:	"top",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"50",
	expectedResult	:	"50"
},
{
	testName		:	"VT299-1024 | Set top :150| 150",
	propertyName	:	"top",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"150",
	expectedResult	:	"150"
},
{
	testName		:	"VT299-1025 | Set top :60| 60",
	propertyName	:	"top",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"60",
	expectedResult	:	"60"
},
{
	testName		:	"VT299-1026 | Set top :0| 0",
	propertyName	:	"top",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"0",
	expectedResult	:	"0"
},
{
	testName		:	"VT299-1027 | Set width :140| 140",
	propertyName	:	"width",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"140",
	expectedResult	:	"140"
},
{
	testName		:	"VT299-1028 | Set width :450| 450",
	propertyName	:	"width",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"450",
	expectedResult	:	"450"
},
{
	testName		:	"VT299-1029 | Set width :200| 200",
	propertyName	:	"width",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"200",
	expectedResult	:	"200"
},
{
	testName		:	"VT299-1030 | Set width :0| 0",
	propertyName	:	"width",
	sigTypes		:	"show",
	OSTypes			:	"All",
	propertyValue	:	"0",
	expectedResult	:	"0"
},
{
	testName		:	"VT299-1031 | Set outputFormat :dataUri| dataUri",
	propertyName	:	"outputFormat",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"dataUri",
	expectedResult	:	"dataUri"
},
{
	testName		:	"VT299-1032 | Set outputFormat :image| image",
	propertyName	:	"outputFormat",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"image",
	expectedResult	:	"image"
},
{
	testName		:	"VT299-1033 | Set penColor :#FF000000| #FF000000",
	propertyName	:	"penColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#FF000000",
	expectedResult	:	"#FF000000"
},
{
	testName		:	"VT299-1034 | Set penColor :#FF00FF| #FF00FF",
	propertyName	:	"penColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#FF00FF",
	expectedResult	:	"#FF00FF"
},
{
	testName		:	"VT299-1035 | Set penColor :#000000| #000000",
	propertyName	:	"penColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#000000",
	expectedResult	:	"#000000"
},
{
	testName		:	"VT299-1036 | Set penColor :#FFFFFFFF| #FFFFFFFF",
	propertyName	:	"penColor",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"#FFFFFFFF",
	expectedResult	:	"#FFFFFFFF"
},
{
	testName		:	"VT299-1037 | Set penWidth :1| 1",
	propertyName	:	"penWidth",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"1",
	expectedResult	:	"1"
},
{
	testName		:	"VT299-1038 | Set penWidth :5| 5",
	propertyName	:	"penWidth",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"5",
	expectedResult	:	"5"
},
{
	testName		:	"VT299-1039 | Set penWidth :0| 0",
	propertyName	:	"penWidth",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"0",
	expectedResult	:	"0"
},
{
	testName		:	"VT299-1040 | Set penWidth :10| 10",
	propertyName	:	"penWidth",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"10",
	expectedResult	:	"10"
},
{
	testName		:	"VT299-1041 | Set penWidth :2.5| 2.5",
	propertyName	:	"penWidth",
	sigTypes		:	"All",
	OSTypes			:	"All",
	propertyValue	:	"2.5",
	expectedResult	:	"2.5"
}

];

var sigCallback = function (data){

};

var getApplicablePropertiesShow = function (){

	var finalSIGObj = [];

	for (var i = 0; i < arr_sig_property.length ; i++){

		if((arr_sig_property[i]['OSTypes'] == 'All') || (arr_sig_property[i]['OSTypes'].indexOf(Rho.System.platform) != -1)){
			var sigType = arr_sig_property[i]['sigTypes']

			if((sigType == "All") || (sigType == "show"))
			{
				finalSIGObj.push(arr_sig_property[i]);
			}
		}
	}

	return finalSIGObj;
}

var getApplicablePropertiesFullScreen = function (){

	var finalSIGObjtake = [];

	for (var i = 0; i < arr_sig_property.length ; i++){

		if((arr_sig_property[i]['OSTypes'] == 'All') || (arr_sig_property[i]['OSTypes'].indexOf(Rho.System.platform) != -1)){
			var sigType = arr_sig_property[i]['sigTypes']

			if(sigType == "All")
			{
				finalSIGObjtake.push(arr_sig_property[i]);
			}
		}
	}

	return finalSIGObjtake;
}

var ENABLE_TIMEOUT_VALUE = (Rho.System.platform == "ANDROID" ? 1000 : 1000);<|endoftext|>