Skip to content

Commit b7b0de4

Browse files
committed
tests: More tests for array shorthand
1 parent fac759d commit b7b0de4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/utils/__tests__/getFlowType-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,22 @@ describe('getFlowType', () => {
6363
var typePath = expression('x: xyz').get('typeAnnotation').get('typeAnnotation');
6464
expect(getFlowType(typePath)).toEqual({ name: 'xyz' });
6565
});
66+
6667
it('detects external nullable type', () => {
6768
var typePath = expression('x: ?xyz').get('typeAnnotation').get('typeAnnotation');
6869
expect(getFlowType(typePath)).toEqual({ name: 'xyz', nullable: true });
6970
});
7071

72+
it('detects array type shorthand optional', () => {
73+
var typePath = expression('x: ?number[]').get('typeAnnotation').get('typeAnnotation');
74+
expect(getFlowType(typePath)).toEqual({ name: 'Array', elements: [{ name: 'number' }], raw: 'number[]', nullable: true });
75+
});
76+
77+
it('detects array type shorthand optional type', () => {
78+
var typePath = expression('x: (?number)[]').get('typeAnnotation').get('typeAnnotation');
79+
expect(getFlowType(typePath)).toEqual({ name: 'Array', elements: [{ name: 'number', nullable: true }], raw: 'number[]' });
80+
});
81+
7182
it('detects array type shorthand', () => {
7283
var typePath = expression('x: number[]').get('typeAnnotation').get('typeAnnotation');
7384
expect(getFlowType(typePath)).toEqual({ name: 'Array', elements: [{ name: 'number' }], raw: 'number[]' });

0 commit comments

Comments
 (0)