Skip to content

Commit

Permalink
chore: housekeeping
Browse files Browse the repository at this point in the history
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
  • Loading branch information
SychO9 committed Nov 13, 2022
1 parent b1f9190 commit 8072453
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 37 deletions.
2 changes: 1 addition & 1 deletion js-packages/jest-config/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = (options = {}) => ({
],
},
preset: 'ts-jest',
setupFilesAfterEnv: [path.resolve(__dirname, 'src/setup-env.js')],
setupFilesAfterEnv: [path.resolve(__dirname, 'setup-env.js')],
moduleDirectories: ['node_modules', 'src'],
...options,
});
39 changes: 39 additions & 0 deletions js-packages/jest-config/setup-env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import app from '@flarum/core/src/forum/app';
import ForumApplication from '@flarum/core/src/forum/ForumApplication';
import jsYaml from 'js-yaml';
import fs from 'fs';
import jquery from 'jquery';
import m from 'mithril';
import flatten from 'flat';

// Boot the Flarum app.
function bootApp() {
ForumApplication.prototype.mount = () => {};
window.flarum = { extensions: {} };
app.load({
apiDocument: null,
locale: 'en',
locales: {},
resources: [
{
type: 'forums',
id: '1',
attributes: {},
},
],
session: {
userId: 0,
csrfToken: 'test',
},
});
app.translator.addTranslations(flatten(jsYaml.load(fs.readFileSync('../locale/core.yml', 'utf8'))));
app.bootExtensions(window.flarum.extensions);
app.boot();
}

beforeAll(() => {
window.$ = jquery;
window.m = m;

bootApp();
});
36 changes: 0 additions & 36 deletions js-packages/jest-config/src/setup-env.js

This file was deleted.

0 comments on commit 8072453

Please sign in to comment.