@@ -4,7 +4,7 @@ import { FeatureOptions } from "./featureType";
44import { getFeatureURL } from "./featureUtil" ;
55
66describe ( "getFeatureUrl" , ( ) => {
7- let mockFeatureOptions : FeatureOptions < "treatmentPlan" > ;
7+ let mockFeatureOptions : FeatureOptions < "treatmentPlan" | "platform" > ;
88 let mockFullscriptOptions : FullscriptOptions ;
99 let mockFrameId : string ;
1010 const mockDataToken = "random+data_token" ;
@@ -31,39 +31,58 @@ describe("getFeatureUrl", () => {
3131 mockFrameId = "uuid" ;
3232 } ) ;
3333
34- it ( "returns the proper url" , async ( ) => {
35- const url = await getFeatureURL (
36- "treatmentPlan" ,
37- mockFeatureOptions ,
38- mockFullscriptOptions ,
39- mockFrameId
40- ) ;
34+ 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+ ) ;
4142
42- expect ( url ) . toEqual (
43- `https://us-snd.fullscript.io/api/embeddable/session/treatment_plans/new?data_token=${ encodeURIComponent (
44- mockDataToken
45- ) } &secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
46- ) ;
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+ ) ;
48+ } ) ;
49+
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+ ) ;
57+
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+ ) ;
63+ } ) ;
4764 } ) ;
4865
49- it ( "returns proper custom url if domain is present" , async ( ) => {
50- const customDomain = "https://staging.r.fullscript.io" ;
51- mockFullscriptOptions = {
52- ...mockFullscriptOptions ,
53- domain : customDomain ,
54- } ;
66+ describe ( "custome domain" , ( ) => {
67+ it ( "returns proper custom url if domain is present" , async ( ) => {
68+ const customDomain = "https://staging.r.fullscript.io" ;
69+ mockFullscriptOptions = {
70+ ...mockFullscriptOptions ,
71+ domain : customDomain ,
72+ } ;
5573
56- const url = await getFeatureURL (
57- "treatmentPlan" ,
58- mockFeatureOptions ,
59- mockFullscriptOptions ,
60- mockFrameId
61- ) ;
74+ const url = await getFeatureURL (
75+ "treatmentPlan" ,
76+ mockFeatureOptions ,
77+ mockFullscriptOptions ,
78+ mockFrameId
79+ ) ;
6280
63- expect ( url ) . toEqual (
64- `${ customDomain } /api/embeddable/session/treatment_plans/new?data_token=${ encodeURIComponent (
65- mockDataToken
66- ) } &secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
67- ) ;
81+ expect ( url ) . toEqual (
82+ `${ customDomain } /api/embeddable/session/treatment_plans/new?data_token=${ encodeURIComponent (
83+ mockDataToken
84+ ) } &secret_token=secretToken&public_key=publicKey&frame_id=uuid&target_origin=http://localhost`
85+ ) ;
86+ } ) ;
6887 } ) ;
6988} ) ;
0 commit comments