33import awsSDK from 'aws-sdk' ;
44import AwsApiParser from '../AwsApiParser' ;
55import AwsService from '../AwsService' ;
6+ import AwsConfigITC from '../types/AwsConfigITC' ;
67
78describe ( 'AwsApiParser' , ( ) => {
89 const aws = new AwsApiParser ( {
@@ -11,14 +12,20 @@ describe('AwsApiParser', () => {
1112
1213 it ( 'getServicesNames()' , ( ) => {
1314 const names = aws . getServicesNames ( ) ;
14- expect ( names ) . toContain ( 's3' ) ;
15- expect ( names ) . toContain ( 'ec2' ) ;
16- expect ( names ) . toContain ( 'route53' ) ;
17- expect ( names ) . toContain ( 'sqs' ) ;
15+ expect ( names ) . toContain ( 'S3' ) ;
16+ expect ( names ) . toContain ( 'EC2' ) ;
17+ expect ( names ) . toContain ( 'Route53' ) ;
18+ expect ( names ) . toContain ( 'SQS' ) ;
19+ } ) ;
20+
21+ it ( 'getServiceIdentifier()' , ( ) => {
22+ expect ( aws . getServiceIdentifier ( 'S3' ) ) . toBe ( 's3' ) ;
23+ // also should work if provided serviceIdentifier
24+ expect ( aws . getServiceIdentifier ( 's3' ) ) . toBe ( 's3' ) ;
1825 } ) ;
1926
2027 it ( 'getServiceConfig()' , ( ) => {
21- const cfg = aws . getServiceConfig ( 's3 ' ) ;
28+ const cfg = aws . getServiceConfig ( 'S3 ' ) ;
2229 expect ( Object . keys ( cfg ) ) . toEqual ( [
2330 'version' ,
2431 'metadata' ,
@@ -27,24 +34,37 @@ describe('AwsApiParser', () => {
2734 'paginators' ,
2835 'waiters' ,
2936 ] ) ;
37+
38+ // get config by serviceIdentifier
39+ const cfg2 = aws . getServiceConfig ( 's3' ) ;
40+ expect ( Object . keys ( cfg2 ) ) . toEqual ( [
41+ 'version' ,
42+ 'metadata' ,
43+ 'operations' ,
44+ 'shapes' ,
45+ 'paginators' ,
46+ 'waiters' ,
47+ ] ) ;
3048 } ) ;
3149
3250 it ( 'getService()' , ( ) => {
33- const service = aws . getService ( 's3 ' ) ;
51+ const service = aws . getService ( 'S3 ' ) ;
3452 expect ( service ) . toBeInstanceOf ( AwsService ) ;
53+
54+ // get service by serviceIdentifier
55+ const service2 = aws . getService ( 's3' ) ;
56+ expect ( service2 ) . toBeInstanceOf ( AwsService ) ;
3557 } ) ;
3658
3759 it ( 'getType()' , ( ) => {
3860 const type = aws . getType ( ) ;
3961 expect ( type . name ) . toBe ( 'Aws' ) ;
4062 } ) ;
41- } ) ;
4263
43- // export default class Aws {
44- // constructor(opts: AwsOpts) {
45- // getServicesNames(): string[] {
46- // getServiceConfig(name: string): ServiceConfig {
47- // getService(name: string): AwsService {
48- // getTypeComposer(): TypeComposer {
49- // getType(): GraphQLObjectType {
50- // }
64+ it ( 'getFieldConfig()' , ( ) => {
65+ const fc : any = aws . getFieldConfig ( ) ;
66+ expect ( fc . type ) . toBe ( aws . getType ( ) ) ;
67+ expect ( fc . args . config . type ) . toBe ( AwsConfigITC . getType ( ) ) ;
68+ expect ( fc . resolve ( ) ) . toEqual ( { awsConfig : { } } ) ;
69+ } ) ;
70+ } ) ;
0 commit comments