<commit_before>const chai = require('chai');
const assert = chai.assert;
const ScoreBoard = require('../lib/scoreBoard');

describe("ScoreBoard", function(){

  context("with default attributes", function(){

    it('should be instantiated', function(){
      let scoreBoard = new ScoreBoard();
      assert.isObject(scoreBoard);
    });

    it('should have newScore property', function(){
      let scoreBoard = new ScoreBoard();
      assert.isNull(scoreBoard.newScore);
    });
  });

  context("with calculatedAttribute", function(){

    it('should have currentHighScores property', function(){
      let scoreBoard = new ScoreBoard();
      assert.isNotNull(scoreBoard.currentHighScores);
    });
  });
});

describe("lowestScore()", function(){

  it('should return lowest high score', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~7", "Kerry~1"];
    assert.equal(scoreBoard.lowestScore(), 1);
  });
});

describe("roomAvailable()", function(){

  it('should return true if less than 10 high scores', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~1", "Kerry~8"];
    assert(scoreBoard.roomAvailable());
  });

  it('should returns false if 10 high scores', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~1", "Kerry~8", "Kerry~2", "Kerry~1", "Kerry~8", "Kerry~2", "Kerry~1", "Kerry~8", "Kerry~8"];
    assert.equal(scoreBoard.roomAvailable(), false);
  });
});

describe("numHighScores()", function(){

  it('should return number of high scores', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~1", "Kerry~8"];
    assert.equal(scoreBoard.numHighScores(), 3);
  });
});


describe("updateHighScores()", function(){

  it('should add a new high score', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~1", "Kerry~8"];
    scoreBoard.newScore = 9;
    scoreBoard.updateHighScores("Jenny");
    assert.equal(scoreBoard.numHighScores(), 4);
  });

  it('should order high scores in desc order', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~1", "Kerry~8"];
    scoreBoard.newScore = 9;
    scoreBoard.updateHighScores("Jenny");
    assert.equal(scoreBoard.currentHighScores[0], "Jenny~9");
    assert.equal(scoreBoard.currentHighScores[1], "Kerry~8");
  });

  it('should only keep 10 high scores', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~1", "Kerry~8", "Kerry~2", "Kerry~1", "Kerry~8", "Kerry~2", "Kerry~1", "Kerry~8", "Kerry~8"];
    scoreBoard.newScore = 9;
    scoreBoard.updateHighScores("Jenny");
    assert.equal(scoreBoard.currentHighScores.length, 10);
  });
});<commit_msg>Add delete local storage method to test to clear out high scores when test suite is run<commit_after>const chai = require('chai');
const assert = chai.assert;
const ScoreBoard = require('../lib/scoreBoard');

describe("ScoreBoard", function(){

  context("with default attributes", function(){

    it('should be instantiated', function(){
      let scoreBoard = new ScoreBoard();
      assert.isObject(scoreBoard);
    });

    it('should have newScore property', function(){
      let scoreBoard = new ScoreBoard();
      assert.isNull(scoreBoard.newScore);
    });
  });

  context("with calculatedAttribute", function(){

    it('should have currentHighScores property', function(){
      let scoreBoard = new ScoreBoard();
      assert.isNotNull(scoreBoard.currentHighScores);
    });
  });
});

describe("lowestScore()", function(){

  it('should return lowest high score', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~7", "Kerry~1"];
    assert.equal(scoreBoard.lowestScore(), 1);
  });
});

describe("roomAvailable()", function(){

  it('should return true if less than 10 high scores', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~1", "Kerry~8"];
    assert(scoreBoard.roomAvailable());
  });

  it('should returns false if 10 high scores', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~1", "Kerry~8", "Kerry~2", "Kerry~1", "Kerry~8", "Kerry~2", "Kerry~1", "Kerry~8", "Kerry~8"];
    assert.equal(scoreBoard.roomAvailable(), false);
  });
});

describe("numHighScores()", function(){

  it('should return number of high scores', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~1", "Kerry~8"];
    assert.equal(scoreBoard.numHighScores(), 3);
  });
});


describe("updateHighScores()", function(){

  it('should add a new high score', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~1", "Kerry~8"];
    scoreBoard.newScore = 9;
    scoreBoard.updateHighScores("Jenny");
    assert.equal(scoreBoard.numHighScores(), 4);
  });

  it('should order high scores in desc order', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~1", "Kerry~8"];
    scoreBoard.newScore = 9;
    scoreBoard.updateHighScores("Jenny");
    assert.equal(scoreBoard.currentHighScores[0], "Jenny~9");
    assert.equal(scoreBoard.currentHighScores[1], "Kerry~8");
  });

  it('should only keep 10 high scores', function(){
    let scoreBoard = new ScoreBoard();
    scoreBoard.currentHighScores = ["Kerry~2", "Kerry~1", "Kerry~8", "Kerry~2", "Kerry~1", "Kerry~8", "Kerry~2", "Kerry~1", "Kerry~8", "Kerry~8"];
    scoreBoard.newScore = 9;
    scoreBoard.updateHighScores("Jenny");
    assert.equal(scoreBoard.currentHighScores.length, 10);
    localStorage.clear();
  });
});
{'fraction_non_alphanumeric': 0.17559322033898306, 'fraction_numerical': 0.017966101694915255, 'mean_word_length': 4.701449275362319, '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': '3065649', 'n_tokens_mistral': 1958, 'n_tokens_neox': 1845, 'n_words': 421}