@@ -16,6 +16,7 @@ describe('ContentFeature class', () => {
1616 const args = {
1717 site : {
1818 domain : 'beep.example.com' ,
19+ url : 'http://beep.example.com' ,
1920 } ,
2021 featureSettings : {
2122 test : {
@@ -48,6 +49,101 @@ describe('ContentFeature class', () => {
4849 expect ( didRun ) . withContext ( 'Should run' ) . toBeTrue ( ) ;
4950 } ) ;
5051
52+ it ( 'Should trigger getFeatureSettingEnabled for the correct domain' , ( ) => {
53+ let didRun = false ;
54+ class MyTestFeature2 extends ContentFeature {
55+ init ( ) {
56+ expect ( this . getFeatureSetting ( 'test' ) ) . toBe ( 'enabled3' ) ;
57+ expect ( this . getFeatureSetting ( 'otherTest' ) ) . toBe ( 'enabled' ) ;
58+ expect ( this . getFeatureSetting ( 'otherOtherTest' ) ) . toBe ( 'ding' ) ;
59+ expect ( this . getFeatureSetting ( 'arrayTest' ) ) . toBe ( 'enabledArray' ) ;
60+ expect ( this . getFeatureSetting ( 'pathTest' ) ) . toBe ( 'beep' ) ;
61+ expect ( this . getFeatureSetting ( 'pathTestNotApply' ) ) . toBe ( 'nope' ) ;
62+ expect ( this . getFeatureSetting ( 'pathTestShort' ) ) . toBe ( 'beep' ) ;
63+ expect ( this . getFeatureSetting ( 'pathTestAsterix' ) ) . toBe ( 'comic' ) ;
64+ expect ( this . getFeatureSetting ( 'pathTestPlaceholder' ) ) . toBe ( 'place' ) ;
65+ expect ( this . getFeatureSetting ( 'domainWildcard' ) ) . toBe ( 'wildwest' ) ;
66+ expect ( this . getFeatureSetting ( 'domainWildcardNope' ) ) . toBe ( 'nope' ) ;
67+ didRun = true ;
68+ }
69+ }
70+
71+ const args = {
72+ site : {
73+ domain : 'beep.example.com' ,
74+ url : 'http://beep.example.com/path/path/me' ,
75+ } ,
76+ featureSettings : {
77+ test : {
78+ test : 'enabled' ,
79+ otherTest : 'disabled' ,
80+ otherOtherTest : 'ding' ,
81+ arrayTest : 'enabled' ,
82+ pathTest : 'nope' ,
83+ pathTestNotApply : 'nope' ,
84+ pathTestShort : 'nope' ,
85+ pathTestAsterix : 'nope' ,
86+ pathTestPlaceholder : 'nope' ,
87+ domainWildcard : 'nope' ,
88+ domainWildcardNope : 'nope' ,
89+ conditionalChanges : [
90+ {
91+ domain : 'example.com' ,
92+ patchSettings : [
93+ { op : 'replace' , path : '/test' , value : 'enabled2' } ,
94+ { op : 'replace' , path : '/otherTest' , value : 'enabled' } ,
95+ ] ,
96+ } ,
97+ {
98+ domain : 'beep.example.com' ,
99+ patchSettings : [ { op : 'replace' , path : '/test' , value : 'enabled3' } ] ,
100+ } ,
101+ {
102+ domain : [ 'meep.com' , 'example.com' ] ,
103+ patchSettings : [ { op : 'replace' , path : '/arrayTest' , value : 'enabledArray' } ] ,
104+ } ,
105+ {
106+ urlPattern : {
107+ path : '/path/path/me' ,
108+ } ,
109+ patchSettings : [ { op : 'replace' , path : '/pathTest' , value : 'beep' } ] ,
110+ } ,
111+ {
112+ urlPattern : {
113+ hostname : 'beep.nope.com' ,
114+ path : '/path/path/me' ,
115+ } ,
116+ patchSettings : [ { op : 'replace' , path : '/pathTestNotApply' , value : 'yep' } ] ,
117+ } ,
118+ {
119+ urlPattern : 'http://beep.example.com/path/path/me' ,
120+ patchSettings : [ { op : 'replace' , path : '/pathTestShort' , value : 'beep' } ] ,
121+ } ,
122+ {
123+ urlPattern : 'http://beep.example.com/*/path/me' ,
124+ patchSettings : [ { op : 'replace' , path : '/pathTestAsterix' , value : 'comic' } ] ,
125+ } ,
126+ {
127+ urlPattern : 'http://beep.example.com/:something/path/me' ,
128+ patchSettings : [ { op : 'replace' , path : '/pathTestPlaceholder' , value : 'place' } ] ,
129+ } ,
130+ {
131+ urlPattern : 'http://beep.*.com/*/path/me' ,
132+ patchSettings : [ { op : 'replace' , path : '/domainWildcard' , value : 'wildwest' } ] ,
133+ } ,
134+ {
135+ urlPattern : 'http://nope.*.com/*/path/me' ,
136+ patchSettings : [ { op : 'replace' , path : '/domainWildcardNope' , value : 'wildwest' } ] ,
137+ } ,
138+ ] ,
139+ } ,
140+ } ,
141+ } ;
142+ const me = new MyTestFeature2 ( 'test' , { } , args ) ;
143+ me . callInit ( args ) ;
144+ expect ( didRun ) . withContext ( 'Should run' ) . toBeTrue ( ) ;
145+ } ) ;
146+
51147 describe ( 'addDebugFlag' , ( ) => {
52148 class MyTestFeature extends ContentFeature {
53149 // eslint-disable-next-line
0 commit comments