|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License; |
| 4 | + * you may not use this file except in compliance with the Elastic License. |
| 5 | + */ |
| 6 | + |
| 7 | +import { |
| 8 | + getFirstTransactionType, |
| 9 | + isJavaAgentName, |
| 10 | + isRumAgentName, |
| 11 | +} from './agent_name'; |
| 12 | + |
| 13 | +describe('agent name helpers', () => { |
| 14 | + describe('getFirstTransactionType', () => { |
| 15 | + describe('with no transaction types', () => { |
| 16 | + expect(getFirstTransactionType([])).toBeUndefined(); |
| 17 | + }); |
| 18 | + |
| 19 | + describe('with a non-rum agent', () => { |
| 20 | + it('returns "request"', () => { |
| 21 | + expect(getFirstTransactionType(['worker', 'request'], 'java')).toEqual( |
| 22 | + 'request' |
| 23 | + ); |
| 24 | + }); |
| 25 | + |
| 26 | + describe('with no request types', () => { |
| 27 | + it('returns the first type', () => { |
| 28 | + expect( |
| 29 | + getFirstTransactionType(['worker', 'shirker'], 'java') |
| 30 | + ).toEqual('worker'); |
| 31 | + }); |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | + describe('with a rum agent', () => { |
| 36 | + it('returns "page-load"', () => { |
| 37 | + expect( |
| 38 | + getFirstTransactionType(['http-request', 'page-load'], 'js-base') |
| 39 | + ).toEqual('page-load'); |
| 40 | + }); |
| 41 | + }); |
| 42 | + }); |
| 43 | + |
| 44 | + describe('isJavaAgentName', () => { |
| 45 | + describe('when the agent name is java', () => { |
| 46 | + it('returns true', () => { |
| 47 | + expect(isJavaAgentName('java')).toEqual(true); |
| 48 | + }); |
| 49 | + }); |
| 50 | + describe('when the agent name is not java', () => { |
| 51 | + it('returns true', () => { |
| 52 | + expect(isJavaAgentName('not java')).toEqual(false); |
| 53 | + }); |
| 54 | + }); |
| 55 | + }); |
| 56 | + |
| 57 | + describe('isRumAgentName', () => { |
| 58 | + describe('when the agent name is js-base', () => { |
| 59 | + it('returns true', () => { |
| 60 | + expect(isRumAgentName('js-base')).toEqual(true); |
| 61 | + }); |
| 62 | + }); |
| 63 | + |
| 64 | + describe('when the agent name is rum-js', () => { |
| 65 | + it('returns true', () => { |
| 66 | + expect(isRumAgentName('rum-js')).toEqual(true); |
| 67 | + }); |
| 68 | + }); |
| 69 | + |
| 70 | + describe('when the agent name is opentelemetry/webjs', () => { |
| 71 | + it('returns true', () => { |
| 72 | + expect(isRumAgentName('opentelemetry/webjs')).toEqual(true); |
| 73 | + }); |
| 74 | + }); |
| 75 | + |
| 76 | + describe('when the agent name something else', () => { |
| 77 | + it('returns true', () => { |
| 78 | + expect(isRumAgentName('java')).toEqual(false); |
| 79 | + }); |
| 80 | + }); |
| 81 | + }); |
| 82 | +}); |
0 commit comments