@@ -27,12 +27,7 @@ describe('API', () => {
2727 if ( ! errors [ 0 ] . docShort ) {
2828 return ;
2929 }
30- const locale = require ( '../lib/locale' ) ;
31- if ( locale !== 'zh_CN' ) {
32- assert . ok ( / ^ h t t p s ? : \/ \/ g o o \. g l \/ / . test ( errors [ 0 ] . docShort ) ) ;
33- } else {
34- assert . ok ( / ^ h t t p s ? : \/ \/ ( g o o \. g l | t \. c n ) \/ / . test ( errors [ 0 ] . docShort ) ) ;
35- }
30+ assert . ok ( / ^ h t t p s ? : \/ \/ ( g o o \. g l | t \. c n ) \/ / . test ( errors [ 0 ] . docShort ) ) ;
3631 } ) ;
3732 } ) ;
3833
@@ -44,28 +39,31 @@ describe('API', () => {
4439 } ) ;
4540 } ) ;
4641
47- it ( 'short-doc-url (default )' , ( ) => {
42+ it ( 'short-doc-url (in GFW )' , ( ) => {
4843 const shortDocUrl = proxyquire ( '../lib/short-doc-url' , {
49- './locale' : 'en_US' ,
44+ './locale' : 'zh_CN' ,
45+ 'in-gfw' : {
46+ os : ( ) => Promise . resolve ( true ) ,
47+ } ,
5048 } ) ;
5149 return shortDocUrl ( [ {
5250 doc : 'https://stylelint.io/user-guide/rules/indentation/' ,
5351 } ] ) . then ( errors => {
54- assert . equal ( errors [ 0 ] . docShort , 'https ://goo.gl/NVQ9aa ' ) ;
52+ assert . equal ( errors [ 0 ] . docShort , 'http ://t.cn/Ro8Mjw5 ' ) ;
5553 } ) ;
5654 } ) ;
5755
58- it ( 'short-doc-url (in GWF)' , ( ) => {
59- const getTimezoneOffset = Date . prototype . getTimezoneOffset ;
56+ it ( 'short-doc-url (out GFW)' , ( ) => {
6057 const shortDocUrl = proxyquire ( '../lib/short-doc-url' , {
61- './locale' : 'zh_CN' ,
58+ './locale' : 'en_US' ,
59+ 'in-gfw' : {
60+ os : ( ) => Promise . resolve ( false ) ,
61+ } ,
6262 } ) ;
63- Date . prototype . getTimezoneOffset = ( ) => ( - 480 ) ;
6463 return shortDocUrl ( [ {
6564 doc : 'https://stylelint.io/user-guide/rules/indentation/' ,
6665 } ] ) . then ( errors => {
67- Date . prototype . getTimezoneOffset = getTimezoneOffset ;
68- assert . equal ( errors [ 0 ] . docShort , 'http://t.cn/Ro8Mjw5' ) ;
66+ assert . equal ( errors [ 0 ] . docShort , 'https://goo.gl/NVQ9aa' ) ;
6967 } ) ;
7068 } ) ;
7169
0 commit comments