refactor: replace Jest with bun

This commit is contained in:
Justin Lin committed 2026-10-11 17:43:22 +11:00
1 parent 634dc8f987
commit 54225528b3
21 files changed
+66 -856

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
import { describe, test, expect } from '@jest/globals'
import { describe, test, expect, beforeEach } from 'bun:test'
import File from '../file.js'
describe('File', () => {
+1 -1
View File
@@ -1,4 +1,4 @@
import { describe, test, expect } from '@jest/globals'
import { describe, test, expect, beforeEach } from 'bun:test'
import FileGraph from '../fileGraph.js'
import FileNode from '../fileNode.js'
import { FileObject } from '../file.js'
+1 -1
View File
@@ -1,4 +1,4 @@
import { describe, test, expect } from '@jest/globals'
import { describe, test, expect, beforeEach } from 'bun:test'
import { ParentNotExistsError } from '../errors.js'
import FileNode, { IFileNode } from '../fileNode.js'
import { FileObject } from '../file.js'
+2 -23
View File
@@ -1,28 +1,7 @@
import { test, expect } from '@jest/globals'
import { IFileExistenceChecker, IFileInput } from '../schema'
import { test, expect } from 'bun:test'
import { checkFiles } from '../condition/FileMatcher.js'
import { Condition } from '../condition/Condition.js'
export class MockFileChecker implements IFileExistenceChecker {
private files: IFileInput[] = [
{
path: '/home/user/hello.txt',
type: 'file',
},
{
path: '/home/user/world.txt',
type: 'file',
},
{
path: '/home/user/Downloads',
type: 'directory',
},
]
async exists(file: IFileInput): Promise<boolean> {
return this.files.some((f) => f.path === file.path && f.type === file.type)
}
}
import { MockFileChecker } from './mockFileChecker'
test('file matcher', async () => {
const checker = new MockFileChecker()
+2 -2
View File
@@ -1,11 +1,11 @@
import { test, expect } from '@jest/globals'
import { it, test, expect } from 'bun:test'
import { Condition } from '../condition/Condition'
import { OutputMatcher } from '../condition/OutputMatcher'
import { PwdMatcher } from '../condition/PwdMatcher'
import { CommandMatcher } from '../condition/CommandMatcher'
import { ErrorMatcher } from '../condition/ErrorMatcher'
import { conditionSchema } from '../schema'
import { MockFileChecker } from './asyncCondition.test'
import { MockFileChecker } from './mockFileChecker'
test('command match', () => {
const matcher = new CommandMatcher('^echo start$')
+2 -2
View File
@@ -1,7 +1,7 @@
import { expect, it, describe } from '@jest/globals'
import { describe, it, expect } from 'bun:test'
import { IQuest } from '../schema'
import { GameSession } from '../Session'
import { MockFileChecker } from './asyncCondition.test'
import { MockFileChecker } from './mockFileChecker'
const quest: IQuest = {
id: 'quest1',
+22
View File
@@ -0,0 +1,22 @@
import type { IFileExistenceChecker, IFileInput } from '../schema'
export class MockFileChecker implements IFileExistenceChecker {
private files: IFileInput[] = [
{
path: '/home/user/hello.txt',
type: 'file',
},
{
path: '/home/user/world.txt',
type: 'file',
},
{
path: '/home/user/Downloads',
type: 'directory',
},
]
async exists(file: IFileInput): Promise<boolean> {
return this.files.some((f) => f.path === file.path && f.type === file.type)
}
}
+2 -2
View File
@@ -1,7 +1,7 @@
import { expect, describe, it } from '@jest/globals'
import { describe, it, expect } from 'bun:test'
import { IQuest } from '../schema'
import { GameSession } from '../Session'
import { MockFileChecker } from './asyncCondition.test'
import { MockFileChecker } from './mockFileChecker'
const quest: IQuest = {
id: 'quest1',
+2 -2
View File
@@ -1,6 +1,6 @@
import { test, expect } from '@jest/globals'
import { test, expect } from 'bun:test'
import { Stage } from '../Stage'
import { MockFileChecker } from './asyncCondition.test'
import { MockFileChecker } from './mockFileChecker'
const checker = new MockFileChecker()
+1 -1
View File
@@ -1,4 +1,4 @@
import { test, expect } from '@jest/globals'
import { test, expect } from 'bun:test'
import { isValidEmail, isValidUsername } from '../auth'
test('check valid username', () => {
+1 -1
View File
@@ -1,4 +1,4 @@
import { describe, it, expect } from '@jest/globals'
import { describe, it, expect } from 'bun:test'
import { buildFileCheckCmd, File } from '../commands'
describe('buildFileCheckCmd function', () => {
+1 -1
View File
@@ -1,4 +1,4 @@
import { describe, it, expect } from '@jest/globals'
import { describe, it, expect } from 'bun:test'
import DAG from '../dag'
describe('dag layers', () => {