Skip to content
This repository has been archived by the owner on May 23, 2021. It is now read-only.

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
v1rtl committed Mar 8, 2021
1 parent 326b249 commit ac3639c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ms } from 'https://deno.land/x/ms@v0.1.0/ms.ts'
import { green, bold, gray, red } from 'https://deno.land/std@0.89.0/fmt/colors.ts'
export * from 'https://deno.land/x/expect@v0.2.6/mod.ts'

Expand Down Expand Up @@ -34,7 +35,9 @@ export function describe(name: string, fn: () => void) {
* ```
*/
export function it(name: string, fn: Fn) {
if (!testSuites[currSuite]) testSuites[currSuite] = { name: '', cases: [] }
if (!testSuites[currSuite]) {
testSuites.push({ name: '', cases: [] })
}
testSuites[currSuite].cases.push({ name, case: fn })
}

Expand Down Expand Up @@ -75,13 +78,15 @@ export const run = () => {
if (err) throw err
}

const suiteName = suite.name ? ` ${suite.name} >` : ''

try {
const t1 = performance.now()
await t.case(done)
const t2 = performance.now()
msg(`\n${green(bold('PASS'))} ${suite.name} > ${bold(t.name)} (${t2 - t1}ms) \n`)
msg(`\n${green(bold('PASS'))}${suiteName} ${bold(t.name)} (${ms(t2 - t1)}) \n`)
} catch (e) {
msg(red(`\n${bold('FAIL')} ${suite.name} > ${bold(t.name)}\n`))
msg(red(`\n${bold('FAIL')}${suiteName} ${bold(t.name)}\n`))
msg(e.stack)

failedSuites++
Expand Down
4 changes: 4 additions & 0 deletions mod_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ it('should support top-level cases', () => {
expect(1).toBe(1)
})

it('should support multiple top-level cases', () => {
expect(2).toBe(2)
})

run()

0 comments on commit ac3639c

Please sign in to comment.