Initialize unit testing and code coverage

* add: vitest configs

* added vitest scripts to package

* test coverage of src code

* initial unit testing

* added new testing workflows

* comments added, overlapping tests removed

* decouple env, tests

---------

Co-authored-by: Kevin Dang <kevinthedang_1@outlook.com>
This commit is contained in:
Jonathan Smoley
2024-06-05 08:50:56 -07:00
committed by GitHub
parent 496ce43939
commit 9f77c5287f
12 changed files with 2196 additions and 85 deletions

27
tests/commands.test.ts Normal file
View File

@@ -0,0 +1,27 @@
// describe marks a test suite
// expect takes a value from an expression
// it marks a test case
import { describe, expect, it } from 'vitest'
import commands from '../src/commands'
/**
* Commands test suite, tests the commands object
* Each command is to be tested elsewhere, this file
* is to ensure that the commands object is defined.
*
* @param name name of the test suite
* @param fn function holding tests to run
*/
describe('#commands', () => {
// test definition of commands object
it('references defined object', () => {
// toBe compares the value to the expected value
expect(typeof commands).toBe('object')
})
// test specific commands in the object
it('references specific commands', () => {
const commandsString = commands.map(e => e.name).join(', ')
expect(commandsString).toBe('thread, message-style, message-stream, toggle-chat, shutoff, modify-capacity')
})
})