-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make optional options optional in typings and add type tests (#622)
* Make optional options optional in typings and add type tests * Run type test on pre-publish * Remove npm lockfile and update Yarn lockfile * Revert lockfile changes * final newline * Use downloaded files from master to prevent whitespace changes
- Loading branch information
1 parent
fa5a733
commit 68a4100
Showing
4 changed files
with
414 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { | ||
XMLParser, | ||
XMLBuilder, | ||
XMLValidator, | ||
type X2jOptions, | ||
type XmlBuilderOptions, | ||
type validationOptions, | ||
} from '../../src/fxp'; | ||
|
||
const parseOpts: X2jOptions = {}; | ||
|
||
const XML = ` | ||
<?xml version="1.0"?> | ||
<SomeElement name="parent"> | ||
<SomeNestedElement name="child"></SomeNestedElement> | ||
</SomeElement> | ||
`; | ||
|
||
const parser = new XMLParser(parseOpts); | ||
const parsed = parser.parse(XML); | ||
|
||
console.log(!!parsed); | ||
|
||
const buildOpts: XmlBuilderOptions = {}; | ||
|
||
const builder = new XMLBuilder(buildOpts); | ||
|
||
const built = builder.build({ | ||
any_name: { | ||
person: { | ||
phone: [ | ||
15555551313, | ||
15555551212 | ||
] | ||
} | ||
} | ||
}); | ||
|
||
console.log(!!built); | ||
|
||
const validateOpts: validationOptions = {}; | ||
|
||
const isValid = XMLValidator.validate(built, validateOpts); | ||
|
||
console.log(!!isValid); | ||
|
||
|
Oops, something went wrong.