Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

const data = require('./data'); const { getObservationsById } = require('./observations'); describe('Problem 04 - getObservationsById() function', function () { test('if an unknown id is passed, null

const data = require('./data'); const { getObservationsById } = require('./observations');

describe('Problem 04 - getObservationsById() function', function () { test('if an unknown id is passed, null is returned', function () { expect(getObservationsById(data, 'no-such-id')).toBe(null); });

test('if a single, known id is passed, the full Object should be returned', function () { let id = 135714728; let result0 = data.results[0];

expect(result0.id).toBe(id);

let result = getObservationsById(data, id); expect(result).toEqual(result0); });

test('if a multiple known ids are passed, an Array of the full Objects should be returned', function () { let id0 = 135714728; let result0 = data.results[0]; expect(result0.id).toBe(id0);

let id1 = 135284910; let result1 = data.results[1]; expect(result1.id).toBe(id1);

let result = getObservationsById(data, id0, id1); expect(Array.isArray(result)).toBe(true); expect(result.length).toBe(2); expect(result[0]).toEqual(result0); expect(result[1]).toEqual(result1); });

test('if some known and some unknown ids are passed, an Array of the known Objects should be returned', function () { let id0 = 135714728; let result0 = data.results[0]; expect(result0.id).toBe(id0);

let id1 = 'unknown-id';

let id2 = 134338548; let result2 = data.results[2]; expect(result2.id).toBe(id2);

let result = getObservationsById(data, id0, id1, id2); expect(Array.isArray(result)).toBe(true); expect(result.length).toBe(2); expect(result[0]).toEqual(result0); expect(result[1]).toEqual(result2); }); });

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions

Question

Describe the menstrual cycle in a woman.

Answered: 1 week ago

Question

Explain methods of metal extraction with examples.

Answered: 1 week ago