This repository has been archived by the owner on Nov 14, 2022. It is now read-only.
forked from bcherny/json-schema-to-typescript
-
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.
- Loading branch information
Boris Cherny
committed
May 22, 2022
1 parent
a7d14c4
commit b78a616
Showing
3 changed files
with
36 additions
and
3 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,28 @@ | ||
import test from 'ava' | ||
import {JSONSchema4} from 'json-schema' | ||
import {cloneDeep} from 'lodash' | ||
import {compile} from '../src' | ||
|
||
export function run() { | ||
const SCHEMA: JSONSchema4 = { | ||
type: 'object', | ||
properties: { | ||
firstName: { | ||
type: 'string' | ||
} | ||
}, | ||
required: ['firstName'] | ||
} | ||
|
||
test('compile() should not mutate its input', async t => { | ||
const before = cloneDeep(SCHEMA) | ||
await compile(SCHEMA, 'A') | ||
t.deepEqual(before, SCHEMA) | ||
}) | ||
|
||
test('compile() should be idempotent', async t => { | ||
const a = await compile(SCHEMA, 'A') | ||
const b = await compile(SCHEMA, 'A') | ||
t.deepEqual(a, b) | ||
}) | ||
} |