Skip to content
Merged
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
77 changes: 35 additions & 42 deletions exercises/concept/freelancer-rates/freelancer-rates.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,57 +35,50 @@ describe('day rate', () => {
});

describe('days in budget', () => {
describe('with a budget of 1280', () => {
test('at 16/hour', () => {
const actual = daysInBudget(1280, 16);
const expected = 10;
test('with a budget of 1280 at 16/hour', () => {
const actual = daysInBudget(1280, 16);
const expected = 10;

expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});
expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});

test('at 25/hour', () => {
const actual = daysInBudget(1280, 25);
const expected = 6;
test('with a budget of 1280 at 25/hour', () => {
const actual = daysInBudget(1280, 25);
const expected = 6;

expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});
expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});

describe('with a budget of 835', () => {
test('at 12/hour', () => {
const actual = daysInBudget(835, 12);
const expected = 8;
test('with a budget of 835 at 12/hour', () => {
const actual = daysInBudget(835, 12);
const expected = 8;

expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});
});
expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});
});

describe('cost with monthly discount', () => {
describe('at 16/hour', () => {
test('for 70 days', () => {
const actual = priceWithMonthlyDiscount(16, 70, 0);
const expected = 8960;
expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});

test('for 130 days with 15% discount', () => {
const actual = priceWithMonthlyDiscount(16, 130, 0.15);
const expected = 14528;
expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});
test('at 16/hour for 70 days', () => {
const actual = priceWithMonthlyDiscount(16, 70, 0);
const expected = 8960;
expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});

test('at 16/hour for 130 days with 15% discount', () => {
const actual = priceWithMonthlyDiscount(16, 130, 0.15);
const expected = 14528;
expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});
describe('at 29.654321/hour', () => {
test('for 220 days with 11.2%', () => {
const actual = priceWithMonthlyDiscount(29.654321, 220, 0.112);
const expected = 46347;
expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});

test('for 155 days with 25.47% discount', () => {
const actual = priceWithMonthlyDiscount(29.654321, 155, 0.2547);
const expected = 27467;
expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});

test('at 29.654321/hour for 220 days with 11.2%', () => {
const actual = priceWithMonthlyDiscount(29.654321, 220, 0.112);
const expected = 46347;
expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});

test('at 29.654321/hour for 155 days with 25.47% discount', () => {
const actual = priceWithMonthlyDiscount(29.654321, 155, 0.2547);
const expected = 27467;
expect(actual).toBeCloseTo(expected, DIFFERENCE_PRECISION_IN_DIGITS);
});
});