vitest/examples/basic/test/basic.test.ts
Allison Pratt b3bc866d44
chore: add tsconfig.json to basic example (#4372)
Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
2023-10-27 16:41:27 +02:00

28 lines
609 B
TypeScript

import { assert, expect, test } from 'vitest'
import { squared } from '../src/basic.js'
// Edit an assertion and save to see HMR in action
test('Math.sqrt()', () => {
expect(Math.sqrt(4)).toBe(2)
expect(Math.sqrt(144)).toBe(12)
expect(Math.sqrt(2)).toBe(Math.SQRT2)
})
test('Squared', () => {
expect(squared(2)).toBe(4)
expect(squared(12)).toBe(144)
})
test('JSON', () => {
const input = {
foo: 'hello',
bar: 'world',
}
const output = JSON.stringify(input)
expect(output).eq('{"foo":"hello","bar":"world"}')
assert.deepEqual(JSON.parse(output), input, 'matches original')
})