-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
454 additions
and
181 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { getHandleError } from '../lib' | ||
import { getParseMosTypes } from '../parseMosTypes' | ||
|
||
describe('lib', () => { | ||
test('getHandleError types', () => { | ||
const { mosString128 } = getParseMosTypes(true) | ||
const handleError = getHandleError('unit test') | ||
|
||
handleError(mosString128.createRequired, 'test', 'path') | ||
|
||
// @ts-expect-error number is not a valid XML type, only string | ||
handleError(mosString128.createRequired, 1234, 'path') | ||
}) | ||
}) |
59 changes: 59 additions & 0 deletions
59
packages/helper/src/mosModel/__tests__/parseMosTypes.spec.ts
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,59 @@ | ||
import { AnyXMLValue, AnyXMLValueSingular } from '@mos-connection/model' | ||
import { getParseMosTypes } from '../parseMosTypes' | ||
|
||
describe('parseMosTypes', () => { | ||
test('createRequired types', () => { | ||
const parseMosTypes = getParseMosTypes(true) | ||
|
||
const testTypes = (xmlValue: AnyXMLValue, xmlValueSingular: AnyXMLValueSingular) => { | ||
parseMosTypes.mosString128.createRequired(xmlValue) | ||
parseMosTypes.mosTime.createRequired(xmlValue) | ||
parseMosTypes.mosDuration.createRequired(xmlValue) | ||
|
||
parseMosTypes.mosString128.createRequired(xmlValueSingular) | ||
parseMosTypes.mosTime.createRequired(xmlValueSingular) | ||
parseMosTypes.mosDuration.createRequired(xmlValueSingular) | ||
|
||
// @ts-expect-error bad type | ||
parseMosTypes.mosString128.createRequired({ somethingNonXml: 1234 }) | ||
// @ts-expect-error bad type | ||
parseMosTypes.mosTime.createRequired({ somethingNonXml: 1234 }) | ||
// @ts-expect-error bad type | ||
parseMosTypes.mosDuration.createRequired({ somethingNonXml: 1234 }) | ||
} | ||
try { | ||
testTypes('', '') | ||
} catch { | ||
// Ignore any errors | ||
} | ||
|
||
expect(1).toEqual(1) | ||
}) | ||
test('createOptional types', () => { | ||
const parseMosTypes = getParseMosTypes(true) | ||
|
||
const testTypes = (xmlValue: AnyXMLValue, xmlValueSingular: AnyXMLValueSingular) => { | ||
parseMosTypes.mosString128.createOptional(xmlValue) | ||
parseMosTypes.mosTime.createOptional(xmlValue) | ||
parseMosTypes.mosDuration.createOptional(xmlValue) | ||
|
||
parseMosTypes.mosString128.createOptional(xmlValueSingular) | ||
parseMosTypes.mosTime.createOptional(xmlValueSingular) | ||
parseMosTypes.mosDuration.createOptional(xmlValueSingular) | ||
|
||
// @ts-expect-error bad type | ||
parseMosTypes.mosString128.createOptional({ somethingNonXml: 1234 }) | ||
// @ts-expect-error bad type | ||
parseMosTypes.mosTime.createOptional({ somethingNonXml: 1234 }) | ||
// @ts-expect-error bad type | ||
parseMosTypes.mosDuration.createOptional({ somethingNonXml: 1234 }) | ||
} | ||
try { | ||
testTypes('', '') | ||
} catch { | ||
// Ignore any errors | ||
} | ||
|
||
expect(1).toEqual(1) | ||
}) | ||
}) |
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
Oops, something went wrong.