Skip to content

Commit 0082d4f

Browse files
committed
8.0.0, auto-format tests
1 parent d898361 commit 0082d4f

File tree

7 files changed

+43
-49
lines changed

7 files changed

+43
-49
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 8.0.0
4+
5+
- e144890 Improve generated output when mixing nulls and unions (#261)
6+
37
## 7.1.0
48

59
- ddbd627 Add `strictIndexSignatures` CLI option, defaulting to false (#252)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-schema-to-typescript",
3-
"version": "7.1.0",
3+
"version": "8.0.0",
44
"description": "compile json schema to typescript typings",
55
"main": "dist/src/index.js",
66
"bin": {
@@ -15,7 +15,7 @@
1515
"build:browser": "browserify src/index.ts -s jstt -p tsify > dist/bundle.js",
1616
"build:server": "tsc -d",
1717
"clean": "shx rm -rf dist",
18-
"lint": "eslint src/*.ts",
18+
"lint": "eslint src/*.ts test/*.ts",
1919
"tdd": "concurrently -r -p '' -k 'npm run watch' 'npm run watch:test'",
2020
"test": "ava --serial --verbose",
2121
"prepublishOnly": "npm test",

test/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { run as runCLITests } from './testCLI'
2-
import { run as runCompileFromFileTests } from './testCompileFromFile'
3-
import { hasOnly, run as runE2ETests } from './testE2E'
4-
import { run as runNormalizerTests } from './testNormalizer'
1+
import {run as runCLITests} from './testCLI'
2+
import {run as runCompileFromFileTests} from './testCompileFromFile'
3+
import {hasOnly, run as runE2ETests} from './testE2E'
4+
import {run as runNormalizerTests} from './testNormalizer'
55

66
runE2ETests()
77

test/testCLI.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,32 @@
11
import test from 'ava'
2-
import { execSync } from 'child_process'
3-
import { readFileSync, unlinkSync } from 'fs'
2+
import {execSync} from 'child_process'
3+
import {readFileSync, unlinkSync} from 'fs'
44

55
export function run() {
6-
76
test('pipe in, pipe out', t => {
87
t.snapshot(
9-
execSync('shx cat ./test/resources/ReferencedType.json | node dist/src/cli.js', { encoding: 'utf-8' }).toString()
8+
execSync('shx cat ./test/resources/ReferencedType.json | node dist/src/cli.js', {encoding: 'utf-8'}).toString()
109
)
1110
})
1211

1312
test('pipe in (schema without ID), pipe out', t => {
1413
t.snapshot(
15-
execSync('shx cat ./test/resources/ReferencedTypeWithoutID.json | node dist/src/cli.js', { encoding: 'utf-8' }).toString()
14+
execSync('shx cat ./test/resources/ReferencedTypeWithoutID.json | node dist/src/cli.js', {
15+
encoding: 'utf-8'
16+
}).toString()
1617
)
1718
})
1819

1920
test('file in (no flags), pipe out', t => {
20-
t.snapshot(
21-
execSync('node dist/src/cli.js ./test/resources/ReferencedType.json').toString()
22-
)
21+
t.snapshot(execSync('node dist/src/cli.js ./test/resources/ReferencedType.json').toString())
2322
})
2423

2524
test('file in (--input), pipe out', t => {
26-
t.snapshot(
27-
execSync('node dist/src/cli.js --input ./test/resources/ReferencedType.json').toString()
28-
)
25+
t.snapshot(execSync('node dist/src/cli.js --input ./test/resources/ReferencedType.json').toString())
2926
})
3027

3128
test('file in (-i), pipe out', t => {
32-
t.snapshot(
33-
execSync('node dist/src/cli.js -i ./test/resources/ReferencedType.json').toString()
34-
)
29+
t.snapshot(execSync('node dist/src/cli.js -i ./test/resources/ReferencedType.json').toString())
3530
})
3631

3732
test('file in (-i), unreachable definitions flag, pipe out', t => {
@@ -47,13 +42,13 @@ export function run() {
4742
})
4843

4944
test('file in (-i), pipe out (absolute path)', t => {
50-
t.snapshot(
51-
execSync(`node dist/src/cli.js -i ${__dirname}/../../test/resources/ReferencedType.json`).toString()
52-
)
45+
t.snapshot(execSync(`node dist/src/cli.js -i ${__dirname}/../../test/resources/ReferencedType.json`).toString())
5346
})
5447

5548
test('pipe in, file out (--output)', t => {
56-
execSync('shx cat ./test/resources/ReferencedType.json | node dist/src/cli.js --output ./ReferencedType.d.ts').toString()
49+
execSync(
50+
'shx cat ./test/resources/ReferencedType.json | node dist/src/cli.js --output ./ReferencedType.d.ts'
51+
).toString()
5752
t.snapshot(readFileSync('./ReferencedType.d.ts', 'utf-8'))
5853
unlinkSync('./ReferencedType.d.ts')
5954
})
@@ -77,9 +72,10 @@ export function run() {
7772
})
7873

7974
test('file in (--input), file out (--output)', t => {
80-
execSync('node dist/src/cli.js --input ./test/resources/ReferencedType.json --output ./ReferencedType.d.ts').toString()
75+
execSync(
76+
'node dist/src/cli.js --input ./test/resources/ReferencedType.json --output ./ReferencedType.d.ts'
77+
).toString()
8178
t.snapshot(readFileSync('./ReferencedType.d.ts', 'utf-8'))
8279
unlinkSync('./ReferencedType.d.ts')
8380
})
84-
8581
}

test/testCompileFromFile.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import test from 'ava'
2-
import { compileFromFile } from '../src'
2+
import {compileFromFile} from '../src'
33

44
export function run() {
5-
65
test('compileFromFile should resolve refs from cwd option', async t =>
7-
t.snapshot(await compileFromFile('./test/resources/other/ReferencingType.json', {cwd: './test/resources'}))
8-
)
9-
6+
t.snapshot(await compileFromFile('./test/resources/other/ReferencingType.json', {cwd: './test/resources'})))
107
}

test/testE2E.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import test from 'ava'
2-
import { readdirSync } from 'fs'
3-
import { find } from 'lodash'
4-
import { join } from 'path'
5-
import { compile, JSONSchema, Options } from '../src'
6-
import { log, stripExtension } from '../src/utils'
2+
import {readdirSync} from 'fs'
3+
import {find} from 'lodash'
4+
import {join} from 'path'
5+
import {compile, JSONSchema, Options} from '../src'
6+
import {log, stripExtension} from '../src/utils'
77

88
const dir = __dirname + '/e2e'
99

@@ -23,7 +23,6 @@ export function hasOnly() {
2323
}
2424

2525
export function run() {
26-
2726
// [filename, absolute dirname, contents][]
2827
const modules = readdirSync(dir)
2928
.filter(_ => /^.*\.js$/.test(_))
@@ -35,9 +34,7 @@ export function run() {
3534
if (only) {
3635
runOne(only[1], only[0])
3736
} else {
38-
modules
39-
.filter(_ => !_[1].exclude)
40-
.forEach(_ => runOne(_[1], _[0]))
37+
modules.filter(_ => !_[1].exclude).forEach(_ => runOne(_[1], _[0]))
4138
}
4239
}
4340

test/testNormalizer.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import test from 'ava'
2-
import { readdirSync } from 'fs'
3-
import { template } from 'lodash'
4-
import { join } from 'path'
5-
import { JSONSchema } from '../src'
6-
import { normalize } from '../src/normalizer'
2+
import {readdirSync} from 'fs'
3+
import {template} from 'lodash'
4+
import {join} from 'path'
5+
import {JSONSchema} from '../src'
6+
import {normalize} from '../src/normalizer'
77

88
interface JSONTestCase {
99
name: string
@@ -19,15 +19,15 @@ export function run() {
1919
.map(_ => join(normalizerDir, _))
2020
.map(_ => [_, require(_)] as [string, JSONTestCase])
2121
.forEach(([filename, json]: [string, JSONTestCase]) => {
22-
const params = { filename }
22+
const params = {filename}
2323
test(json.name, t => {
24-
const normalised = normalize(json.in, filename);
24+
const normalised = normalize(json.in, filename)
2525
t.snapshot(template(toString(normalised))(params))
26-
t.deepEqual(json.out, normalised);
26+
t.deepEqual(json.out, normalised)
2727
})
2828
})
2929
}
3030

31-
function toString(json: Object): string {
31+
function toString(json: Record<string, any>): string {
3232
return JSON.stringify(json, null, 2)
3333
}

0 commit comments

Comments
 (0)