-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.ts
41 lines (27 loc) · 795 Bytes
/
example.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
import Suit, {expect, chai} from './index.js'
const $math =new Suit('Math')
const $circle = new Suit('Math::Circle')
$math.it('add', () => {
const a = 1
const b = 2
const result = a+b
expect(result, 'incorrect sum').equals(3)
})
await $math.it('add, when async testfn', async () => {
const a = 1
const b = 2
const req = await chai.request('http://api.mathjs.org/v4/').get(`?expr=${a}%2B${b}`)
const result = req.text
expect(result, 'incorrect sum').to.be.equal('3')
})
$math.done()
$circle.it('calculate circumference from radius', () => {
const r = 10
const result = 2*Math.PI*r
expect(result.toFixed(2)).to.equal('62.83')
})
$circle.it('is circle a square?', () => {
const result = true
expect(result, 'circle is not a square').to.equal(false)
})
$circle.done()