import { MockRouter , mockRequestHandler , mockDependencies } from '../../__mocks__' ; import { registerOrgSettingsRoute , registerOrgSettingsCustomizeRoute , registerOrgSettingsUploadImagesRoute , registerOrgSettingsOauthApplicationRoute , } from './settings' ; describe ( 'settings routes' , ( ) => { describe ( 'GET /internal/workplace_search/org/settings' , ( ) => { let mockRouter ; beforeEach ( ( ) => { jest . clearAllMocks ( ) ; mockRouter = new MockRouter ( { method : 'get' , path : '/internal/workplace_search/org/settings' , } ) ; registerOrgSettingsRoute ( { ... mockDependencies , router : mockRouter . router , } ) ; } ) ; it ( 'creates a request handler' , ( ) => { expect ( mockRequestHandler . createRequest ) . toHaveBeenCalledWith ( { path : '/ws/org/settings' , } ) ; } ) ; } ) ; describe ( 'PUT /internal/workplace_search/org/settings/customize' , ( ) => { let mockRouter ; beforeEach ( ( ) => { jest . clearAllMocks ( ) ; mockRouter = new MockRouter ( { method : 'put' , path : '/internal/workplace_search/org/settings/customize' , } ) ; registerOrgSettingsCustomizeRoute ( { ... mockDependencies , router : mockRouter . router , } ) ; } ) ; it ( 'creates a request handler' , ( ) => { expect ( mockRequestHandler . createRequest ) . toHaveBeenCalledWith ( { path : '/ws/org/settings/customize' , } ) ; } ) ; describe ( 'validates' , ( ) => { it ( 'correctly' , ( ) => { const request = { body : { name : 'foo' } } ; mockRouter . shouldValidate ( request ) ; } ) ; } ) ; } ) ; describe ( 'PUT /internal/workplace_search/org/settings/upload_images' , ( ) => { let mockRouter ; beforeEach ( ( ) => { jest . clearAllMocks ( ) ; mockRouter = new MockRouter ( { method : 'put' , path : '/internal/workplace_search/org/settings/upload_images' , } ) ; registerOrgSettingsUploadImagesRoute ( { ... mockDependencies , router : mockRouter . router , } ) ; } ) ; it ( 'creates a request handler' , ( ) => { expect ( mockRequestHandler . createRequest ) . toHaveBeenCalledWith ( { path : '/ws/org/settings/upload_images' , } ) ; } ) ; describe ( 'validates' , ( ) => { it ( 'correctly' , ( ) => { const request = { body : { logo : 'foo' , icon : null } } ; mockRouter . shouldValidate ( request ) ; } ) ; } ) ; } ) ; describe ( 'PUT /internal/workplace_search/org/settings/oauth_application' , ( ) => { let mockRouter ; beforeEach ( ( ) => { jest . clearAllMocks ( ) ; mockRouter = new MockRouter ( { method : 'put' , path : '/internal/workplace_search/org/settings/oauth_application' , } ) ; registerOrgSettingsOauthApplicationRoute ( { ... mockDependencies , router : mockRouter . router , } ) ; } ) ; it ( 'creates a request handler' , ( ) => { expect ( mockRequestHandler . createRequest ) . toHaveBeenCalledWith ( { path : '/ws/org/settings/oauth_application' , } ) ; } ) ; describe ( 'validates' , ( ) => { it ( 'correctly' , ( ) => { const request = { body : { oauth_application : { name : 'foo' , confidential : true , redirect_uri : 'http://foo.bar' , } , } , } ; mockRouter . shouldValidate ( request ) ; } ) ; } ) ; } ) ; } ) ;