Skip to content

Commit 9dd9ca3

Browse files
committed
Use new converters and fix unit tests
1 parent ea6d661 commit 9dd9ca3

File tree

18 files changed

+98
-143
lines changed

18 files changed

+98
-143
lines changed
File renamed without changes.

jest.config.base.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* eslint-env node */
2+
module.exports = {
3+
testEnvironment: 'jsdom',
4+
rootDir: __dirname,
5+
6+
collectCoverage: true,
7+
collectCoverageFrom: [
8+
'<rootDir>/packages/chords-charts-studio/src/**/*.js',
9+
],
10+
coverageDirectory: '<rootDir>/coverage',
11+
coverageReporters: ['json', 'lcov', 'text', 'clover'],
12+
coverageThreshold: {
13+
global: {
14+
branches: 99,
15+
functions: 99,
16+
lines: 99,
17+
statements: 99,
18+
},
19+
},
20+
21+
transform: {
22+
'\\.js$': 'babel-jest',
23+
'\\.hbs$': 'jest-handlebars',
24+
'\\.txt': 'jest-raw-loader',
25+
},
26+
// whitelisting local modules in the node_modules folder
27+
transformIgnorePatterns: ['<rootDir>.*(node_modules)(?!.*chord-mark.*).*$'],
28+
29+
moduleNameMapper: {
30+
'\\.(css|scss)$': '<rootDir>/tests/styleMock.js',
31+
'\\.(png)$': '<rootDir>/tests/assetMock.js',
32+
},
33+
};

jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* eslint-env node */
2+
const baseConfig = require('./jest.config.base');
3+
4+
module.exports = {
5+
...baseConfig,
6+
projects: ['<rootDir>/packages/*/jest.config.js'],
7+
};
Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,16 @@
11
/* eslint-env node */
2+
const baseConfig = require('../../jest.config.base');
3+
const packageJson = require('./package');
4+
25
module.exports = {
3-
testEnvironment: 'jsdom',
6+
...baseConfig,
7+
name: packageJson.name,
8+
displayName: packageJson.name,
49

5-
collectCoverage: true,
6-
collectCoverageFrom: ['src/**/*.js', '!src/main.js', '!**/node_modules/**'],
7-
coverageDirectory: '<rootDir>/coverage',
10+
rootDir: '../..',
811
coveragePathIgnorePatterns: [
9-
'node_modules',
10-
'src/core/createGetVersions.js',
12+
'packages/chord-charts-studio/src/core/createGetVersions.js',
1113
],
12-
coverageReporters: ['json', 'lcov', 'text', 'clover'],
13-
coverageThreshold: {
14-
global: {
15-
branches: 99,
16-
functions: 99,
17-
lines: 99,
18-
statements: 99,
19-
},
20-
},
21-
22-
transform: {
23-
'\\.js$': 'babel-jest',
24-
'\\.hbs$': 'jest-handlebars',
25-
'\\.txt': 'jest-raw-loader',
26-
},
2714

2815
setupFiles: ['jest-localstorage-mock'],
29-
30-
moduleNameMapper: {
31-
'\\.(css|scss)$': '<rootDir>/scss/__mocks__/styleMock.js',
32-
'\\.(png)$': '<rootDir>/assets/__mocks__/assetMock.js',
33-
},
3416
};

packages/chord-charts-studio/src/songImporter/_components/InputFormatSelector.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import InputFormatEntry from './InputFormatEntry';
55

66
const allEntries = [
77
{
8-
id: 'basic',
9-
label: 'Basic',
8+
id: 'auto',
9+
label: 'Detect',
1010
},
1111
{
12-
id: 'chordpro',
13-
label: 'ChordPro',
12+
id: 'chordPro',
13+
label: 'Bracketed chords (ChordPro)',
1414
},
1515
{
16-
id: 'ultimateGuitar',
17-
label: 'Ultimate Guitar',
16+
id: 'chordsOverLyrics',
17+
label: 'Chords over lyrics (Ultimate Guitar...)',
1818
},
1919
];
2020

packages/chord-charts-studio/src/songImporter/_components/SongImporter.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import './SongImporter.scss';
33
import React from 'react';
44
import PropTypes from 'prop-types';
55

6+
import { convert2ChordMark } from 'chord-mark-converters';
7+
68
import Modal from '../../ui/_components/Modal';
79
import Header from './Header';
810
import FilePicker from './FilePicker';
911
import Input from './Input';
1012
import PreviewError from './PreviewError';
1113
import InputFormatSelector from './InputFormatSelector';
12-
import input2ChordMark from '../input2ChordMark';
1314
import Icon from '../../ui/_components/Icon';
1415

1516
function SongImporter(props) {
@@ -31,7 +32,7 @@ function SongImporter(props) {
3132
let error = '';
3233

3334
try {
34-
chordMarkContent = input2ChordMark(content, inputFormat);
35+
chordMarkContent = convert2ChordMark(content, { inputFormat });
3536
} catch (e) {
3637
error = e.message;
3738
}

packages/chord-charts-studio/src/songImporter/_state/reducers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const initialState = {
77
content: '',
88
isFromWeb: false,
99
isImporting: false,
10-
inputFormat: 'basic',
10+
inputFormat: 'auto',
1111
title: '',
1212
};
1313

packages/chord-charts-studio/tests/integration/optionsPanels/rendering/_containers/Rendering.spec.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ describe('"Rendering" option panel', () => {
307307
});
308308

309309
const chordmarkSrc = getByText('ChordMark (Source)');
310-
const chordpro = getByText('ChordPro');
311310

312311
const chartType = getByText(
313312
preferencesWidgets.chartType.label + ':'
@@ -333,15 +332,6 @@ describe('"Rendering" option panel', () => {
333332
expect(isDisabled(alignChordsWithLyrics)).toBe(true);
334333
expect(isDisabled(alignBars)).toBe(true);
335334
expect(isDisabled(autoRepeatChords)).toBe(true);
336-
337-
act(() => {
338-
fireEvent.click(chordpro);
339-
});
340-
341-
expect(isDisabled(chartType, true)).toBe(true);
342-
expect(isDisabled(alignChordsWithLyrics)).toBe(true);
343-
expect(isDisabled(alignBars)).toBe(true);
344-
expect(isDisabled(autoRepeatChords)).toBe(true);
345335
});
346336
});
347337
});

packages/chord-charts-studio/tests/integration/songImporter/_containers/SongImporter.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('SongImporter', () => {
9191
test('should import a song from a website', () => {
9292
dispatch(
9393
startImportFromWeb(
94-
'chordpro',
94+
'chordPro',
9595
'[A]Amazing [D7]grace',
9696
'Amazing Grace'
9797
)

packages/chord-charts-studio/tests/unit/SongRenderers/_components/SongRenderer.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('SongRenderer', () => {
5858
);
5959

6060
expect(container.firstChild.firstChild.innerHTML).toBe(
61-
'<p>&nbsp;</p><p>[A]mySong</p>'
61+
'<p>[|] [A]mySong [|]</p>'
6262
);
6363
});
6464
});

0 commit comments

Comments
 (0)