@@ -4,7 +4,7 @@ import { FeatureOptions } from "./featureType";
4
4
import { getFeatureURL } from "./featureUtil" ;
5
5
6
6
describe ( "getFeatureUrl" , ( ) => {
7
- let mockFeatureOptions : FeatureOptions < "treatmentPlan" > ;
7
+ let mockFeatureOptions : FeatureOptions < "treatmentPlan" | "platform" > ;
8
8
let mockFullscriptOptions : FullscriptOptions ;
9
9
let mockFrameId : string ;
10
10
const mockDataToken = "random+data_token" ;
@@ -31,39 +31,58 @@ describe("getFeatureUrl", () => {
31
31
mockFrameId = "uuid" ;
32
32
} ) ;
33
33
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
+ ) ;
41
42
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
+ } ) ;
47
64
} ) ;
48
65
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
+ } ;
55
73
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
+ ) ;
62
80
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
+ } ) ;
68
87
} ) ;
69
88
} ) ;
0 commit comments