add sample 2

This commit is contained in:
2020-08-28 15:36:20 +07:00
parent 9ced30ded5
commit d293ac3aa4
8 changed files with 71 additions and 12 deletions

View File

@@ -1,25 +1,25 @@
import {sample} from "../src"
import {power} from "../src"
// Describe : top level to describe a block of test below is for what
describe("Test Sample Function", () => {
// Test : is run for each test
test("Test N is Undefined", () => {
expect(sample(undefined)).toBe(undefined) // expect sample(undefined) return undefined
expect(power(undefined)).toBe(undefined) // expect sample(undefined) return undefined
})
test("Test N is Null", () => {
expect(sample(null)).toBe(undefined)
expect(power(null)).toBe(undefined)
})
test("Test N is not number",() => {
expect(sample("Hello")).toBe(undefined)
expect(power("Hello")).toBe(undefined)
})
test("Test Normal Number",() => {
expect(sample(0)).toBe(0)
expect(sample(1)).toBe(1)
expect(sample(2)).toBe(4)
expect(sample(100)).toBe(10000)
expect(power(0)).toBe(0)
expect(power(1)).toBe(1)
expect(power(2)).toBe(4)
expect(power(100)).toBe(10000)
})
})

25
test/sample2.test.js Normal file
View File

@@ -0,0 +1,25 @@
import {sqrt} from "../src"
// Describe : top level to describe a block of test below is for what
describe("Test Sample 2 Function", () => {
// Test : is run for each test
test("Test N is Undefined", () => {
expect(sqrt(undefined)).toBe(undefined) // expect sample(undefined) return undefined
})
test("Test N is Null", () => {
expect(sqrt(null)).toBe(undefined)
})
test("Test N is not number",() => {
expect(sqrt("Hello")).toBe(undefined)
})
test("Test Normal Number",() => {
expect(sqrt(0)).toBe(0)
expect(sqrt(1)).toBe(1)
expect(sqrt(4)).toBe(2)
expect(sqrt(10000)).toBe(100)
})
})