Skip to content

Commit

Permalink
Fix normalize Cb to B in Db (#1183)
Browse files Browse the repository at this point in the history
Resolves #1171
Thanks to @beltonk for reporting
  • Loading branch information
martijnversluis authored May 19, 2024
1 parent b36c39c commit b6eb522
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/normalize_mappings/enharmonic-normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const enharmonics: Record<string, Record<string, string>> = {
'Bb': 'A#',
},
'Db': {
'B': 'Cb',
'Cb': 'B',
'F#': 'Gb',
'G#': 'Ab',
'A#': 'Bb',
Expand Down
17 changes: 5 additions & 12 deletions test/key/normalize.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { buildKey } from '../utilities';

import {
ChordProParser, NUMERIC, SYMBOL, TextFormatter,
NUMERAL,
NUMERIC,
SOLFEGE,
SYMBOL,
} from '../../src';
import { NUMERAL, SOLFEGE } from '../../src/constants';

describe('Key', () => {
describe('normalize', () => {
Expand Down Expand Up @@ -69,15 +72,5 @@ describe('Key', () => {
it('normalizes bIV', () => {
expect(buildKey('IV', NUMERAL, 'b').normalize().toString()).toEqual('III');
});

it('normalizes Db key', () => {
const song = new ChordProParser()
.parse('[E] [E/B] [E/C#] [E/A]')
.setKey('E')
.setCapo(3);

const rendered = new TextFormatter().format(song).trim();
expect(rendered).toEqual('Db Db/Ab Db/Bb Db/Gb');
});
});
});
2 changes: 1 addition & 1 deletion test/numeral_chord/to_chord_symbol_string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const majorExamples = {
'V': 'Ab',
'bVI': 'A',
'VI': 'Bb',
'bVII': 'Cb',
'bVII': 'B',
'VII': 'C',
},

Expand Down
2 changes: 1 addition & 1 deletion test/numeric_chord/to_chord_symbol_string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const majorExamples = {
'5': 'Ab',
'b6': 'A',
'6': 'Bb',
'b7': 'Cb',
'b7': 'B',
'7': 'C',
},

Expand Down

0 comments on commit b6eb522

Please sign in to comment.