11const { Cdn } = require ( '../src' ) ;
2+ const { getCdnByDomain } = require ( '../src/modules/cdn/utils' ) ;
23
34describe ( 'Cdn' , ( ) => {
5+ jest . setTimeout ( 600000 ) ;
46 const credentials = {
57 SecretId : process . env . TENCENT_SECRET_ID ,
68 SecretKey : process . env . TENCENT_SECRET_KEY ,
79 } ;
810 const inputs = {
9- async : true ,
11+ async : false ,
1012 area : 'overseas' ,
1113 domain : 'test.yuga.chat' ,
12- hostType : 'cos' ,
1314 origin : {
1415 origins : [ 'up6pwd9-89hm718-xxx.cos-website.ap-guangzhou.myqcloud.com' ] ,
1516 originType : 'cos' ,
@@ -31,10 +32,9 @@ describe('Cdn', () => {
3132 } ;
3233 const cdn = new Cdn ( credentials , process . env . REGION ) ;
3334
34- test ( 'should deploy CDN success' , async ( ) => {
35+ test ( 'should deploy CDN success with originType = cos ' , async ( ) => {
3536 const res = await cdn . deploy ( inputs ) ;
3637 expect ( res ) . toEqual ( {
37- created : true ,
3838 https : true ,
3939 domain : inputs . domain ,
4040 origins : inputs . origin . origins ,
@@ -43,5 +43,26 @@ describe('Cdn', () => {
4343 resourceId : expect . stringContaining ( 'cdn-' ) ,
4444 } ) ;
4545 } ) ;
46+
47+
48+ test ( 'should deploy CDN success with originType = domain' , async ( ) => {
49+ inputs . origin . originType = 'domain' ;
50+ const res = await cdn . deploy ( inputs ) ;
51+ expect ( res ) . toEqual ( {
52+ https : true ,
53+ domain : inputs . domain ,
54+ origins : inputs . origin . origins ,
55+ cname : `${ inputs . domain } .cdn.dnsv1.com` ,
56+ inputCache : JSON . stringify ( inputs ) ,
57+ resourceId : expect . stringContaining ( 'cdn-' ) ,
58+ } ) ;
59+ } ) ;
60+
61+ test ( 'should remove CDN success' , async ( ) => {
62+ const res = await cdn . remove ( inputs ) ;
63+ expect ( res ) . toEqual ( { } ) ;
64+ const detail = await getCdnByDomain ( cdn . capi , inputs . domain ) ;
65+ expect ( detail ) . toBeUndefined ( ) ;
66+ } ) ;
4667} ) ;
4768
0 commit comments