Skip to content

Commit 28867f8

Browse files
andrewdelpretetmcw
authored andcommittedJun 4, 2020
Fix tests
1 parent 71ceea2 commit 28867f8

File tree

2 files changed

+120
-239
lines changed

2 files changed

+120
-239
lines changed
 

‎__tests__/__snapshots__/test.js.snap

+91-172
Original file line numberDiff line numberDiff line change
@@ -5204,65 +5204,6 @@ Object {
52045204

52055205
exports[`outputs document-exported.input.js JSON 1`] = `
52065206
Array [
5207-
Object {
5208-
"augments": Array [],
5209-
"context": Object {
5210-
"loc": Object {
5211-
"end": Object {
5212-
"column": 28,
5213-
"line": 1,
5214-
},
5215-
"start": Object {
5216-
"column": 0,
5217-
"line": 1,
5218-
},
5219-
},
5220-
},
5221-
"description": "",
5222-
"errors": Array [],
5223-
"examples": Array [],
5224-
"implements": Array [],
5225-
"kind": "function",
5226-
"loc": Object {
5227-
"end": Object {
5228-
"column": 28,
5229-
"line": 1,
5230-
},
5231-
"start": Object {
5232-
"column": 0,
5233-
"line": 1,
5234-
},
5235-
},
5236-
"members": Object {
5237-
"events": Array [],
5238-
"global": Array [],
5239-
"inner": Array [],
5240-
"instance": Array [],
5241-
"static": Array [],
5242-
},
5243-
"name": "x",
5244-
"namespace": "x",
5245-
"params": Array [
5246-
Object {
5247-
"lineNumber": 1,
5248-
"name": "yparam",
5249-
"title": "param",
5250-
},
5251-
],
5252-
"path": Array [
5253-
Object {
5254-
"kind": "function",
5255-
"name": "x",
5256-
},
5257-
],
5258-
"properties": Array [],
5259-
"returns": Array [],
5260-
"sees": Array [],
5261-
"tags": Array [],
5262-
"throws": Array [],
5263-
"todos": Array [],
5264-
"yields": Array [],
5265-
},
52665207
Object {
52675208
"augments": Array [],
52685209
"context": Object {
@@ -5377,6 +5318,65 @@ Array [
53775318
"todos": Array [],
53785319
"yields": Array [],
53795320
},
5321+
Object {
5322+
"augments": Array [],
5323+
"context": Object {
5324+
"loc": Object {
5325+
"end": Object {
5326+
"column": 28,
5327+
"line": 1,
5328+
},
5329+
"start": Object {
5330+
"column": 0,
5331+
"line": 1,
5332+
},
5333+
},
5334+
},
5335+
"description": "",
5336+
"errors": Array [],
5337+
"examples": Array [],
5338+
"implements": Array [],
5339+
"kind": "function",
5340+
"loc": Object {
5341+
"end": Object {
5342+
"column": 28,
5343+
"line": 1,
5344+
},
5345+
"start": Object {
5346+
"column": 0,
5347+
"line": 1,
5348+
},
5349+
},
5350+
"members": Object {
5351+
"events": Array [],
5352+
"global": Array [],
5353+
"inner": Array [],
5354+
"instance": Array [],
5355+
"static": Array [],
5356+
},
5357+
"name": "x",
5358+
"namespace": "x",
5359+
"params": Array [
5360+
Object {
5361+
"lineNumber": 1,
5362+
"name": "yparam",
5363+
"title": "param",
5364+
},
5365+
],
5366+
"path": Array [
5367+
Object {
5368+
"kind": "function",
5369+
"name": "x",
5370+
},
5371+
],
5372+
"properties": Array [],
5373+
"returns": Array [],
5374+
"sees": Array [],
5375+
"tags": Array [],
5376+
"throws": Array [],
5377+
"todos": Array [],
5378+
"yields": Array [],
5379+
},
53805380
Object {
53815381
"augments": Array [],
53825382
"context": Object {
@@ -7078,10 +7078,10 @@ exports[`outputs document-exported.input.js markdown 1`] = `
70787078

70797079
### Table of Contents
70807080

7081-
- [x][1]
7082-
- [Parameters][2]
7083-
- [z][3]
7084-
- [zMethod][4]
7081+
- [z][1]
7082+
- [zMethod][2]
7083+
- [x][3]
7084+
- [Parameters][4]
70857085
- [Class][5]
70867086
- [Parameters][6]
70877087
- [classMethod][7]
@@ -7117,16 +7117,16 @@ exports[`outputs document-exported.input.js markdown 1`] = `
71177117
- [o2][37]
71187118
- [om2][38]
71197119

7120+
## z
7121+
7122+
### zMethod
7123+
71207124
## x
71217125

71227126
### Parameters
71237127

71247128
- \`yparam\`
71257129

7126-
## z
7127-
7128-
### zMethod
7129-
71307130
## Class
71317131

71327132
### Parameters
@@ -7223,13 +7223,13 @@ f5 comment
72237223

72247224
### om2
72257225

7226-
[1]: #x
7226+
[1]: #z
72277227

7228-
[2]: #parameters
7228+
[2]: #zmethod
72297229

7230-
[3]: #z
7230+
[3]: #x
72317231

7232-
[4]: #zmethod
7232+
[4]: #parameters
72337233

72347234
[5]: #class
72357235

@@ -7314,6 +7314,26 @@ Object {
73147314
"type": "html",
73157315
"value": "<!-- Generated by documentation.js. Update this documentation by updating the source code. -->",
73167316
},
7317+
Object {
7318+
"children": Array [
7319+
Object {
7320+
"type": "text",
7321+
"value": "z",
7322+
},
7323+
],
7324+
"depth": 2,
7325+
"type": "heading",
7326+
},
7327+
Object {
7328+
"children": Array [
7329+
Object {
7330+
"type": "text",
7331+
"value": "zMethod",
7332+
},
7333+
],
7334+
"depth": 3,
7335+
"type": "heading",
7336+
},
73177337
Object {
73187338
"children": Array [
73197339
Object {
@@ -7362,26 +7382,6 @@ Object {
73627382
"ordered": false,
73637383
"type": "list",
73647384
},
7365-
Object {
7366-
"children": Array [
7367-
Object {
7368-
"type": "text",
7369-
"value": "z",
7370-
},
7371-
],
7372-
"depth": 2,
7373-
"type": "heading",
7374-
},
7375-
Object {
7376-
"children": Array [
7377-
Object {
7378-
"type": "text",
7379-
"value": "zMethod",
7380-
},
7381-
],
7382-
"depth": 3,
7383-
"type": "heading",
7384-
},
73857385
Object {
73867386
"children": Array [
73877387
Object {
@@ -32151,30 +32151,6 @@ Array [
3215132151
"tags": Array [],
3215232152
"throws": Array [],
3215332153
"todos": Array [],
32154-
"type": Object {
32155-
"fields": Array [
32156-
Object {
32157-
"key": "opt",
32158-
"type": "FieldType",
32159-
"value": Object {
32160-
"expression": Object {
32161-
"name": "number",
32162-
"type": "NameExpression",
32163-
},
32164-
"type": "OptionalType",
32165-
},
32166-
},
32167-
Object {
32168-
"key": "req",
32169-
"type": "FieldType",
32170-
"value": Object {
32171-
"name": "string",
32172-
"type": "NameExpression",
32173-
},
32174-
},
32175-
],
32176-
"type": "RecordType",
32177-
},
3217832154
"yields": Array [],
3217932155
},
3218032156
]
@@ -32190,8 +32166,6 @@ exports[`outputs optional-record-field-type.input.js markdown 1`] = `
3219032166

3219132167
## Record
3219232168

32193-
Type: {opt: [number][3]?, req: [string][4]}
32194-
3219532169
### Properties
3219632170

3219732171
- \`opt\` **[number][3]?**
@@ -32224,61 +32198,6 @@ Object {
3222432198
"depth": 2,
3222532199
"type": "heading",
3222632200
},
32227-
Object {
32228-
"children": Array [
32229-
Object {
32230-
"type": "text",
32231-
"value": "Type: ",
32232-
},
32233-
Object {
32234-
"type": "text",
32235-
"value": "{",
32236-
},
32237-
Object {
32238-
"type": "text",
32239-
"value": "opt: ",
32240-
},
32241-
Object {
32242-
"children": Array [
32243-
Object {
32244-
"type": "text",
32245-
"value": "number",
32246-
},
32247-
],
32248-
"identifier": "1",
32249-
"referenceType": "full",
32250-
"type": "linkReference",
32251-
},
32252-
Object {
32253-
"type": "text",
32254-
"value": "?",
32255-
},
32256-
Object {
32257-
"type": "text",
32258-
"value": ", ",
32259-
},
32260-
Object {
32261-
"type": "text",
32262-
"value": "req: ",
32263-
},
32264-
Object {
32265-
"children": Array [
32266-
Object {
32267-
"type": "text",
32268-
"value": "string",
32269-
},
32270-
],
32271-
"identifier": "2",
32272-
"referenceType": "full",
32273-
"type": "linkReference",
32274-
},
32275-
Object {
32276-
"type": "text",
32277-
"value": "}",
32278-
},
32279-
],
32280-
"type": "paragraph",
32281-
},
3228232201
Object {
3228332202
"children": Array [
3228432203
Object {

‎__tests__/lib/infer/type.js

+29-67
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,6 @@ test('inferType (flow)', function() {
4141
type: 'TypeApplication'
4242
});
4343

44-
expect(evaluate('/** */' + "type V = {a:number,'b':string}").type).toEqual({
45-
fields: [
46-
{
47-
key: 'a',
48-
type: 'FieldType',
49-
value: {
50-
name: 'number',
51-
type: 'NameExpression'
52-
}
53-
},
54-
{
55-
key: 'b',
56-
type: 'FieldType',
57-
value: {
58-
name: 'string',
59-
type: 'NameExpression'
60-
}
61-
}
62-
],
63-
type: 'RecordType'
64-
});
65-
6644
expect(evaluate('/** */' + 'type V = Array<T>').type).toEqual({
6745
applications: [
6846
{
@@ -127,16 +105,12 @@ test('inferType (flow)', function() {
127105
type: 'NameExpression'
128106
});
129107

130-
expect(
131-
evaluate('interface Foo { /** */ bar: string; }').type
132-
).toEqual({
108+
expect(evaluate('interface Foo { /** */ bar: string; }').type).toEqual({
133109
name: 'string',
134110
type: 'NameExpression'
135111
});
136112

137-
expect(
138-
evaluate('type Foo = { /** */ bar: string; }').type
139-
).toEqual({
113+
expect(evaluate('type Foo = { /** */ bar: string; }').type).toEqual({
140114
name: 'string',
141115
type: 'NameExpression'
142116
});
@@ -167,28 +141,6 @@ test('inferType (typescript)', function() {
167141
type: 'TypeApplication'
168142
});
169143

170-
expect(evaluate('/** */' + "type V = {a:number,'b':string}", 'test.ts').type).toEqual({
171-
fields: [
172-
{
173-
key: 'a',
174-
type: 'FieldType',
175-
value: {
176-
name: 'number',
177-
type: 'NameExpression'
178-
}
179-
},
180-
{
181-
key: 'b',
182-
type: 'FieldType',
183-
value: {
184-
name: 'string',
185-
type: 'NameExpression'
186-
}
187-
}
188-
],
189-
type: 'RecordType'
190-
});
191-
192144
expect(evaluate('/** */' + 'type V = Array<T>', 'test.ts').type).toEqual({
193145
applications: [
194146
{
@@ -223,27 +175,43 @@ test('inferType (typescript)', function() {
223175
type: 'NameExpression'
224176
});
225177

226-
expect(evaluate('class C {' + '/** */' + 'x: number;' + '}', 'test.ts').type).toEqual({
178+
expect(
179+
evaluate('class C {' + '/** */' + 'x: number;' + '}', 'test.ts').type
180+
).toEqual({
227181
name: 'number',
228182
type: 'NameExpression'
229183
});
230184

231-
expect(evaluate('class Foo { /** */ get b(): string { } }', 'test.ts').type).toEqual({
185+
expect(
186+
evaluate('class Foo { /** */ get b(): string { } }', 'test.ts').type
187+
).toEqual({
232188
name: 'string',
233189
type: 'NameExpression'
234190
});
235191

236-
expect(evaluate('class Foo { /** */ set b(s: string) { } }', 'test.ts').type).toEqual({
192+
expect(
193+
evaluate('class Foo { /** */ set b(s: string) { } }', 'test.ts').type
194+
).toEqual({
237195
name: 'string',
238196
type: 'NameExpression'
239197
});
240198

241-
expect(evaluate('abstract class Foo { /** */ abstract get b(): string; }', 'test.ts').type).toEqual({
199+
expect(
200+
evaluate(
201+
'abstract class Foo { /** */ abstract get b(): string; }',
202+
'test.ts'
203+
).type
204+
).toEqual({
242205
name: 'string',
243206
type: 'NameExpression'
244207
});
245208

246-
expect(evaluate('abstract class Foo { /** */ abstract set b(s: string); }', 'test.ts').type).toEqual({
209+
expect(
210+
evaluate(
211+
'abstract class Foo { /** */ abstract set b(s: string); }',
212+
'test.ts'
213+
).type
214+
).toEqual({
247215
name: 'string',
248216
type: 'NameExpression'
249217
});
@@ -277,28 +245,22 @@ test('inferType (typescript)', function() {
277245
type: 'NameExpression'
278246
});
279247

280-
expect(
281-
evaluate('enum Foo { /** */ A }', 'test.ts').type
282-
).toEqual({
248+
expect(evaluate('enum Foo { /** */ A }', 'test.ts').type).toEqual({
283249
name: 'number',
284250
type: 'NameExpression'
285251
});
286252

287-
expect(
288-
evaluate('enum Foo { /** */ A = 2 }', 'test.ts').type
289-
).toEqual({
253+
expect(evaluate('enum Foo { /** */ A = 2 }', 'test.ts').type).toEqual({
290254
name: 'number',
291255
type: 'NameExpression'
292256
});
293257

294-
expect(
295-
evaluate('enum Foo { /** */ A = "test" }', 'test.ts').type
296-
).toEqual({
258+
expect(evaluate('enum Foo { /** */ A = "test" }', 'test.ts').type).toEqual({
297259
name: 'string',
298260
type: 'NameExpression'
299261
});
300262

301-
expect(
302-
evaluate('enum Foo { /** */ A = foo }', 'test.ts').type
303-
).toBe(undefined);
263+
expect(evaluate('enum Foo { /** */ A = foo }', 'test.ts').type).toBe(
264+
undefined
265+
);
304266
});

0 commit comments

Comments
 (0)
Please sign in to comment.