Skip to content

Commit 00ddc6a

Browse files
committed
ex-1: inline airSpeedVelocity at speeds
1 parent 0a30a70 commit 00ddc6a

File tree

2 files changed

+2
-38
lines changed

2 files changed

+2
-38
lines changed

src/functions-into-class-hierarchy/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,5 @@ export function plumages(birds) {
55
}
66

77
export function speeds(birds) {
8-
return new Map(birds.map(b => [b.name, airSpeedVelocity(b)]));
9-
}
10-
11-
export function airSpeedVelocity(bird) {
12-
return createBird(bird).airSpeedVelocity;
8+
return new Map(birds.map(b => createBird(b)).map(b => [b.name, b.airSpeedVelocity]));
139
}

src/functions-into-class-hierarchy/index.test.js

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { speeds, airSpeedVelocity, plumages } from './index';
1+
import { speeds, plumages } from './index';
22

33
describe('plumages', () => {
44
it('should return a map containing the plumage of all birds in the list', () => {
@@ -23,38 +23,6 @@ describe('plumages', () => {
2323
});
2424
});
2525

26-
describe('airSpeedVelocity', () => {
27-
it('should return 35 for EuropeanSwallow', () => {
28-
const bird = { type: 'EuropeanSwallow' };
29-
expect(airSpeedVelocity(bird)).toBe(35);
30-
});
31-
32-
it('should return 38 for AfricanSwallow with 1 coconut', () => {
33-
const bird = { type: 'AfricanSwallow', numberOfCoconuts: 1 };
34-
expect(airSpeedVelocity(bird)).toBe(38);
35-
});
36-
37-
it('should return 36 for AfricanSwallow with 2 coconuts', () => {
38-
const bird = { type: 'AfricanSwallow', numberOfCoconuts: 2 };
39-
expect(airSpeedVelocity(bird)).toBe(36);
40-
});
41-
42-
it('should return 0 for nailed NorwegianBlueParrot', () => {
43-
const bird = { type: 'NorwegianBlueParrot', isNailed: true };
44-
expect(airSpeedVelocity(bird)).toBe(0);
45-
});
46-
47-
it('should return 10 for NorwegianBlueParrot with voltage 0', () => {
48-
const bird = { type: 'NorwegianBlueParrot', voltage: 0 };
49-
expect(airSpeedVelocity(bird)).toBe(10);
50-
});
51-
52-
it('should return 20 for NorwegianBlueParrot with voltage 100', () => {
53-
const bird = { type: 'NorwegianBlueParrot', voltage: 100 };
54-
expect(airSpeedVelocity(bird)).toBe(20);
55-
});
56-
});
57-
5826
describe('speeds', () => {
5927
it('should return a map containing the air speed velocity of all birds in the list', () => {
6028
const birds = [

0 commit comments

Comments
 (0)