generateTrackAdditionalNamesBox.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import t from 'tap';
  2. import contentFunction from '#content-function';
  3. import {testContentFunctions} from '#test-lib';
  4. testContentFunctions(t, 'generateTrackAdditionalNamesBox (snapshot)', async (t, evaluate) => {
  5. await evaluate.load({
  6. mock: {
  7. generateAdditionalNamesBox:
  8. evaluate.stubContentFunction('generateAdditionalNamesBox'),
  9. },
  10. });
  11. const stubTrack = {
  12. additionalNames: [],
  13. sharedAdditionalNames: [],
  14. inferredAdditionalNames: [],
  15. };
  16. const quickSnapshot = (message, trackProperties) =>
  17. evaluate.snapshot(message, {
  18. name: 'generateTrackAdditionalNamesBox',
  19. args: [{...stubTrack, ...trackProperties}],
  20. });
  21. quickSnapshot(`no additional names`, {});
  22. quickSnapshot(`own additional names only`, {
  23. additionalNames: [
  24. {name: `Foo Bar`, annotation: `the Alps`},
  25. ],
  26. });
  27. quickSnapshot(`shared additional names only`, {
  28. sharedAdditionalNames: [
  29. {name: `Bar Foo`, annotation: `the Rockies`},
  30. ],
  31. });
  32. quickSnapshot(`inferred additional names only`, {
  33. inferredAdditionalNames: [
  34. {name: `Baz Baz`, from: [{directory: `the-pyrenees`}]},
  35. ],
  36. });
  37. quickSnapshot(`multiple own`, {
  38. additionalNames: [
  39. {name: `Apple Time!`},
  40. {name: `Pterodactyl Time!`},
  41. {name: `Banana Time!`},
  42. ],
  43. });
  44. quickSnapshot(`own and shared, some overlap`, {
  45. additionalNames: [
  46. {name: `weed dreams..`, annotation: `own annotation`},
  47. {name: `夜間のMOON汗`, annotation: `own annotation`},
  48. ],
  49. sharedAdditionalNames: [
  50. {name: `weed dreams..`, annotation: `shared annotation`},
  51. {name: `GAMINGブラザー96`, annotation: `shared annotation`},
  52. ],
  53. });
  54. quickSnapshot(`shared and inferred, some overlap`, {
  55. sharedAdditionalNames: [
  56. {name: `Coruscate`, annotation: `shared annotation`},
  57. {name: `Arbroath`, annotation: `shared annotation`},
  58. ],
  59. inferredAdditionalNames: [
  60. {name: `Arbroath`, from: [{directory: `inferred-from`}]},
  61. {name: `Prana Ferox`, from: [{directory: `inferred-from`}]},
  62. ],
  63. });
  64. quickSnapshot(`own and inferred, some overlap`, {
  65. additionalNames: [
  66. {name: `Ke$halo Strike Back`, annotation: `own annotation`},
  67. {name: `Ironic Mania`, annotation: `own annotation`},
  68. ],
  69. inferredAdditionalNames: [
  70. {name: `Ironic Mania`, from: [{directory: `inferred-from`}]},
  71. {name: `ANARCHY::MEGASTRIFE`, from: [{directory: `inferred-from`}]},
  72. ],
  73. });
  74. quickSnapshot(`own and shared and inferred, various overlap`, {
  75. additionalNames: [
  76. {name: `Own!`, annotation: `own annotation`},
  77. {name: `Own! Shared!`, annotation: `own annotation`},
  78. {name: `Own! Inferred!`, annotation: `own annotation`},
  79. {name: `Own! Shared! Inferred!`, annotation: `own annotation`},
  80. ],
  81. sharedAdditionalNames: [
  82. {name: `Shared!`, annotation: `shared annotation`},
  83. {name: `Own! Shared!`, annotation: `shared annotation`},
  84. {name: `Shared! Inferred!`, annotation: `shared annotation`},
  85. {name: `Own! Shared! Inferred!`, annotation: `shared annotation`},
  86. ],
  87. inferredAdditionalNames: [
  88. {name: `Inferred!`, from: [{directory: `inferred-from`}]},
  89. {name: `Own! Inferred!`, from: [{directory: `inferred-from`}]},
  90. {name: `Shared! Inferred!`, from: [{directory: `inferred-from`}]},
  91. {name: `Own! Shared! Inferred!`, from: [{directory: `inferred-from`}]},
  92. ],
  93. });
  94. });