@@ -6,6 +6,7 @@ import { ModelDataStore, GenericData } from '../../lib/model-data';
66import {
77 OAuthNativeClients ,
88 OAuthNativeIntegration ,
9+ OAuthNativeServices ,
910} from './oauth-native-integration' ;
1011import { OAuthWebIntegration } from './oauth-web-integration' ;
1112
@@ -27,7 +28,7 @@ describe('OAuthNativeIntegration', function () {
2728 beforeEach ( function ( ) {
2829 data = new GenericData ( {
2930 clientId : OAuthNativeClients . FirefoxIOS ,
30- service : 'sync' ,
31+ service : OAuthNativeServices . Sync ,
3132 } ) ;
3233 oauthData = new GenericData ( {
3334 scope : 'profile' ,
@@ -38,7 +39,7 @@ describe('OAuthNativeIntegration', function () {
3839 isPromptNoneEnabled : true ,
3940 isPromptNoneEnabledClientIds : [ ] ,
4041 } ) ;
41- model . data . service = 'sync' ;
42+ model . data . service = OAuthNativeServices . Sync ;
4243 model . data . state = 'aaaa' ;
4344 model . data . clientId = '123abc' ;
4445 } ) ;
@@ -51,7 +52,7 @@ describe('OAuthNativeIntegration', function () {
5152 describe ( 'isSync' , ( ) => {
5253 it ( 'returns true for Firefox desktop client when service is sync' , ( ) => {
5354 model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
54- model . data . service = 'sync' ;
55+ model . data . service = OAuthNativeServices . Sync ;
5556 expect ( model . isSync ( ) ) . toBe ( true ) ;
5657 } ) ;
5758
@@ -77,21 +78,21 @@ describe('OAuthNativeIntegration', function () {
7778
7879 it ( 'returns false for non-Sync services' , ( ) => {
7980 model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
80- model . data . service = 'relay' ;
81+ model . data . service = OAuthNativeServices . Relay ;
8182 expect ( model . isSync ( ) ) . toBe ( false ) ;
8283 } ) ;
8384 } ) ;
8485
8586 describe ( 'isDesktopSync' , ( ) => {
8687 it ( 'returns true when client is Firefox desktop and service is sync' , ( ) => {
8788 model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
88- model . data . service = 'sync' ;
89+ model . data . service = OAuthNativeServices . Sync ;
8990 expect ( model . isDesktopSync ( ) ) . toBe ( true ) ;
9091 } ) ;
9192
9293 it ( 'returns false for non-sync service' , ( ) => {
9394 model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
94- model . data . service = 'relay' ;
95+ model . data . service = OAuthNativeServices . Relay ;
9596 expect ( model . isDesktopSync ( ) ) . toBe ( false ) ;
9697 } ) ;
9798 } ) ;
@@ -135,15 +136,96 @@ describe('OAuthNativeIntegration', function () {
135136 } ) ;
136137 } ) ;
137138
138- describe ( 'serviceName ' , ( ) => {
139+ describe ( 'getServiceName ' , ( ) => {
139140 it ( 'returns "Firefox" for non-sync services' , ( ) => {
140141 model . data . service = 'non-sync-service' ;
141- expect ( model . serviceName ) . toBe ( 'Firefox' ) ;
142+ expect ( model . getServiceName ( ) ) . toBe ( 'Firefox' ) ;
142143 } ) ;
143144
144145 it ( 'returns Sync service name for sync service' , ( ) => {
145- model . data . service = 'sync' ;
146- expect ( model . serviceName ) . toBe ( 'Firefox Sync' ) ;
146+ model . data . service = OAuthNativeServices . Sync ;
147+ expect ( model . getServiceName ( ) ) . toBe ( 'Firefox Sync' ) ;
148+ } ) ;
149+
150+ it ( 'returns Relay service name for relay service' , ( ) => {
151+ model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
152+ model . data . service = OAuthNativeServices . Relay ;
153+ expect ( model . getServiceName ( ) ) . toBe ( 'Firefox Relay' ) ;
154+ } ) ;
155+
156+ it ( 'returns AI Mode service name for aimode service' , ( ) => {
157+ model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
158+ model . data . service = OAuthNativeServices . AiMode ;
159+ expect ( model . getServiceName ( ) ) . toBe ( 'Firefox AI Mode' ) ;
160+ } ) ;
161+ } ) ;
162+
163+ describe ( 'isFirefoxClientServiceRelay' , ( ) => {
164+ it ( 'returns true when service is relay' , ( ) => {
165+ model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
166+ model . data . service = OAuthNativeServices . Relay ;
167+ expect ( model . isFirefoxClientServiceRelay ( ) ) . toBe ( true ) ;
168+ } ) ;
169+
170+ it ( 'returns false when service is sync' , ( ) => {
171+ model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
172+ model . data . service = OAuthNativeServices . Sync ;
173+ expect ( model . isFirefoxClientServiceRelay ( ) ) . toBe ( false ) ;
174+ } ) ;
175+
176+ it ( 'returns false when service is aimode' , ( ) => {
177+ model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
178+ model . data . service = OAuthNativeServices . AiMode ;
179+ expect ( model . isFirefoxClientServiceRelay ( ) ) . toBe ( false ) ;
180+ } ) ;
181+ } ) ;
182+
183+ describe ( 'isFirefoxClientServiceAiMode' , ( ) => {
184+ it ( 'returns true when service is aimode' , ( ) => {
185+ model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
186+ model . data . service = OAuthNativeServices . AiMode ;
187+ expect ( model . isFirefoxClientServiceAiMode ( ) ) . toBe ( true ) ;
188+ } ) ;
189+
190+ it ( 'returns false when service is sync' , ( ) => {
191+ model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
192+ model . data . service = OAuthNativeServices . Sync ;
193+ expect ( model . isFirefoxClientServiceAiMode ( ) ) . toBe ( false ) ;
194+ } ) ;
195+
196+ it ( 'returns false when service is relay' , ( ) => {
197+ model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
198+ model . data . service = OAuthNativeServices . Relay ;
199+ expect ( model . isFirefoxClientServiceAiMode ( ) ) . toBe ( false ) ;
200+ } ) ;
201+ } ) ;
202+
203+ describe ( 'getWebChannelServices' , ( ) => {
204+ it ( 'returns relay services when service is relay' , ( ) => {
205+ model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
206+ model . data . service = OAuthNativeServices . Relay ;
207+ expect ( model . getWebChannelServices ( ) ) . toEqual ( { relay : { } } ) ;
208+ } ) ;
209+
210+ it ( 'returns aimode services when service is aimode' , ( ) => {
211+ model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
212+ model . data . service = OAuthNativeServices . AiMode ;
213+ expect ( model . getWebChannelServices ( ) ) . toEqual ( { aimode : { } } ) ;
214+ } ) ;
215+
216+ it ( 'returns sync services when service is sync' , ( ) => {
217+ model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
218+ model . data . service = OAuthNativeServices . Sync ;
219+ const syncEngines = { offeredEngines : [ 'tabs' ] , declinedEngines : [ ] } ;
220+ expect ( model . getWebChannelServices ( syncEngines ) ) . toEqual ( {
221+ sync : syncEngines ,
222+ } ) ;
223+ } ) ;
224+
225+ it ( 'returns sync services with empty object when no sync engines provided' , ( ) => {
226+ model . clientInfo = mockClientInfo ( OAuthNativeClients . FirefoxDesktop ) ;
227+ model . data . service = OAuthNativeServices . Sync ;
228+ expect ( model . getWebChannelServices ( ) ) . toEqual ( { sync : { } } ) ;
147229 } ) ;
148230 } ) ;
149231} ) ;
0 commit comments