module("", {
setup: function () {
  this.fruits = ['tomato', 'apple', 'apricot'];
  this.fruitsExt = ['tomato', 'apple', 'cucumbers', 'apricot', 'tomato'];
  this.vegetables = ['tomato', 'cucumbers'];
  this.botanicalFruits = ['pumpkins', 'avocado', 'tomato'];
}
});

test('Working with 2 arrays', function () {
  same(array_big_intersect(this.vegetables, this.fruits), ['tomato'], 'Arrays of String: first array smaller than the second');
  same(array_big_intersect(this.fruits, this.vegetables), ['tomato'], 'Arrays of String: first array larger than the second');
  same(array_big_intersect(['a', ' ', 'b'], ['b', ' ']).sort(), [' ', 'b'], 'Arrays of String with a space character intersection');
  same(array_big_intersect([1, 2, 3], [0, 4, 7, 3, 6]), [3], 'Array of Number: first array smaller than the second');
  same(array_big_intersect([0, 4, 7, 3, 6], [1, 2, 3]), [3], 'Array of Number: first array larger than the second');
  same(array_big_intersect([0, 4, 7, -3, 2], [1, 2, -3]).sort(), [-3, 2], 'Array with negative numbers');
  same(array_big_intersect([1, 1, 2], [3, 1]), [1], 'Array of Number: multiple occurrence in one array');
  same(array_big_intersect([1, 1, 2], [3, 1, 1]), [1], 'Array of Number: multiple occurrence in all arrays');
  same(array_big_intersect([1, 1, 2, 1, 1, 1, 1, 1], [3, 1, 1]), [1], 'Multiple occurrences exceed the number of arrays');
  same(array_big_intersect([0, 2, 3], [8, 9, 0, 2]).sort(), [0, 2], 'Intersection contains 0');
  same(array_big_intersect([0, 2, 3], []), [], 'With an empty array');
  same(array_big_intersect([], []), [], 'Only empty arrays');
  same(array_big_intersect(["a"], ["b"]), [], 'Nothing to take');
  same(array_big_intersect(["a", "c"], ["b"]), [], 'Nothing to take');
  same(array_big_intersect(["a", true], ["b", true]), [true], 'Take a boolean true intersection');
  same(array_big_intersect(["a", false], ["b", false]), [false], 'Take a boolean false intersection');
  same(array_big_intersect(["a", null], ["b", null]), [null], 'Take null as intersection');
  same(array_big_intersect(
    [1, true, 3, null, 101], [null, 101, false, true, 10]).sort(),
    [101, null, true],
    'Mixed content');
});

test('Working with 3 arrays', function () {
  same(array_big_intersect(this.vegetables, this.fruits, this.vegetables), ['tomato'], 'Arrays of String: first array smaller than others');
  same(array_big_intersect(this.fruits, this.vegetables, this.botanicalFruits), ['tomato'], 'Arrays of String: first array larger than others');
  same(array_big_intersect(['a', ' ', 'b'], ['b', ' '], [' ', 'b']).sort(), [' ', 'b'], 'Arrays of String with a space character intersection');
  same(array_big_intersect([1, 2, 3], [0, 4, 7, 3, 6], [8, 3, 9]), [3], 'Array of Number: first array smaller than others');
  same(array_big_intersect([0, 4, 7, 3, 6], [1, 2, 3], [8, 3, 9]), [3], 'Array of Number: first array larger than others');
  same(array_big_intersect([0, 4, 7, -3, 2], [1, 2, -3], [8, -3, 2]).sort(), [-3, 2], 'Array with negative numbers');
  same(array_big_intersect([1, 1, 2], [3, 1], [8, 1, 9]), [1], 'Array of Number: multiple occurrence in one array');
  same(array_big_intersect([1, 1, 2], [3, 1, 1], [8, 1, 1]), [1], 'Array of Number: multiple occurrence in all arrays');
  same(array_big_intersect([1, 1, 2, 1, 1, 1, 1, 1], [3, 1, 1], [8, 1, 1]), [1], 'Multiple occurrences exceed the number of arrays');
  same(array_big_intersect([0, 2, 3], [8, 9, 0, 2], [1, 2, 7, 0]).sort(), [0, 2], 'Intersection contains 0');
  same(array_big_intersect([0, 2, 3], [], [8, 3, 9]), [], 'With an empty array');
  same(array_big_intersect([], [], []), [], 'Only empty arrays');
  same(array_big_intersect(["a"], ["b"], ["c"]), [], 'Nothing to take');
  same(array_big_intersect(["a", "c"], ["b"], ["d", "e", "f"]), [], 'Nothing to take');
  same(array_big_intersect(["a", true], ["b", true], [true, "c"]), [true], 'Take a boolean true intersection');
  same(array_big_intersect(["a", false], ["b", false], ["c", false]), [false], 'Take a boolean false intersection');
  same(array_big_intersect(["a", null], ["b", null], ["c", null]), [null], 'Take null as intersection');
  same(array_big_intersect(
    [1, true, 3, null, 101], [null, 101, false, true, 10], [2, true, 101, null]).sort(),
    [101, null, true],
    'Mixed content');
});

