Skip to content

Commit

Permalink
chore: Update metric length limits (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
just-boris authored Jan 31, 2024
1 parent 2a6b0a1 commit ea870f1
Show file tree
Hide file tree
Showing 5 changed files with 525 additions and 48 deletions.
36 changes: 36 additions & 0 deletions src/internal/base-component/__tests__/metrics-init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { Metrics } from '../metrics/metrics';

declare global {
interface Window {
AWSC?: any;
}
}

const metrics = new Metrics('components', '3.0 (HEAD)');

// This test file is separate from metrics.test.ts because we want to test an uninitialized Metrics module
describe('Metrics.initMetrics', () => {
beforeEach(() => {
window.AWSC = {
Clog: {
log: () => {},
},
};
jest.spyOn(window.AWSC.Clog, 'log');
});

test('is required before sending metrics', () => {
const consoleSpy = jest.spyOn(console, 'error');

metrics.sendMetric('name', 0);
expect(window.AWSC.Clog.log).toHaveBeenCalledTimes(0);
expect(consoleSpy).toHaveBeenCalled();

metrics.initMetrics('default');
metrics.sendMetric('name', 0);
expect(window.AWSC.Clog.log).toHaveBeenCalledTimes(1);
});
});
Loading

0 comments on commit ea870f1

Please sign in to comment.