@@ -32,34 +32,102 @@ describe("getFeatureUrl", () => {
3232 } ) ;
3333
3434 describe ( "feature type" , ( ) => {
35- it ( "returns the proper url when the feature type is 'treatmentPlan'" , async ( ) => {
36- const url = await getFeatureURL (
37- "treatmentPlan" ,
38- mockFeatureOptions ,
39- mockFullscriptOptions ,
40- mockFrameId
41- ) ;
35+ describe ( "the feature type is 'treatmentPlan'" , ( ) => {
36+ it ( "returns the proper url" , async ( ) => {
37+ const url = await getFeatureURL (
38+ "treatmentPlan" ,
39+ mockFeatureOptions ,
40+ mockFullscriptOptions ,
41+ mockFrameId
42+ ) ;
4243
43- expect ( url ) . toEqual (
44- `https://us-snd.fullscript.io/api/embeddable/session/treatment_plans/new?data_token=${ encodeURIComponent (
45- mockDataToken
46- ) } &secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
47- ) ;
44+ expect ( url ) . toEqual (
45+ `https://us-snd.fullscript.io/api/embeddable/session/treatment_plans/new?data_token=${ encodeURIComponent (
46+ mockDataToken
47+ ) } &secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
48+ ) ;
49+ } ) ;
50+
51+ it ( "doesn't add entrypoint to the url when entrypoint is given" , async ( ) => {
52+ const url = await getFeatureURL (
53+ "treatmentPlan" ,
54+ // @ts -expect-error
55+ { ...mockFeatureOptions , entrypoint : "labs" } ,
56+ mockFullscriptOptions ,
57+ mockFrameId
58+ ) ;
59+
60+ expect ( url ) . toEqual (
61+ `https://us-snd.fullscript.io/api/embeddable/session/treatment_plans/new?data_token=${ encodeURIComponent (
62+ mockDataToken
63+ ) } &secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
64+ ) ;
65+ } ) ;
4866 } ) ;
4967
50- it ( "returns the proper url when the feature type is 'platform'" , async ( ) => {
51- const url = await getFeatureURL (
52- "platform" ,
53- mockFeatureOptions ,
54- mockFullscriptOptions ,
55- mockFrameId
56- ) ;
68+ describe ( "the feature type is 'platform'" , ( ) => {
69+ it ( "returns the proper url" , async ( ) => {
70+ const url = await getFeatureURL (
71+ "platform" ,
72+ mockFeatureOptions ,
73+ mockFullscriptOptions ,
74+ mockFrameId
75+ ) ;
5776
58- expect ( url ) . toEqual (
59- `https://us-snd.fullscript.io/api/embeddable/session/embed/entry?data_token=${ encodeURIComponent (
60- mockDataToken
61- ) } &secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
62- ) ;
77+ expect ( url ) . toEqual (
78+ `https://us-snd.fullscript.io/api/embeddable/session/embed/entry?data_token=${ encodeURIComponent (
79+ mockDataToken
80+ ) } &secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
81+ ) ;
82+ } ) ;
83+
84+ describe ( "entrypoint" , ( ) => {
85+ it ( "adds labs entrypoint to the url when it is given" , async ( ) => {
86+ const url = await getFeatureURL (
87+ "platform" ,
88+ { ...mockFeatureOptions , entrypoint : "labs" } ,
89+ mockFullscriptOptions ,
90+ mockFrameId
91+ ) ;
92+
93+ expect ( url ) . toEqual (
94+ `https://us-snd.fullscript.io/api/embeddable/session/embed/entry?data_token=${ encodeURIComponent (
95+ mockDataToken
96+ ) } &secret_token=secretToken&entrypoint=labs&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
97+ ) ;
98+ } ) ;
99+
100+ it ( "adds catalog entrypoint to the url when it is given" , async ( ) => {
101+ const url = await getFeatureURL (
102+ "platform" ,
103+ { ...mockFeatureOptions , entrypoint : "catalog" } ,
104+ mockFullscriptOptions ,
105+ mockFrameId
106+ ) ;
107+
108+ expect ( url ) . toEqual (
109+ `https://us-snd.fullscript.io/api/embeddable/session/embed/entry?data_token=${ encodeURIComponent (
110+ mockDataToken
111+ ) } &secret_token=secretToken&entrypoint=catalog&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
112+ ) ;
113+ } ) ;
114+
115+ it ( "doesn't add entrypoint to the url when an invalid entrypoint is given" , async ( ) => {
116+ const url = await getFeatureURL (
117+ "platform" ,
118+ // @ts -expect-error
119+ { ...mockFeatureOptions , entrypoint : "invalid" } ,
120+ mockFullscriptOptions ,
121+ mockFrameId
122+ ) ;
123+
124+ expect ( url ) . toEqual (
125+ `https://us-snd.fullscript.io/api/embeddable/session/embed/entry?data_token=${ encodeURIComponent (
126+ mockDataToken
127+ ) } &secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
128+ ) ;
129+ } ) ;
130+ } ) ;
63131 } ) ;
64132 } ) ;
65133
0 commit comments