Sha256: 212e04a6931fc4396a2e686d61133ec043f2ac8dfd22705cd31426132b778e33

Contents?: true

Size: 1.59 KB

Versions: 104

Compression:

Stored size: 1.59 KB

Contents

var Robot = require('./robot-name');

describe('Robot', function () {
  // NOTE: The 'beforeEach()' and 'afterEach()' act as setup/teardown for this
  // test suite. See more: http://jasmine.github.io/2.0/introduction.html
  var robot;

  beforeEach(function () {
    robot = new Robot();
  });

  afterEach(function () {
    robot = null;
  });

  it('has a name', function () {
    expect(robot.name).toMatch(/^[A-Z]{2}\d{3}$/);
  });

  xit('name is the same each time', function () {
    expect(robot.name).toEqual(robot.name);
  });

  xit('different robots have different names', function () {
    var differentRobot = new Robot();
    expect(differentRobot.name).not.toEqual(robot.name);
  });

  xit('is able to reset the name', function () {
    var originalName = robot.name;
    robot.reset();
    var newName = robot.name;
    expect(newName).toMatch(/^[A-Z]{2}\d{3}$/);
    expect(originalName).not.toEqual(newName);
  });

  xit('should set a unique name after reset', function () {
    var i;
    var numResets = 10000;
    var usedNames = {};

    usedNames[robot.name] = true;

    for (i = 0; i < numResets; i++) {
      robot.reset();
      usedNames[robot.name] = true;
    }

    expect(Object.keys(usedNames).length).toEqual(numResets + 1);
  });

  // This test is optional.
  xit('there can be lots of robots with different names each', function () {
    var i;
    var numRobots = 10000;
    var usedNames = {};

    for (i = 0; i < numRobots; i++) {
      var newRobot = new Robot();
      usedNames[newRobot.name] = true;
    }

    expect(Object.keys(usedNames).length).toEqual(numRobots);
  });
});

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.158 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.157 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.156 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.155 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.154 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.153 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.152 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.151 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.150 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.149 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.148 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.147 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.146 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.145 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.144 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.143 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.142 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.141 tracks/javascript/exercises/robot-name/robot-name.spec.js
trackler-2.2.1.140 tracks/javascript/exercises/robot-name/robot-name.spec.js