-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update metric length limits (#46)
- Loading branch information
1 parent
2a6b0a1
commit ea870f1
Showing
5 changed files
with
525 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
Oops, something went wrong.