@@ -36,6 +36,35 @@ afterEach(() => {
3636} ) ;
3737
3838// ─── Exports ─────────────────────────────────────────────────────────────────
39+ // ─── buildRequestBody ─────────────────────────────────────────────────────────
40+
41+ describe ( 'buildRequestBody' , ( ) => {
42+ it ( 'produces { url } for page scope with no form factor' , ( ) => {
43+ const body = buildRequestBody ( 'https://example.com' , 'page' ) ;
44+ expect ( body ) . toEqual ( { url : 'https://example.com' } ) ;
45+ } ) ;
46+
47+ it ( 'produces { origin } for origin scope with no form factor' , ( ) => {
48+ const body = buildRequestBody ( 'https://example.com/path' , 'origin' ) ;
49+ expect ( body ) . toEqual ( { origin : 'https://example.com' } ) ;
50+ } ) ;
51+
52+ it ( 'adds formFactor in uppercase when provided' , ( ) => {
53+ const phone = buildRequestBody ( 'https://example.com' , 'page' , 'phone' ) ;
54+ expect ( phone . formFactor ) . toBe ( 'PHONE' ) ;
55+
56+ const desktop = buildRequestBody ( 'https://example.com' , 'page' , 'desktop' ) ;
57+ expect ( desktop . formFactor ) . toBe ( 'DESKTOP' ) ;
58+
59+ const tablet = buildRequestBody ( 'https://example.com' , 'page' , 'tablet' ) ;
60+ expect ( tablet . formFactor ) . toBe ( 'TABLET' ) ;
61+ } ) ;
62+
63+ it ( 'omits formFactor from body when not provided' , ( ) => {
64+ const body = buildRequestBody ( 'https://example.com' , 'page' ) ;
65+ expect ( Object . prototype . hasOwnProperty . call ( body , 'formFactor' ) ) . toBe ( false ) ;
66+ } ) ;
67+ } ) ;
3968
4069describe ( 'exports' , ( ) => {
4170 it ( 'buildRequestBody is exported' , ( ) => expect ( typeof buildRequestBody ) . toBe ( 'function' ) ) ;
0 commit comments