var Anagram = require('./anagram');

describe('Anagram', function() {

  it("no matches",function() {
    var detector = new Anagram("diaper");
    var matches = detector.match([ "hello", "world", "zombies", "pants"]);
    expect(matches).toEqual([]);
  });

  xit("detects simple anagram",function() {
    var detector = new Anagram("ba");
    var matches = detector.match(['ab', 'abc', 'bac']);
    expect(matches).toEqual(['ab']);
  });

  xit("detects multiple anagrams",function() {
    var detector = new Anagram("abc");
    var matches = detector.match(['ab', 'abc', 'bac']);
    expect(matches).toEqual(['abc', 'bac']);
  });

  xit("detects anagram",function() {
    var detector = new Anagram("listen");
    var matches = detector.match(['enlists', 'google', 'inlets', 'banana']);
    expect(matches).toEqual(['inlets']);
  });

  xit("detects multiple anagrams",function() {
    var detector = new Anagram("allergy");
    var matches = detector.match(['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading']);
    expect(matches).toEqual(['gallery', 'regally', 'largely']);
  });
});
var Anagram = require('./anagram');

describe('Anagram', function() {

  it("no matches",function() {
    var detector = new Anagram("diaper");
    var matches = detector.match([ "hello", "world", "zombies", "pants"]);
    expect(matches).toEqual([]);
  });

  xit("detects simple anagram",function() {
    var detector = new Anagram("ba");
    var matches = detector.match(['ab', 'abc', 'bac']);
    expect(matches).toEqual(['ab']);
  });
  
  xit("does not detect false positives",function() {
    var detector = new Anagram("bba");
    var matches = detector.match(["aab"]);
    expect(matches).toEqual([]);
  });

  xit("detects multiple anagrams",function() {
    var detector = new Anagram("abc");
    var matches = detector.match(['ab', 'abc', 'bac']);
    expect(matches).toEqual(['abc', 'bac']);
  });

  xit("detects anagram",function() {
    var detector = new Anagram("listen");
    var matches = detector.match(['enlists', 'google', 'inlets', 'banana']);
    expect(matches).toEqual(['inlets']);
  });

  xit("detects multiple anagrams",function() {
    var detector = new Anagram("allergy");
    var matches = detector.match(['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading']);
    expect(matches).toEqual(['gallery', 'regally', 'largely']);
  });
});

Add test for same length, same letters, different letter instance counts
Add test for same length, same letters, different letter instance counts

One possible solution to detecting an anagram might be to check to see if the words are the same length and that each letter from the first word is contained in the second word. This additional test would guard against that solution appearing to work.

I wasn't sure in what position in the test sequence it ought to go, or what the exact test description should be. Feel free to suggest changes.