martijnversluis/ChordSheetJS

View on GitHub
test/fixtures/song.ts

Summary

Maintainability
A
0 mins
Test Coverage
import {
  chordLyricsPair, comment, createSongFromAst, section, softLineBreak, tag, ternary,
} from '../utilities';

// This Song object mimics the chord pro sheet in chord_pro_sheet.js
export const exampleSongSymbol = createSongFromAst([
  [tag('title', 'Let it be')],
  [tag('subtitle', 'ChordSheetJS example version')],
  [tag('key', 'C')],
  [tag('x_some_setting', '')],
  [tag('composer', 'John Lennon')],
  [tag('composer', 'Paul McCartney')],
  [comment('This is my favorite song')],
  [],
  [
    chordLyricsPair('', 'Written by: '),
    ternary({
      variable: 'composer',
      trueExpression: [ternary({ variable: null })],
      falseExpression: [
        'No composer defined for ',
        ternary({
          variable: 'title',
          trueExpression: [ternary({ variable: null })],
          falseExpression: ['Untitled song'],
        }),
      ],
    }),
  ],
  [],
  [tag('start_of_verse', 'Verse 1')],
  [
    chordLyricsPair('', 'Let it '),
    chordLyricsPair('Am', 'be, '),
    softLineBreak(),
    chordLyricsPair('', 'let it '),
    chordLyricsPair('C/G', 'be, let it '),
    chordLyricsPair('F', 'be, let it '),
    chordLyricsPair('C', 'be'),
  ],
  [tag('transpose', '2')],
  [
    chordLyricsPair('C', 'Whisper '),
    chordLyricsPair('', 'words of ', 'strong'),
    chordLyricsPair('F', 'wis'),
    chordLyricsPair('G', 'dom, let it '),
    chordLyricsPair('F', 'be '),
    chordLyricsPair('C/E', ' '),
    chordLyricsPair('Dm', ' '),
    chordLyricsPair('C', ''),
  ],
  [tag('end_of_verse')],
  [],
  [tag('start_of_chorus')],
  [tag('comment', 'Breakdown')],
  [tag('transpose', 'G')],
  [
    chordLyricsPair('Am', 'Whisper words of '),
    chordLyricsPair('Bb', 'wisdom, let it '),
    chordLyricsPair('F', 'be '),
    chordLyricsPair('C', ''),
  ],
  [tag('end_of_chorus')],
  [],
  [tag('start_of_chorus', '', { label: 'Chorus 2' })],
  [
    chordLyricsPair('C', 'Whisper words of '),
    chordLyricsPair('Bb', 'wisdom, let it '),
    chordLyricsPair('F', 'be '),
    chordLyricsPair('C', ''),
  ],
  [tag('end_of_chorus')],
  [],
  ...section('tab', '', { label: 'Tab 1' }, 'Tab line 1\nTab line 2'),
  [],
  ...section('abc', 'ABC 1', {}, 'ABC line 1\nABC line 2'),
  [],
  ...section('ly', 'LY 1', {}, 'LY line 1\nLY line 2'),
  [],
  [tag('start_of_bridge', 'Bridge 1')],
  [chordLyricsPair('', 'Bridge line')],
  [tag('end_of_bridge')],
  [],
  ...section('grid', 'Grid 1', {}, 'Grid line 1\nGrid line 2'),
]);

export const exampleSongSolfege = createSongFromAst([
  [tag('title', 'Let it be')],
  [tag('subtitle', 'ChordSheetJS example version')],
  [tag('key', 'Do')],
  [tag('x_some_setting', '')],
  [tag('composer', 'John Lennon')],
  [tag('composer', 'Paul McCartney')],
  [comment('This is my favorite song')],
  [],
  [
    chordLyricsPair('', 'Written by: '),
    ternary({
      variable: 'composer',
      trueExpression: [ternary({ variable: null })],
      falseExpression: [
        'No composer defined for ',
        ternary({
          variable: 'title',
          trueExpression: [ternary({ variable: null })],
          falseExpression: ['Untitled song'],
        }),
      ],
    }),
  ],
  [],
  [tag('start_of_verse', 'Verse 1')],
  [
    chordLyricsPair('', 'Let it '),
    chordLyricsPair('Lam', 'be, let it '),
    chordLyricsPair('Do/Sol', 'be, let it '),
    chordLyricsPair('Fa', 'be, let it '),
    chordLyricsPair('Do', 'be'),
  ],
  [tag('transpose', '2')],
  [
    chordLyricsPair('Do', 'Whisper '),
    chordLyricsPair('', 'words of ', 'strong'),
    chordLyricsPair('Fa', 'wis'),
    chordLyricsPair('Sol', 'dom, let it '),
    chordLyricsPair('Fa', 'be '),
    chordLyricsPair('Do/Mi', ' '),
    chordLyricsPair('Rem', ' '),
    chordLyricsPair('Do', ''),
  ],
  [tag('end_of_verse')],
  [],
  [tag('start_of_chorus')],
  [tag('comment', 'Breakdown')],
  [tag('transpose', 'Sol')],
  [
    chordLyricsPair('Lam', 'Whisper words of '),
    chordLyricsPair('Sib', 'wisdom, let it '),
    chordLyricsPair('Fa', 'be '),
    chordLyricsPair('Do', ''),
  ],
  [tag('end_of_chorus')],
  [],
  [tag('start_of_chorus', '', { label: 'Chorus 2' })],
  [
    chordLyricsPair('Lam', 'Whisper words of '),
    chordLyricsPair('Sib', 'wisdom, let it '),
    chordLyricsPair('Fa', 'be '),
    chordLyricsPair('Do', ''),
  ],
  [tag('end_of_chorus')],
  [],
  ...section('tab', 'Tab 1', {}, 'Tab line 1\nTab line 2'),
  [],
  ...section('abc', 'ABC 1', {}, 'ABC line 1\nABC line 2'),
  [],
  ...section('ly', 'LY 1', {}, 'LY line 1\nLY line 2'),
  [],
  [tag('start_of_bridge', 'Bridge 1')],
  [chordLyricsPair('', 'Bridge line')],
  [tag('end_of_bridge')],
  [],
  ...section('grid', 'Grid 1', {}, 'Grid line 1\nGrid line 2'),
]);