"use strict";

var _react = require("@testing-library/react");
var _useTranslation = require("./use-translation");
describe('useTranslation hook', () => {
  it('should return the t function', () => {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useTranslation.useTranslation)());
    expect(typeof result.current.t).toBe('function');
  });
  it('should return the key if no parameters are provided', () => {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useTranslation.useTranslation)());
    expect(result.current.t('hello')).toBe('hello');
  });
  it('should replace placeholders with provided parameters', () => {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useTranslation.useTranslation)());
    expect(result.current.t('Hello, {{name}}!', {
      name: 'Alice'
    })).toBe('Hello, Alice!');
  });
  it('should leave placeholders intact if no matching parameter is found', () => {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useTranslation.useTranslation)());
    expect(result.current.t('Hello, {{name}}!')).toBe('Hello, {{name}}!');
  });
  it('should handle multiple placeholders', () => {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useTranslation.useTranslation)());
    expect(result.current.t('{{greeting}}, {{name}}!', {
      greeting: 'Hi',
      name: 'Bob'
    })).toBe('Hi, Bob!');
  });
  it('should not replace non-matching placeholders', () => {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useTranslation.useTranslation)());
    expect(result.current.t('Welcome, {{user}}!', {
      name: 'Charlie'
    })).toBe('Welcome, {{user}}!');
  });
  it('should use the key when count is 1 and no plural is provided', () => {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useTranslation.useTranslation)());
    expect(result.current.t('item', {
      count: 1
    })).toBe('item');
  });
  it('should use the key when count is 0 and no defaultpluralValue is provided', () => {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useTranslation.useTranslation)());
    expect(result.current.t('item', {
      count: 0
    })).toBe('item');
  });
  it('should use the key when count is not a number and no plural is provided', () => {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useTranslation.useTranslation)());
    expect(result.current.t('item', {
      count: 'not a number'
    })).toBe('item');
  });
  it('should use plural when count is greater than 1', () => {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useTranslation.useTranslation)());
    expect(result.current.t('item', {
      count: 2,
      plural: '2 items'
    })).toBe('2 items');
  });
  it('should use plural with placeholders when count is greater than 1', () => {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useTranslation.useTranslation)());
    expect(result.current.t('item', {
      count: 5,
      plural: '{{count}} items'
    })).toBe('5 items');
  });
  it('should not use plural when count is 1', () => {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useTranslation.useTranslation)());
    expect(result.current.t('item', {
      count: 1,
      plural: '2 items'
    })).toBe('item');
  });
  it('should use plural when count is 0', () => {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useTranslation.useTranslation)());
    expect(result.current.t('item', {
      count: 0,
      plural: '2 items'
    })).toBe('2 items');
  });
});