Skip to content

Commit 13218a1

Browse files
authored
Merge pull request #534 from sir-gon/develop
Develop
2 parents ef03020 + e455d1a commit 13218a1

File tree

4 files changed

+16
-20
lines changed

4 files changed

+16
-20
lines changed

jest.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ const jestConfig = {
159159
testMatch: ['**/?(*.)+(spec|test).js?(x)'],
160160

161161
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
162-
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/coverage'],
162+
testPathIgnorePatterns: [
163+
'/node_modules/',
164+
'<rootDir>/coverage',
165+
'<rootDir>/dist'
166+
],
163167

164168
// The regexp pattern or array of patterns that Jest uses to detect test files
165169
// testRegex: [],

src/hackerrank/interview_preparation_kit/sort/ctci_comparator_sorting.Player.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ export class Player {
55

66
score = 0;
77

8-
toString() {
9-
// Given code
10-
this.name.toString();
11-
return '';
8+
constructor(name, score) {
9+
this.name = name;
10+
this.score = score;
1211
}
1312

14-
comparator(bPlayer) {
15-
// Given code
16-
return 0 * this.score * bPlayer.score;
13+
toString() {
14+
return `${this.name} ${this.score}`;
1715
}
1816
}
1917

src/hackerrank/interview_preparation_kit/sort/ctci_comparator_sorting.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ export class SortablePlayer extends Player {
1616
this.score = score;
1717
}
1818

19-
toString() {
20-
return `${this.name} ${this.score}`;
21-
}
22-
2319
comparator(bPlayer) {
2420
if (this.score > bPlayer.score) {
2521
return -1;

src/hackerrank/interview_preparation_kit/sort/ctci_comparator_sorting.test.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@ import TEST_CASES from './ctci_comparator_sorting.testcases.json';
1111

1212
describe('comparatorSorting', () => {
1313
it('test_player', () => {
14-
expect.assertions(2);
14+
expect.assertions(1);
1515

16-
const aPlayer = new Player();
16+
const _NAME_ = 'name';
17+
const _SCORE_ = 0;
18+
19+
const aPlayer = new Player(_NAME_, _SCORE_);
1720
const aPlayerAsString = aPlayer.toString();
18-
const aExpected = '';
21+
const aExpected = 'name 0';
1922

2023
expect(aExpected).toStrictEqual(aPlayerAsString);
21-
22-
const bPlayer = new Player();
23-
const comparatorAnswerExpected = 0;
24-
25-
expect(aPlayer.comparator(bPlayer)).toStrictEqual(comparatorAnswerExpected);
2624
});
2725

2826
it('test_comparator_sorting', () => {

0 commit comments

Comments
 (0)