Skip to content

Commit 484a827

Browse files
add tests for new throwing function
1 parent 5df9d38 commit 484a827

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

packages/react-native-codegen/src/parsers/__tests__/error-utils-test.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const {
2323
throwIfModuleTypeIsUnsupported,
2424
throwIfUntypedModule,
2525
throwIfUnsupportedFunctionParamTypeAnnotationParserError,
26+
throwIfArrayElementTypeAnnotationIsUnsupported,
2627
} = require('../error-utils');
2728
const {
2829
UnsupportedModulePropertyParserError,
@@ -652,3 +653,59 @@ describe('throwIfUnsupportedFunctionParamTypeAnnotationParserError', () => {
652653
}).toThrow(UnsupportedFunctionParamTypeAnnotationParserError);
653654
});
654655
});
656+
657+
describe('throwIfArrayElementTypeAnnotationIsUnsupported', () => {
658+
const {
659+
UnsupportedArrayElementTypeAnnotationParserError,
660+
} = require('../errors.js');
661+
const moduleName = 'moduleName';
662+
const language = 'Flow';
663+
664+
it('throws the error if it is the type is void type annotation', () => {
665+
expect(() => {
666+
throwIfArrayElementTypeAnnotationIsUnsupported(
667+
moduleName,
668+
undefined,
669+
'Array',
670+
'VoidTypeAnnotation',
671+
language,
672+
);
673+
}).toThrow(UnsupportedArrayElementTypeAnnotationParserError);
674+
});
675+
676+
it('throws the error if it is the type is promise type annotation', () => {
677+
expect(() => {
678+
throwIfArrayElementTypeAnnotationIsUnsupported(
679+
moduleName,
680+
undefined,
681+
'Array',
682+
'PromiseTypeAnnotation',
683+
language,
684+
);
685+
}).toThrow(UnsupportedArrayElementTypeAnnotationParserError);
686+
});
687+
688+
it('throws the error if it is the type is function type annotation', () => {
689+
expect(() => {
690+
throwIfArrayElementTypeAnnotationIsUnsupported(
691+
moduleName,
692+
undefined,
693+
'Array',
694+
'FunctionTypeAnnotation',
695+
language,
696+
);
697+
}).toThrow(UnsupportedArrayElementTypeAnnotationParserError);
698+
});
699+
700+
it('does not throw the error if the type is NativeModuleTypeAnnotation', () => {
701+
expect(() => {
702+
throwIfArrayElementTypeAnnotationIsUnsupported(
703+
moduleName,
704+
undefined,
705+
'Array',
706+
'StringTypeAnnotation',
707+
language,
708+
);
709+
}).not.toThrow(UnsupportedArrayElementTypeAnnotationParserError);
710+
});
711+
});

0 commit comments

Comments
 (0)