Skip to content

Commit

Permalink
pass test/loader/get_app_info.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jun 17, 2024
1 parent 5e28f95 commit 98a77b3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 45 deletions.
45 changes: 0 additions & 45 deletions test/loader/get_app_info.test.js

This file was deleted.

44 changes: 44 additions & 0 deletions test/loader/get_app_info.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { strict as assert } from 'node:assert';
import mm from 'mm';
import { Application, createApp, getFilepath } from '../helper.js';

describe('test/loader/get_app_info.test.ts', () => {
let app: Application;
afterEach(() => app.close());
afterEach(mm.restore);

it('should get appInfo', () => {
app = createApp('appinfo');
assert.equal(app.loader.appInfo.name, 'appinfo');
assert.equal(app.loader.appInfo.baseDir, getFilepath('appinfo'));
assert.equal(app.loader.appInfo.env, 'unittest');
assert.equal(app.loader.appInfo.HOME, process.env.HOME);
assert.deepEqual(app.loader.appInfo.pkg, {
name: 'appinfo',
});
});

it('should get root when unittest', () => {
mm(process.env, 'EGG_SERVER_ENV', 'unittest');
app = createApp('appinfo');
assert.equal(app.loader.appInfo.root, getFilepath('appinfo'));
});

it('should get root when unittest', () => {
mm(process.env, 'EGG_SERVER_ENV', 'local');
app = createApp('appinfo');
assert.equal(app.loader.appInfo.root, getFilepath('appinfo'));
});

it('should get root when unittest', () => {
mm(process.env, 'EGG_SERVER_ENV', 'default');
app = createApp('appinfo');
assert.equal(app.loader.appInfo.root, process.env.HOME);
});

it('should get scope when specified', () => {
mm(process.env, 'EGG_SERVER_SCOPE', 'en');
app = createApp('appinfo');
assert.equal(app.loader.appInfo.scope, 'en');
});
});

0 comments on commit 98a77b3

Please sign in to comment.