generateAlbumTrackList.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import t from 'tap';
  2. import {testContentFunctions} from '#test-lib';
  3. testContentFunctions(t, 'generateAlbumTrackList (snapshot)', async (t, evaluate) => {
  4. await evaluate.load({
  5. mock: {
  6. generateAlbumTrackListMissingDuration:
  7. evaluate.stubContentFunction('generateAlbumTrackListMissingDuration'),
  8. },
  9. });
  10. const contribs1 = [
  11. {artist: {name: 'Apricot', directory: 'apricot', urls: null}},
  12. ];
  13. const contribs2 = [
  14. {artist: {name: 'Apricot', directory: 'apricot', urls: null}},
  15. {artist: {name: 'Peach', directory: 'peach', urls: ['https://peach.bandcamp.com/']}},
  16. {artist: {name: 'Cerise', directory: 'cerise', urls: null}},
  17. ];
  18. const color1 = '#fb07ff';
  19. const color2 = '#ea2e83';
  20. const tracks = [
  21. {name: 'Track 1', directory: 't1', duration: 20, artistContribs: contribs1, color: color1},
  22. {name: 'Track 2', directory: 't2', duration: 0, artistContribs: contribs1, color: color1},
  23. {name: 'Track 3', directory: 't3', duration: 40, artistContribs: contribs1, color: color1},
  24. {name: 'Track 4', directory: 't4', duration: 0, artistContribs: contribs2, color: color2},
  25. ];
  26. const albumWithTrackSections = {
  27. color: color1,
  28. artistContribs: contribs1,
  29. trackSections: [
  30. {name: 'First section', tracks: tracks.slice(0, 3)},
  31. {name: 'Second section', tracks: tracks.slice(3)},
  32. ],
  33. tracks,
  34. };
  35. const albumWithoutTrackSections = {
  36. color: color1,
  37. artistContribs: contribs1,
  38. trackSections: [{isDefaultTrackSection: true, tracks}],
  39. tracks,
  40. };
  41. const albumWithNoDuration = {
  42. color: color1,
  43. artistContribs: contribs1,
  44. trackSections: [{isDefaultTrackSection: true, tracks: [tracks[1], tracks[3]]}],
  45. tracks: [tracks[1], tracks[3]],
  46. };
  47. evaluate.snapshot(`basic behavior, with track sections`, {
  48. name: 'generateAlbumTrackList',
  49. args: [albumWithTrackSections],
  50. });
  51. evaluate.snapshot(`basic behavior, default track section`, {
  52. name: 'generateAlbumTrackList',
  53. args: [albumWithoutTrackSections],
  54. });
  55. evaluate.snapshot(`collapseDurationScope: never`, {
  56. name: 'generateAlbumTrackList',
  57. slots: {collapseDurationScope: 'never'},
  58. multiple: [
  59. {args: [albumWithTrackSections]},
  60. {args: [albumWithoutTrackSections]},
  61. {args: [albumWithNoDuration]},
  62. ],
  63. });
  64. evaluate.snapshot(`collapseDurationScope: track`, {
  65. name: 'generateAlbumTrackList',
  66. slots: {collapseDurationScope: 'track'},
  67. multiple: [
  68. {args: [albumWithTrackSections]},
  69. {args: [albumWithoutTrackSections]},
  70. {args: [albumWithNoDuration]},
  71. ],
  72. });
  73. evaluate.snapshot(`collapseDurationScope: section`, {
  74. name: 'generateAlbumTrackList',
  75. slots: {collapseDurationScope: 'section'},
  76. multiple: [
  77. {args: [albumWithTrackSections]},
  78. {args: [albumWithoutTrackSections]},
  79. {args: [albumWithNoDuration]},
  80. ],
  81. });
  82. evaluate.snapshot(`collapseDurationScope: album`, {
  83. name: 'generateAlbumTrackList',
  84. slots: {collapseDurationScope: 'album'},
  85. multiple: [
  86. {args: [albumWithTrackSections]},
  87. {args: [albumWithoutTrackSections]},
  88. {args: [albumWithNoDuration]},
  89. ],
  90. });
  91. });