tobe

Finished
1import { describe, test, it } from 'node:test';
2import { recite } from './main.js';
3import assert from 'node:assert';
4
5describe('Beer Song', () => {
6 // Test case: verify the function correctly handles the first verse (99 bottles)
7 test('first generic verse', () => {
8 const expected = [
9 '99 bottles of beer on the wall, 99 bottles of beer.',
10 'Take one down and pass it around, 98 bottles of beer on the wall.'
11 ];
12 assert.deepStrictEqual(recite(99), expected);
13 });
14
15 // Test case: verify the function correctly handles the last standard verse (3 bottles)
16 test('last generic verse', () => {
17 const expected = [
18 '3 bottles of beer on the wall, 3 bottles of beer.',
19 'Take one down and pass it around, 2 bottles of beer on the wall.'
20 ];
21 assert.deepStrictEqual(recite(3), expected);
22 });
23
24 // Test case: verify the function correctly handles the verse with 2 bottles
25 test('verse with 2 bottles', () => {
26 const expected = [
27 '2 bottles of beer on the wall, 2 bottles of beer.',
28 'Take one down and pass it around, 1 bottle of beer on the wall.'
29 ];
30 assert.deepStrictEqual(recite(2), expected);
31 });
32
33 // Test case: verify the function correctly handles the verse with 1 bottle
34 test('verse with 1 bottle', () => {
35 const expected = [
36 '1 bottle of beer on the wall, 1 bottle of beer.',
37 'Take it down and pass it around, no more bottles of beer on the wall.'
38 ];
39 assert.deepStrictEqual(recite(1), expected);
40 });
41
42 // Edge case: tests the special verse when there are no more bottles
43 test('verse with 0 bottles', () => {
44 const expected = [
45 'No more bottles of beer on the wall, no more bottles of beer.',
46 'Go to the store and buy some more, 99 bottles of beer on the wall.'
47 ];
48 assert.deepStrictEqual(recite(0), expected);
49 });
50
51 // Test case: verify the function correctly handles multiple verses
52 test('first two verses', () => {
53 const expected = [
54 '99 bottles of beer on the wall, 99 bottles of beer.',
55 'Take one down and pass it around, 98 bottles of beer on the wall.',
56 '',
57 '98 bottles of beer on the wall, 98 bottles of beer.',
58 'Take one down and pass it around, 97 bottles of beer on the wall.'
59 ];
60 assert.deepStrictEqual(recite(99, 2), expected);
61 });
62
63 // Test case: verify the function correctly handles the last three verses
64 test('last three verses', () => {
65 const expected = [
66 '2 bottles of beer on the wall, 2 bottles of beer.',
67 'Take one down and pass it around, 1 bottle of beer on the wall.',
68 '',
69 '1 bottle of beer on the wall, 1 bottle of beer.',
70 'Take it down and pass it around, no more bottles of beer on the wall.',
71 '',
72 'No more bottles of beer on the wall, no more bottles of beer.',
73 'Go to the store and buy some more, 99 bottles of beer on the wall.'
74 ];
75 assert.deepStrictEqual(recite(2, 3), expected);
76 });
77
78 // Edge case: tests reciting a single verse from the middle of the song
79 test('single verse from the middle', () => {
80 const expected = [
81 '50 bottles of beer on the wall, 50 bottles of beer.',
82 'Take one down and pass it around, 49 bottles of beer on the wall.'
83 ];
84 assert.deepStrictEqual(recite(50), expected);
85 });
86
87 // This test verifies the function correctly handles multiple edge cases in sequence
88 test('multiple verses across special boundaries', () => {
89 const expected = [
90 '3 bottles of beer on the wall, 3 bottles of beer.',
91 'Take one down and pass it around, 2 bottles of beer on the wall.',
92 '',
93 '2 bottles of beer on the wall, 2 bottles of beer.',
94 'Take one down and pass it around, 1 bottle of beer on the wall.',
95 '',
96 '1 bottle of beer on the wall, 1 bottle of beer.',
97 'Take it down and pass it around, no more bottles of beer on the wall.'
98 ];
99 assert.deepStrictEqual(recite(3, 3), expected);
100 });
101});
Test NameStatus
first generic verse
Pass
last generic verse
Pass
verse with 2 bottles
Pass
verse with 1 bottle
Pass
verse with 0 bottles
Pass
first two verses
Pass
last three verses
Pass
all verses
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.