<commit_before>'use strict';

import { Clickers } from '../../app/services/clickers';

export function main() {

  describe('Clickers', () => {
    it('initialises with empty clickers', () => {
      let clickers = new Clickers();
      expect(clickers.getClickers()).toEqual([]);
    });

    it('returns undefined for a bad id', () => {
      let clickers = new Clickers();
      expect(clickers.getClicker('1234')).not.toBeDefined();
    });
  });
};<commit_msg>Adding more unit tests, only thing that persists is persistant storage..<commit_after>'use strict';

import { Clickers } from '../../app/services/clickers';

export function main() {

  describe('Clickers', () => {

    it('initialises with empty clickers', () => {
      let clickers = new Clickers();
      expect(clickers.getClickers()).toEqual([]);
    });

    it('has empty ids set on init', () => {
      let clickers = new Clickers();
      (<any>clickers).initIds()
        .then(() => {
          expect(clickers.getClickers()).toEqual([]);
        });
    });

    it('has empty clickers on init', () => {
      let clickers = new Clickers();
      (<any>clickers).initClickers()
        .then(() => {
          expect(clickers.getClickers()).toEqual([]);
        });
    });

    it('can initialise a clicker from string', () => {
      let clickerString = '{"id":"0g2vt8qtlm","name":"harold","clicks":[{"time":1450410168819,"location":"TODO"},{"time":1450410168945,"location":"TODO"}]}';
      let clickers = new Clickers();
      let clicker = (<any>clickers).initClicker(clickerString);
      expect(clicker.getName()).toEqual('harold');
      expect(clicker.getCount()).toEqual(2);
    });

    it('returns undefined for a bad id', () => {
      let clickers = new Clickers();
      expect(clickers.getClicker('dave')).not.toBeDefined();
    });

    it('adds a new clicker with the correct name', () => {
      let clickers = new Clickers();
      clickers.newClicker('dave');
      expect(clickers.getClickers()[0].getName()).toEqual('dave');
    });

    it('removes a clicker by id', () => {
      let clickers = new Clickers();
      let idToRemove = clickers.newClicker('dave');
      clickers.removeClicker(idToRemove);
      expect(clickers.getClickers()).toEqual([]);
    });

    it('does a click', () => {
      let clickers = new Clickers();
      let idToClick = clickers.newClicker('dave');
      let clickedClicker = null;
      clickers.doClick(idToClick);
      clickedClicker = clickers.getClicker(idToClick);
      expect(clickedClicker.getCount()).toEqual(1);
    });

  });
};
{'fraction_non_alphanumeric': 0.18735453840186192, 'fraction_numerical': 0.013964313421256789, 'mean_word_length': 3.1264, 'pattern_counts': {'":': 7, '<': 6, '<?xml version=': 0, '>': 20, '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': '5918220', 'n_tokens_mistral': 814, 'n_tokens_neox': 792, 'n_words': 158}