Example #1
0
 it('creates a new request based on the current request replacing the custom "auth"', () => {
   const authData1 = { username: 'bob', password: 'bob' }
   const authData2 = { username: 'bob', password: 'bill' }
   const request = new Request(methodDescriptor, { snowflake: authData1 })
   const enhancedRequest = request.enhance({ auth: authData2 })
   expect(enhancedRequest).not.toEqual(request)
   expect(enhancedRequest.auth()).toEqual(authData2)
 })
Example #2
0
 it('creates a new request based on the current request replacing the custom "timeout"', () => {
   const request = new Request(methodDescriptor, { snowflake: 1000 })
   const enhancedRequest = request.enhance({ timeout: 2000 })
   expect(enhancedRequest).not.toEqual(request)
   expect(enhancedRequest.timeout()).toEqual(2000)
 })
Example #3
0
 it('creates a new request based on the current request replacing the custom "body"', () => {
   const request = new Request(methodDescriptor, { snowflake: 'payload-1' })
   const enhancedRequest = request.enhance({ body: 'payload-2' })
   expect(enhancedRequest).not.toEqual(request)
   expect(enhancedRequest.body()).toEqual('payload-2')
 })
Example #4
0
 it('creates a new request based on the current request merging the custom "headers" key', () => {
   const request = new Request(methodDescriptor, { snowflake: { 'x-old': 'no' } })
   const enhancedRequest = request.enhance({ headers: { 'x-special': 'yes' } })
   expect(enhancedRequest).not.toEqual(request)
   expect(enhancedRequest.headers()).toEqual({ 'x-old': 'no', 'x-special': 'yes' })
 })
Example #5
0
 it('does not remove the previously assigned "timeout"', () => {
   const request = new Request(methodDescriptor, { timeout: 1000 })
   const enhancedRequest = request.enhance({})
   expect(enhancedRequest.timeout()).toEqual(1000)
 })
Example #6
0
 it('does not remove the previously assigned "auth"', () => {
   const request = new Request(methodDescriptor, { auth: { username: 'a', password: 'b' } })
   const enhancedRequest = request.enhance({})
   expect(enhancedRequest.auth()).toEqual({ username: 'a', password: 'b' })
 })
Example #7
0
 it('does not remove the previously assigned "body"', () => {
   const request = new Request(methodDescriptor, { body: 'test' })
   const enhancedRequest = request.enhance({})
   expect(enhancedRequest.body()).toEqual('test')
 })
Example #8
0
 it('creates a new request based on the current request merging the params', () => {
   const request = new Request(methodDescriptor, { a: 1 })
   const enhancedRequest = request.enhance({ params: { b: 2 } })
   expect(enhancedRequest).not.toEqual(request)
   expect(enhancedRequest.params()).toEqual({ a: 1, b: 2 })
 })