<commit_before>describe('Knight', function() {
  var Knight = require('../../lib/models/knight.js');
  var Enemy = require('../../lib/models/knight.js');

  beforeEach(function() {
    knight = Knight();
    enemy = Enemy();
  });

  it("should be able to attack and cause damage to enemies", function() {
    knight.attack(enemy);

    expect(enemy.health()).toEqual(950);
  });

  describe("when defending", function() {
    beforeEach(function() {
      knight.defend();
    });
    
    it("should take no damage from attacks", function() {
      enemy.attack(knight);

      expect(knight.health()).toEqual(1000);
    });

    it("should take damage on subsequent attacks, after successfully blocking an attack", function() {
      enemy.attack(knight);
      enemy.attack(knight);

      expect(knight.health()).toEqual(950);
    });
  });

  describe("when running", function() {
    beforeEach(function() {
      knight.run();
    });

    it("should take 50% more damage", function() {
      enemy.attack(knight);

      expect(knight.health()).toEqual(925);
    });

    it("should stop running and take normal damage when they attack", function() {
      knight.attack(enemy);
      enemy.attack(knight);

      expect(knight.health()).toEqual(950);
    });

    it("should stop running and take normal damage when they defend", function() {
      knight.defend();
      enemy.attack(knight);

      expect(knight.health()).toEqual(950);
    });
  });
});
<commit_msg>Adds spec for Knight taking damage<commit_after>describe('Knight', function() {
  var Knight = require('../../lib/models/knight.js');
  var Enemy = require('../../lib/models/knight.js');

  beforeEach(function() {
    knight = Knight();
    enemy = Enemy();
  });

  it("should be able to attack and cause damage to enemies", function() {
    knight.attack(enemy);

    expect(enemy.health()).toEqual(950);
  });

  it("should be able to take damage from enemies when attacked", function() {
    enemy.attack(knight);

    expect(knight.health()).toEqual(950);
  })

  describe("when defending", function() {
    beforeEach(function() {
      knight.defend();
    });
    
    it("should take no damage from attacks", function() {
      enemy.attack(knight);

      expect(knight.health()).toEqual(1000);
    });

    it("should take damage on subsequent attacks, after successfully blocking an attack", function() {
      enemy.attack(knight);
      enemy.attack(knight);

      expect(knight.health()).toEqual(950);
    });
  });

  describe("when running", function() {
    beforeEach(function() {
      knight.run();
    });

    it("should take 50% more damage", function() {
      enemy.attack(knight);

      expect(knight.health()).toEqual(925);
    });

    it("should stop running and take normal damage when they attack", function() {
      knight.attack(enemy);
      enemy.attack(knight);

      expect(knight.health()).toEqual(950);
    });

    it("should stop running and take normal damage when they defend", function() {
      knight.defend();
      enemy.attack(knight);

      expect(knight.health()).toEqual(950);
    });
  });
});

{'fraction_non_alphanumeric': 0.16794380587484037, 'fraction_numerical': 0.014367816091954023, 'mean_word_length': 3.068831168831169, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1764945', 'n_tokens_mistral': 979, 'n_tokens_neox': 925, 'n_words': 210}