summaryrefslogtreecommitdiff
path: root/src/components/tailwind-indicator.test.tsx
blob: 4244ef6a86ac844400df727465ae44f2f6b144c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { render, screen } from '@testing-library/react';
import { afterAll, beforeEach, describe, expect, test } from 'vitest';
import { TailwindIndicator } from './tailwind-indicator';

const originalEnv = process.env;

describe('TailwindIndicator', () => {
  beforeEach(() => {
    process.env = { ...originalEnv };
  });

  afterAll(() => {
    process.env = originalEnv;
  });

  test('renders in non-production environments', () => {
    process.env.NODE_ENV = 'test';
    render(<TailwindIndicator />);

    expect(screen.getByText('xs')).toBeInTheDocument();
  });

  test('returns null in production', () => {
    process.env.NODE_ENV = 'production';
    const { container } = render(<TailwindIndicator />);

    expect(container.firstChild).toBeNull();
  });
});