-
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.
Add the feature of Custom Parser and add any test unit
- Loading branch information
Showing
6 changed files
with
102 additions
and
32 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "JSON" | ||
} |
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 @@ | ||
type: "YAML" |
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,13 +1,27 @@ | ||
import test from "ava"; | ||
import * as findUp from "find-up"; | ||
import * as path from "path"; | ||
import Config = require("../lib"); | ||
|
||
test("Empty Config", (t) => { | ||
const oneConfig = new Config(); | ||
const configFolderPath = path.resolve(findUp.sync("simples"), "config"); | ||
|
||
test("Much Config", (t) => { | ||
const oneConfig = new Config<{ baz: string; }>(); | ||
const otherConfig = new Config(); | ||
oneConfig.addConfig({ | ||
baz: "foo" | ||
}); | ||
t.not(oneConfig.toString(), otherConfig.toString()); | ||
t.not(oneConfig.toObject(), otherConfig.toObject()); | ||
t.not(oneConfig.getConfig(), otherConfig.getConfig()); | ||
t.is(oneConfig.get("baz"), "foo"); | ||
t.is(otherConfig.get("baz" as never), undefined); | ||
}); | ||
|
||
test("Much Config File", (t) => { | ||
const config = new Config<{ type: string; comment: string; }>(); | ||
config.addConfigPath(path.resolve(configFolderPath, "config.json")); | ||
t.is(config.get("type"), "JSON"); | ||
config.addConfigPath(path.resolve(configFolderPath, "config.yaml")); | ||
t.is(config.get("type"), "YAML"); | ||
}); |