Skip to content

Commit b80798f

Browse files
committed
feat(metrics): remove learning concept as const
1 parent 7a25f2f commit b80798f

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

packages/metrics/tests/unit/Metrics.test.ts

-40
Original file line numberDiff line numberDiff line change
@@ -798,44 +798,4 @@ describe('Class: Metrics', () => {
798798
expect(loggedData._aws.CloudWatchMetrics[0].Namespace).toEqual(namespace);
799799
});
800800
});
801-
802-
describe('concept', ()=>{
803-
test('metric DX type with const', ()=>{
804-
const MetricResolutionConcept = {
805-
Standard: 60,
806-
High: 1
807-
} as const;
808-
type MetricResolutionConcept = typeof MetricResolutionConcept[keyof typeof MetricResolutionConcept];
809-
810-
const use = (resolution: MetricResolutionConcept):void => {
811-
if (resolution === MetricResolutionConcept.Standard) expect(resolution).toBe(MetricResolution.Standard);
812-
if (resolution === MetricResolution.High) expect(resolution).toBe(MetricResolutionConcept.High);
813-
};
814-
815-
// prefered design of Metric Resolution, strcutural typing, compile time guidance
816-
use(MetricResolution.Standard);
817-
use(60);
818-
use(1);
819-
// use(10); // Argument of type '10' is not assignable to parameter of type 'MetricResolutionConcept'.ts(2345)
820-
//use(80); // Argument of type '10' is not assignable to parameter of type 'MetricResolutionConcept'.ts(2345)
821-
});
822-
823-
test('metric DX type with enum', ()=>{
824-
enum MetricResolutionEnum {
825-
Standard = 60,
826-
High = 1
827-
}
828-
829-
const use = (resolution: MetricResolutionEnum):void => {
830-
if (resolution === MetricResolutionEnum.Standard) expect(resolution).toBe(MetricResolution.Standard);
831-
if (resolution === MetricResolutionEnum.High) expect(resolution).toBe(MetricResolutionEnum.High);
832-
};
833-
use(MetricResolution.Standard);
834-
835-
// enum design, allows the following usage at compile time
836-
use(10); // Argument of type '10' is assignable to parameter of type 'MetricResolutionEnum'
837-
use(80); // Argument of type '10' is assignable to parameter of type 'MetricResolutionEnum'
838-
});
839-
840-
});
841801
});

0 commit comments

Comments
 (0)