-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfizzbuzz.test.ts
46 lines (35 loc) · 1.2 KB
/
fizzbuzz.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { describe, it, expect } from 'vitest'
import { FizzBuzz } from './fizzbuzz';
const fbz = new FizzBuzz()
describe('fizzbuzz rules', () => {
it("Should return the same number if any of the conditions doesn't apply", () => {
expect(fbz.checkRules(1)).toBe(1)
expect(fbz.checkRules(2)).toBe(2)
expect(fbz.checkRules(4)).toBe(4)
})
it("Should return Fizz if it's multiple of 3", () => {
const res = 'Fizz'
expect(fbz.checkRules(3)).toBe(res)
expect(fbz.checkRules(6)).toBe(res)
expect(fbz.checkRules(12)).toBe(res)
})
it("Should return Buzz if it's multiple of 5", () => {
const res: string = 'Buzz'
expect(fbz.checkRules(5)).toBe(res)
expect(fbz.checkRules(10)).toBe(res)
expect(fbz.checkRules(20)).toBe(res)
})
it("Should return FizzBuzz if it's multiple of 3 and 5", () => {
const res: string = 'FizzBuzz'
expect(fbz.checkRules(15)).toBe(res)
expect(fbz.checkRules(30)).toBe(res)
expect(fbz.checkRules(45)).toBe(res)
})
})
describe('print method', () => {
it("Should return numbers from 0 to 100", () => {
const nums: number[] = fbz.printFrom1To100()
expect(nums).toBeInstanceOf(Array)
expect(nums).toHaveLength(99)
})
})