{"size": 2281, "ext": "js", "max_stars_repo_path": "challenges/leftJoin/__tests__/left-join.test.js", "max_stars_repo_name": "jquaglia/data-structures-and-algorithms-401", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "challenges/leftJoin/__tests__/left-join.test.js", "max_issues_repo_name": "jquaglia/data-structures-and-algorithms-401", "max_issues_repo_issues_event_min_datetime": "2021-02-15T23:42:08.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-23T23:07:12.000Z", "max_forks_repo_path": "challenges/leftJoin/__tests__/left-join.test.js", "max_forks_repo_name": "jquaglia/data-structures-and-algorithms-401", "max_forks_repo_forks_event_min_datetime": "2021-05-22T16:20:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-22T16:20:15.000Z"}
{"max_stars_count": null, "max_issues_count": 4, "max_forks_count": 1, "avg_line_length": 30.8243243243, "max_line_length": 131, "alphanum_fraction": 0.5795703639}
'use strict';

const hash = require('../../hashtable/hashtable.js');
const join = require('../left-join.js');

const synonyms = new hash.HashTable(1024);
const antonyms = new hash.HashTable(1024);

synonyms.add('fond', 'enamored');
synonyms.add('wrath', 'anger');
synonyms.add('diligent', 'employed');
synonyms.add('outfit', 'garb');
synonyms.add('guide', 'usher');

antonyms.add('fond', 'adverse');
antonyms.add('wrath', 'delight');
antonyms.add('diligent', 'idle');
antonyms.add('guide', 'follow');
antonyms.add('flow', 'jam');


describe('Testing leftJoin function', () => {
  it('Should return all keys and values from left hashtable', () => {
    const test = join(synonyms, antonyms, 'left');

    expect(test.length).toBeTruthy();
    expect(test).toEqual([
      [ 'diligent', 'employed', 'idle' ],
      [ 'outfit', 'garb', null ],
      [ 'fond', 'enamored', 'adverse' ],
      [ 'guide', 'usher', 'follow' ],
      [ 'wrath', 'anger', 'delight' ]
    ]);
  });

  it('Should return all values from right hashtable that exist in current left join. Should return null where they do not', () => {
    const test = join(synonyms, antonyms, 'left');

    expect(test.length).toBeTruthy();
    expect(test).toEqual([
      [ 'diligent', 'employed', 'idle' ],
      [ 'outfit', 'garb', null ],
      [ 'fond', 'enamored', 'adverse' ],
      [ 'guide', 'usher', 'follow' ],
      [ 'wrath', 'anger', 'delight' ]
    ]);
  });

  it('Should return all keys and values from right hashtable', () => {
    const test = join(synonyms, antonyms, 'right');

    expect(test.length).toBeTruthy();
    expect(test).toEqual([
      [ 'diligent', 'idle', 'employed' ],
      [ 'flow', 'jam', null ],
      [ 'fond', 'adverse', 'enamored' ],
      [ 'guide', 'follow', 'usher' ],
      [ 'wrath', 'delight', 'anger' ]
    ]);
  });

  it('Should return all values from left hashtable that exist in current right join. Should return null where they do not', () => {
    const test = join(synonyms, antonyms, 'right');

    expect(test.length).toBeTruthy();
    expect(test).toEqual([
      [ 'diligent', 'idle', 'employed' ],
      [ 'flow', 'jam', null ],
      [ 'fond', 'adverse', 'enamored' ],
      [ 'guide', 'follow', 'usher' ],
      [ 'wrath', 'delight', 'anger' ]
    ]);
  });
});