Skip to content

Develop #534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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