search.test.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const { eq, ok } = require('../../helpers/assert');
  2. const { makeNetwork, makePeer } = require('../../helpers/setup');
  3. describe('search: full-text search across modules', (t) => {
  4. t('searches audios by title', async () => {
  5. const net = makeNetwork(); const A = makePeer(net); A.setActor();
  6. await A.use('audios').createAudio('[a](&aud00000000000000000000000000000000000000000000000.sha256)', [], 'unique-title-x', '', '');
  7. const results = await A.use('search').search({ query: 'unique-title-x', types: [] });
  8. ok(results);
  9. });
  10. });
  11. describe('search: WISH only-LAN filter (config + persistence)', (t) => {
  12. const path = require('path');
  13. const fs = require('fs');
  14. const os = require('os');
  15. const { getConfig, saveConfig } = require('../../../src/configs/config-manager.js');
  16. t('config persists wish=only-lan', () => {
  17. const cfg = getConfig();
  18. const prev = cfg.wish;
  19. cfg.wish = 'only-lan';
  20. saveConfig(cfg);
  21. const reloaded = getConfig();
  22. eq(reloaded.wish, 'only-lan');
  23. cfg.wish = prev || 'whole';
  24. saveConfig(cfg);
  25. });
  26. t('wish accepts whole|mutuals|only-lan and rejects others', () => {
  27. const cfg = getConfig();
  28. const prev = cfg.wish;
  29. for (const v of ['whole', 'mutuals', 'only-lan']) {
  30. cfg.wish = v;
  31. saveConfig(cfg);
  32. eq(getConfig().wish, v);
  33. }
  34. cfg.wish = prev || 'whole';
  35. saveConfig(cfg);
  36. });
  37. });