mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
WIP: fixing tests
This commit is contained in:
1 parent
8eaec839d3
commit
2bdb804f24
10 files changed
+49
-29
No files matched your search
@@ -0,0 +1,5 @@
|
||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
}
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
"cli": "yarn workspace client start",
|
||||
"lint": "eslint --ext .js,.vue .",
|
||||
"format": "prettier --ignore-path .prettierignore --write app server",
|
||||
"test": "yarn node --experimental-vm-modules $(yarn bin jest)",
|
||||
"test": "yarn jest",
|
||||
"test:e2e": "yarn workspace tests test",
|
||||
"test:open": "yarn workspace tests test:open",
|
||||
"analytics": "yarn workspace analytics dev",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"types": "dist/index.d.ts",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "tsc && node post-build-script.js"
|
||||
"build": "tsc && node post-build-script.js",
|
||||
"test": "yarn build && jest"
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { basename } from './utils.js'
|
||||
|
||||
export default class File {
|
||||
constructor({ path, type, discovered }) {
|
||||
this.path = path.trimEnd('/')
|
||||
this.name = basename(path)
|
||||
this.type = type
|
||||
this.discovered = discovered
|
||||
}
|
||||
|
||||
isDirectory() {
|
||||
return this.type === 'folder'
|
||||
}
|
||||
|
||||
contains(file) {
|
||||
if (!this.isDirectory()) return false
|
||||
if (this.path === file.path) return true
|
||||
const parentPath = this.path.endsWith('/') ? this.path : `${this.path}/`
|
||||
return file.path.startsWith(parentPath)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
import File from './file.js'
|
||||
import { describe, expect, test } from '@jest/globals'
|
||||
|
||||
import File from './file'
|
||||
|
||||
describe('File', () => {
|
||||
let file
|
||||
@@ -0,0 +1,33 @@
|
||||
/* eslint-disable lines-between-class-members */
|
||||
import { basename } from './utils'
|
||||
|
||||
interface FileObject {
|
||||
path: string
|
||||
type: string
|
||||
discovered: boolean
|
||||
}
|
||||
|
||||
export default class File implements FileObject {
|
||||
path: string
|
||||
name: string
|
||||
type: string
|
||||
discovered: boolean
|
||||
|
||||
constructor(obj: FileObject) {
|
||||
this.path = obj.path.trimEnd()
|
||||
this.name = basename(obj.path)
|
||||
this.type = obj.type
|
||||
this.discovered = obj.discovered
|
||||
}
|
||||
|
||||
isDirectory() {
|
||||
return this.type === 'folder'
|
||||
}
|
||||
|
||||
contains(file: FileObject) {
|
||||
if (!this.isDirectory()) return false
|
||||
if (this.path === file.path) return true
|
||||
const parentPath = this.path.endsWith('/') ? this.path : `${this.path}/`
|
||||
return file.path.startsWith(parentPath)
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import FileGraph from './fileGraph.js'
|
||||
import FileNode from './fileNode.js'
|
||||
import FileGraph from './fileGraph'
|
||||
import FileNode from './fileNode'
|
||||
|
||||
describe('FileGraph', () => {
|
||||
let root
|
||||
@@ -1,4 +1,4 @@
|
||||
import File from './file.js'
|
||||
import File from './file'
|
||||
import {
|
||||
DuplicateItemError,
|
||||
ParentNotExistsError,
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { DuplicateItemError, ParentNotExistsError } from './errors'
|
||||
import FileNode from './fileNode.js'
|
||||
import FileNode from './fileNode'
|
||||
|
||||
function createNodeFromFiles(files) {
|
||||
const node = new FileNode(files[0])
|
||||
@@ -1,3 +1,3 @@
|
||||
export { default as File } from './file.js'
|
||||
export { default as File } from './file'
|
||||
export { default as FileNode } from './fileNode.js'
|
||||
export { default as FileGraph } from './fileGraph.js'
|
||||
Reference in new issue
Block a user