env.test.ts 768 B

12345678910111213141516171819202122232425262728293031
  1. import { describe, expect, test } from 'bun:test';
  2. import {
  3. isPluginDisabledByEnv,
  4. isTruthyEnvValue,
  5. PLUGIN_DISABLE_ENV,
  6. } from './env';
  7. describe('isTruthyEnvValue', () => {
  8. test.each(['1', 'true', 'TRUE', ' yes ', 'on'])('%p is truthy', (value) => {
  9. expect(isTruthyEnvValue(value)).toBe(true);
  10. });
  11. test.each([
  12. undefined,
  13. '',
  14. '0',
  15. 'false',
  16. 'no',
  17. 'off',
  18. 'anything',
  19. ])('%p is not truthy', (value) => {
  20. expect(isTruthyEnvValue(value)).toBe(false);
  21. });
  22. });
  23. describe('isPluginDisabledByEnv', () => {
  24. test('reads OH_MY_OPENCODE_SLIM_DISABLE', () => {
  25. expect(isPluginDisabledByEnv({ [PLUGIN_DISABLE_ENV]: '1' })).toBe(true);
  26. expect(isPluginDisabledByEnv({ [PLUGIN_DISABLE_ENV]: '0' })).toBe(false);
  27. });
  28. });