frame.spec.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {Frame} from 'sentry/utils/profiling/frame';
  2. describe('Frame', () => {
  3. describe('web', () => {
  4. it('sets anonymouse name if frame has no name', () => {
  5. expect(new Frame({key: 0, name: '', line: 0, column: 0}, 'web').name).toBe(
  6. '<anonymous>'
  7. );
  8. });
  9. it('appends [native code] to name if frame belongs to native code', () => {
  10. expect(
  11. new Frame(
  12. {key: 0, name: 'foo', line: undefined, column: undefined},
  13. 'web'
  14. ).name.endsWith('[native code]')
  15. ).toBe(true);
  16. });
  17. });
  18. describe('pulls package from path for web|node platforms', () => {
  19. it('file in node modules', () => {
  20. expect(
  21. new Frame(
  22. {
  23. key: 0,
  24. name: 'Foo',
  25. path: '/usr/code/node_modules/file.js',
  26. line: undefined,
  27. column: undefined,
  28. },
  29. 'node'
  30. ).image
  31. ).toBe(undefined);
  32. });
  33. it.each([
  34. ['/usr/code/node_modules/@sentry/profiling-node/file.js', '@sentry/profiling-node'],
  35. ['/usr/code/node_modules/sentry/profiling-node/file.js', 'sentry'],
  36. ['/usr/code/node_modules/sentry/file.js', 'sentry'],
  37. [
  38. 'C:\\Program Files (x86)\\node_modules\\@sentry\\profiling-node\\file.js',
  39. '@sentry/profiling-node',
  40. ],
  41. [
  42. 'C:\\Program Files (x86)\\node_modules\\sentry\\profiling-node\\file.js',
  43. 'sentry',
  44. ],
  45. ['C:\\Program Files (x86)\\node_modules\\sentry\\file.js', 'sentry'],
  46. ])('%s -> %s', (path, expected) => {
  47. expect(
  48. new Frame(
  49. {
  50. key: 0,
  51. name: 'Foo',
  52. path,
  53. line: undefined,
  54. column: undefined,
  55. },
  56. 'node'
  57. ).image
  58. ).toBe(expected);
  59. });
  60. });
  61. });