-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import sqlite3, { Database } from 'sqlite3' | ||
import sqlite3Rewire, { | ||
options, | ||
execute, | ||
save, | ||
list, | ||
page, | ||
count, | ||
getOne, | ||
updateById, | ||
remove | ||
} from '../../src/db/sqlite3' | ||
|
||
jest.mock('sqlite3') | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
describe('Test user api', () => { | ||
test('Test pageList', async () => { | ||
const getDb = sqlite3Rewire.__get__('getDb') | ||
await getDb() | ||
expect(options.db).toBeInstanceOf(Database) | ||
|
||
sqlite3.Database = jest.fn().mockImplementation((filePath, callback) => { | ||
if (callback !== undefined) { | ||
callback(new Error('Test')) | ||
} | ||
}) | ||
|
||
options.db = undefined | ||
await getDb() | ||
expect(options.db).toBeInstanceOf(sqlite3.Database) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { datetime } from '../../src/utils/date' | ||
describe('Test date utils', () => { | ||
test('Test datetime', async () => { | ||
const date = new Date('2024-05-29T00:00:00Z') | ||
expect(datetime(date)).toBe('2024-05-29 00:00:00') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
module.exports = { | ||
transform: { | ||
"\\.[jt]sx?$": "babel-jest", | ||
'\\.[jt]sx?$': 'babel-jest', | ||
'^[^.]+.vue$': '@vue/vue3-jest' | ||
}, | ||
testPathIgnorePatterns: ['<rootDir>/node_modules/'], | ||
collectCoverage: true, | ||
collectCoverageFrom: ['src/**/**.vue', 'src/**/**.js', 'src/**/**.ts'], | ||
coverageDirectory: 'coverage', | ||
coverageProvider: 'v8', | ||
coverageReporters: ['text', 'lcov'], | ||
moduleFileExtensions: ['vue', 'js', 'ts'], | ||
testEnvironment: 'jsdom', | ||
testEnvironmentOptions: { | ||
customExportConditions: ['node', 'node-addons'] | ||
} | ||
}, | ||
// moduleNameMapper: { | ||
// '\\.(css|less)$': '<rootDir>/__test__/styleMock.ts' | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
sonar.organization=sunquakes | ||
sonar.projectKey=sunquakes_electron-kits | ||
|
||
sonar.exclusions=src/lang/**.js | ||
sonar.exclusions=src/lang/**.ts | ||
sonar.javascript.lcov.reportPaths=coverage/lcov.info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters