<commit_before>'use strict';
const Color = require('../src/color');
const Scheme = require('../src/scheme');

describe('Scheme', ()=>{

describe('instantiation', ()=>{
  it('should create an empty scheme', ()=>{
    let scheme = new Scheme();
    expect(scheme instanceof Object).toBe(true);
    expect(scheme.colors[0].base).toEqual(new Color());
    expect(scheme.name).toBeUndefined();
  });

  it('should create and initializate an scheme', ()=>{
    let scheme, config;
    config = {
      name: 'test',
      colors:[{base: (new Color()).toJSON()}]
    };
    scheme = new Scheme(config);
    expect(scheme.name).toBe(config.name);
    expect(scheme.colors).toBeDefined();
    expect(scheme.colors[0].base).toEqual((new Color()).toJSON());
  });
});// <<< instantiation

describe('populate colors methods', ()=>{
  it('should generate secundary colors given a harmony function', ()=>{
    let scheme = new Scheme();
    scheme.configure('triadic');
    scheme.generate();
    expect(scheme.colors).toBeDefined();
    expect(scheme.colors instanceof Array).toBe(true);
    expect(scheme.colors.length).toBe(3);
  });

  it('should generate 3 shades for each color in the scheme', ()=>{
    let scheme = new Scheme();
    scheme.generateShades(3);
    scheme.colors.forEach((color)=>{
      expect(color.shades).toBeDefined();
      expect(color.shades instanceof Array).toBe(true);
      expect(color.shades.length).toBe(3);
    });
  });

  it('should generate 3 tints for each color in the scheme', ()=>{
    let scheme = new Scheme();
    scheme.generateTints(3);
    scheme.colors.forEach((color)=>{
      expect(color.tints).toBeDefined();
      expect(color.tints instanceof Array).toBe(true);
      expect(color.tints.length).toBe(3);
    });
  });

  it('should generate 3 tones for each color in the scheme', ()=>{
    let scheme = new Scheme();
    scheme.generateTones(3);
    scheme.colors.forEach((color)=>{
      expect(color.tones).toBeDefined();
      expect(color.tones instanceof Array).toBe(true);
      expect(color.tones.length).toBe(3);
    });
  });
});// <<< populate colors methods

describe('modifiers', ()=>{

  it('should name an scheme', ()=>{
    let scheme = new Scheme(),
        name = 'test';
    scheme.setName(name);
    expect(scheme.name).toBeDefined();
    expect(scheme.getName()).toBe(name);
  });

  it('should reset scheme to initial default values', ()=>{
    let scheme = new Scheme({name: 'test'});
    scheme.reset();
    expect(scheme.name).toBeUndefined();
  });

  it('should rotate hue wheel of all colors', ()=>{
    let scheme = new Scheme(),
        clone = scheme.clone(),
        angle = 0.5,
        hue = clone.colors[0].base.rotateHueWheel(angle).getHSV().h;

    scheme.rotate(angle);
    expect(hue)
      .toEqual(scheme.colors[0].base.getHSV().h);
  });
});// <<< modifiers

it('should clone the scheme',()=>{
  let scheme = new Scheme(),
      clone = scheme.clone();

  expect(clone).toEqual(scheme);
  expect(clone).not.toBe(scheme);
});


<commit_msg>Fix unit test<commit_after>'use strict';
const Color = require('../src/color');
const Scheme = require('../src/scheme');

describe('Scheme', ()=>{

describe('instantiation', ()=>{
  it('should create an empty scheme', ()=>{
    let scheme = new Scheme();
    expect(scheme instanceof Object).toBe(true);
    expect(scheme.colors[0].base).toEqual(new Color());
    expect(scheme.name).toBeUndefined();
  });

  it('should create and initializate an scheme', ()=>{
    let scheme, config;
    config = {
      name: 'test',
      colors:[{base: (new Color()).toJSON()}]
    };
    scheme = new Scheme(config);
    expect(scheme.name).toBe(config.name);
    expect(scheme.colors).toBeDefined();
    expect(scheme.colors[0].base).toEqual((new Color()).toJSON());
  });
});// <<< instantiation

describe('populate colors methods', ()=>{
  it('should generate secundary colors given a harmony function', ()=>{
    let scheme = new Scheme();
    scheme.configure('triadic');
    scheme.generate();
    expect(scheme.colors).toBeDefined();
    expect(scheme.colors instanceof Array).toBe(true);
    expect(scheme.colors.length).toBe(3);
  });

  it('should generate 3 shades for each color in the scheme', ()=>{
    let scheme = new Scheme();
    scheme.generateShades(3);
    scheme.colors.forEach((color)=>{
      expect(color.shades).toBeDefined();
      expect(color.shades instanceof Array).toBe(true);
      expect(color.shades.length).toBe(3);
    });
  });

  it('should generate 3 tints for each color in the scheme', ()=>{
    let scheme = new Scheme();
    scheme.generateTints(3);
    scheme.colors.forEach((color)=>{
      expect(color.tints).toBeDefined();
      expect(color.tints instanceof Array).toBe(true);
      expect(color.tints.length).toBe(3);
    });
  });

  it('should generate 3 tones for each color in the scheme', ()=>{
    let scheme = new Scheme();
    scheme.generateTones(3);
    scheme.colors.forEach((color)=>{
      expect(color.tones).toBeDefined();
      expect(color.tones instanceof Array).toBe(true);
      expect(color.tones.length).toBe(3);
    });
  });
});// <<< populate colors methods

describe('modifiers', ()=>{

  it('should name an scheme', ()=>{
    let scheme = new Scheme(),
        name = 'test';
    scheme.setName(name);
    expect(scheme.name).toBeDefined();
    expect(scheme.getName()).toBe(name);
  });

  it('should reset scheme to initial default values', ()=>{
    let scheme = new Scheme({name: 'test'});
    scheme.reset();
    expect(scheme.name).toBeUndefined();
  });

  it('should rotate hue wheel of all colors', ()=>{
    let scheme = new Scheme(),
        clone = scheme.clone(),
        angle = 0.5,
        hue = clone.colors[0].base.rotateHueWheel(angle).getHSV().h;

    scheme.rotate(angle);
    expect(scheme.colors[0].base.getHSV().h).toEqual(hue - angle);
  });

  it('should set the saturation value to all colors in the scheme',()=>{
    let saturation = 0.5,
        scheme = new Scheme();
    scheme.setSaturation(saturation);
    expect(scheme.colors[0].base.getHSV().s).toBeCloseTo(saturation, 1);
  });

  it('should set the value to all colors in the scheme',()=>{
    let value = 0.5,
        scheme = new Scheme();
    scheme.flatten(value);
    expect(scheme.colors[0].base.getHSV().v).toBeCloseTo(value, 1);
  });

});// <<< modifiers

it('should clone the scheme',()=>{
  let scheme = new Scheme(),
      clone = scheme.clone();

  expect(clone).toEqual(scheme);
  expect(clone).not.toBe(scheme);
});



{'fraction_non_alphanumeric': 0.18560024562480812, 'fraction_numerical': 0.006140620202640466, 'mean_word_length': 3.514899514899515, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 39, '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': '5236839', 'n_tokens_mistral': 2082, 'n_tokens_neox': 1987, 'n_words': 435}