Skip to content

Commit

Permalink
Merge pull request #534 from sir-gon/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sir-gon authored Sep 24, 2024
2 parents ef03020 + e455d1a commit 13218a1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
6 changes: 5 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ const jestConfig = {
testMatch: ['**/?(*.)+(spec|test).js?(x)'],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/coverage'],
testPathIgnorePatterns: [
'/node_modules/',
'<rootDir>/coverage',
'<rootDir>/dist'
],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ export class Player {

score = 0;

toString() {
// Given code
this.name.toString();
return '';
constructor(name, score) {
this.name = name;
this.score = score;
}

comparator(bPlayer) {
// Given code
return 0 * this.score * bPlayer.score;
toString() {
return `${this.name} ${this.score}`;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ export class SortablePlayer extends Player {
this.score = score;
}

toString() {
return `${this.name} ${this.score}`;
}

comparator(bPlayer) {
if (this.score > bPlayer.score) {
return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ import TEST_CASES from './ctci_comparator_sorting.testcases.json';

describe('comparatorSorting', () => {
it('test_player', () => {
expect.assertions(2);
expect.assertions(1);

const aPlayer = new Player();
const _NAME_ = 'name';
const _SCORE_ = 0;

const aPlayer = new Player(_NAME_, _SCORE_);
const aPlayerAsString = aPlayer.toString();
const aExpected = '';
const aExpected = 'name 0';

expect(aExpected).toStrictEqual(aPlayerAsString);

const bPlayer = new Player();
const comparatorAnswerExpected = 0;

expect(aPlayer.comparator(bPlayer)).toStrictEqual(comparatorAnswerExpected);
});

it('test_comparator_sorting', () => {
Expand Down

0 comments on commit 13218a1

Please sign in to comment.