Skip to content

Commit

Permalink
test: update test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 2, 2023
1 parent 67bb12d commit 47a2942
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"types": "./lib/index.d.ts",
"exports": {
".": "./lib/index.js",
"./load-conf": "./lib/loader/jsloader.js"
"./load-conf": "./lib/loader/js.js"
},
"homepage": "https://jaywcjlove.github.io/auto-config-loader",
"repository": {
Expand Down
16 changes: 8 additions & 8 deletions core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import fs from 'fs';
import path from 'path';
import merge from 'lodash.merge';
import { jsLoader, LoadConfOption } from './loader/jsloader';
import { jsonLoader } from './loader/jsonloader';
import { yamlLoader } from './loader/yamlloader';
import { tomlLoader } from './loader/tomlloader';
import { jsLoader, LoadConfOption } from './loader/js';
import { jsonLoader } from './loader/json';
import { yamlLoader } from './loader/yaml';
import { tomlLoader } from './loader/toml';
import { iniLoader } from './loader/ini';
import { findConfigFile } from './utils';

export * from './loader/jsloader';
export * from './loader/jsonloader';
export * from './loader/yamlloader';
export * from './loader/tomlloader';
export * from './loader/js';
export * from './loader/json';
export * from './loader/yaml';
export * from './loader/toml';
export * from './loader/ini';

export type LoaderFunc<T> = (filepath: string, content: string, jsOption?: LoadConfOption) => T;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 11 additions & 1 deletion core/test/loader.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import path from 'path';
import { loadConf } from "../src/loader/jsloader";
import { loadConf } from "../src/loader/js";

const tsPath = path.resolve(__dirname, '../config-example/ext-ts/.autoconfrc.ts');

test('loadConf test case', () => {
// @ts-ignore
expect(loadConf()).toEqual({});
const result = loadConf<any>(tsPath);
expect(result.projectName).toEqual('ext-ts');
expect(result('good')).toEqual('good123');
});

test('loadConf test case', () => {
const result = loadConf<any>(tsPath, { jiti: false });
expect(result.projectName).toBeUndefined();
expect(result('good')).toEqual('good123');
});

0 comments on commit 47a2942

Please sign in to comment.