// Copyright (C) 2023 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import {FuzzyFinder, fuzzyMatch} from './fuzzy';

describe('FuzzyFinder', () => {
  const items = ['aaa', 'aba', 'zzz', 'c z d z e', 'CAPS', 'ababc'];
  const finder = new FuzzyFinder(items, (x) => x);

  it('finds all for empty search term', () => {
    const result = finder.find('');
    // Expect all results are returned in original order.
    expect(result).toEqual([
      {item: 'aaa', segments: [{matching: false, value: 'aaa'}]},
      {item: 'aba', segments: [{matching: false, value: 'aba'}]},
      {item: 'zzz', segments: [{matching: false, value: 'zzz'}]},
      {item: 'c z d z e', segments: [{matching: false, value: 'c z d z e'}]},
      {item: 'CAPS', segments: [{matching: false, value: 'CAPS'}]},
      {item: 'ababc', segments: [{matching: false, value: 'ababc'}]},
    ]);
  });

  it('finds exact match', () => {
    const result = finder.find('aaa');
    expect(result).toEqual(
      expect.arrayContaining([
        {item: 'aaa', segments: [{matching: true, value: 'aaa'}]},
      ]),
    );
  });

  it('finds approx matches', () => {
    const result = finder.find('aa');
    // Allow finding results in any order.
    expect(result).toEqual(
      expect.arrayContaining([
        {
          item: 'aaa',
          // Either |aa|a or a|aa| is valid.
          segments: expect.arrayContaining([
            {matching: true, value: 'aa'},
            {matching: false, value: 'a'},
          ]),
        },
        {
          item: 'aba',
          segments: [
            {matching: true, value: 'a'},
            {matching: false, value: 'b'},
            {matching: true, value: 'a'},
          ],
        },
      ]),
    );
  });

  it('does not find completely unrelated items', () => {
    // |zzz| looks nothing like |aa| and should not be returned.
    const result = finder.find('aa');
    expect(result).not.toEqual(
      expect.arrayContaining([expect.objectContaining({item: 'zzz'})]),
    );
  });

  it('finds non-consecutive matches', () => {
    const result = finder.find('cde');
    expect(result).toEqual(
      expect.arrayContaining([
        {
          item: 'c z d z e',
          segments: [
            {matching: true, value: 'c'},
            {matching: false, value: ' z '},
            {matching: true, value: 'd'},
            {matching: false, value: ' z '},
            {matching: true, value: 'e'},
          ],
        },
      ]),
    );
  });

  it('finds caps match when search term is in lower case', () => {
    const result = finder.find('caps');
    expect(result).toEqual(
      expect.arrayContaining([
        {item: 'CAPS', segments: [{matching: true, value: 'CAPS'}]},
      ]),
    );
  });

  it('finds match with false start', () => {
    const result = finder.find('abc');
    expect(result).toEqual(
      expect.arrayContaining([
        {
          item: 'ababc',
          segments: [
            {matching: true, value: 'ab'},
            {matching: false, value: 'ab'},
            {matching: true, value: 'c'},
          ],
        },
      ]),
    );
  });
});

test('fuzzyMatch', () => {
  expect(fuzzyMatch('foo bar baz', 'foo')).toEqual({
    matches: true,
    segments: [
      {matching: true, value: 'foo'},
      {matching: false, value: ' bar baz'},
    ],
  });

  expect(fuzzyMatch('foo bar baz', 'qux')).toEqual({
    matches: false,
    segments: [],
  });

  expect(fuzzyMatch('bar baz', 'foo', 'bar')).toEqual({
    matches: true,
    segments: [
      {matching: true, value: 'bar'},
      {matching: false, value: ' baz'},
    ],
  });
});
