Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

948 B
Raw Blame
import type { UserStore } from '@/store/user';
import type { UserState } from '@/store/user/initialState';
import { initialState } from '@/store/user/initialState';
import { merge } from '@/utils/merge';

import { userUsageSettingsSelectors } from './usage';

describe('userUsageSettingsSelectors', () => {
  describe('costEstimateWarningThreshold', () => {
    it('should return the default threshold', () => {
      const result = userUsageSettingsSelectors.costEstimateWarningThreshold(
        initialState as UserStore,
      );

      expect(result).toBe(0.5);
    });

    it('should read the persisted threshold from general settings', () => {
      const s: UserState = merge(initialState, {
        settings: {
          general: { costEstimateWarningThreshold: 1.25 },
        },
      });

      const result = userUsageSettingsSelectors.costEstimateWarningThreshold(s as UserStore);

      expect(result).toBe(1.25);
    });
  });
});