mirror of
https://github.com/flarum/core.git
synced 2025-07-16 06:16:23 +02:00
feat(jest): create jest config package for unit testing (#3678)
* feat(jest): create jest config package for unit testing * chore: housekeeping * fix: now we need to explicitly allow importing without extension * fix: recover EditorDriverInterface import * Apply suggestions from code review * chore: yarn Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
This commit is contained in:
1
framework/core/js/jest.config.cjs
Normal file
1
framework/core/js/jest.config.cjs
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('flarum-jest-config')({});
|
@ -2,6 +2,7 @@
|
||||
"private": true,
|
||||
"name": "@flarum/core",
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"prettier": "@flarum/prettier-config",
|
||||
"dependencies": {
|
||||
"@askvortsov/rich-icu-message-formatter": "^0.2.4",
|
||||
@ -30,6 +31,7 @@
|
||||
"bundlewatch": "^0.3.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"expose-loader": "^3.1.0",
|
||||
"flarum-jest-config": "^1.0.0",
|
||||
"flarum-tsconfig": "^1.0.2",
|
||||
"flarum-webpack-config": "^2.0.0",
|
||||
"prettier": "^2.5.1",
|
||||
@ -49,6 +51,7 @@
|
||||
"build-typings": "yarn run clean-typings && ([ -e src/@types ] && cp -r src/@types dist-typings/@types || true) && tsc && yarn run post-build-typings",
|
||||
"post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'",
|
||||
"check-typings": "tsc --noEmit --emitDeclarationOnly false",
|
||||
"check-typings-coverage": "typescript-coverage-report"
|
||||
"check-typings-coverage": "typescript-coverage-report",
|
||||
"test": "yarn node --experimental-vm-modules $(yarn bin jest)"
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
import getCaretCoordinates from 'textarea-caret';
|
||||
import insertText from './insertText';
|
||||
import EditorDriverInterface, { EditorDriverParams } from './EditorDriverInterface';
|
||||
import ItemList from './ItemList';
|
||||
import type EditorDriverInterface from './EditorDriverInterface';
|
||||
import { type EditorDriverParams } from './EditorDriverInterface';
|
||||
|
||||
export default class BasicEditorDriver implements EditorDriverInterface {
|
||||
el: HTMLTextAreaElement;
|
||||
|
@ -2,7 +2,6 @@ import app from '../../forum/app';
|
||||
import subclassOf from '../../common/utils/subclassOf';
|
||||
import Stream from '../../common/utils/Stream';
|
||||
import ReplyComposer from '../components/ReplyComposer';
|
||||
import EditorDriverInterface from '../../common/utils/EditorDriverInterface';
|
||||
|
||||
class ComposerState {
|
||||
constructor() {
|
||||
@ -31,7 +30,7 @@ class ComposerState {
|
||||
/**
|
||||
* A reference to the text editor that allows text manipulation.
|
||||
*
|
||||
* @type {EditorDriverInterface|null}
|
||||
* @type {import('../../common/utils/EditorDriverInterface')|null}
|
||||
*/
|
||||
this.editor = null;
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
import abbreviateNumber from '../../../../src/common/utils/abbreviateNumber';
|
||||
|
||||
test('does not change small numbers', () => {
|
||||
expect(abbreviateNumber(1)).toBe('1');
|
||||
});
|
||||
|
||||
test('abbreviates large numbers', () => {
|
||||
expect(abbreviateNumber(1000000)).toBe('1M');
|
||||
expect(abbreviateNumber(100500)).toBe('100.5K');
|
||||
});
|
||||
|
||||
test('abbreviates large numbers with decimal places', () => {
|
||||
expect(abbreviateNumber(100500)).toBe('100.5K');
|
||||
expect(abbreviateNumber(13234)).toBe('13.2K');
|
||||
});
|
@ -1,6 +1,6 @@
|
||||
// NOTE:
|
||||
// If you're looking at core's `tsconfig.json` for the "perfect"
|
||||
// tsconfig for your erxtension, look at the dedicated tsconfig
|
||||
// tsconfig for your extension, look at the dedicated tsconfig
|
||||
// repo instead.
|
||||
//
|
||||
// https://github.com/flarum/flarum-tsconfig
|
||||
|
Reference in New Issue
Block a user