From 21199d6315e2724804dff7789d104533865bc01a Mon Sep 17 00:00:00 2001 From: Ryan Waskiewicz Date: Mon, 22 May 2023 12:25:37 -0700 Subject: [PATCH] chore(snc): remove snc violations from parse-props.spec (#4402) this commit updates the test for prop parsing via `transpileModule` to account for the fact that returned fields may be `undefined` --- .../transformers/test/parse-props.spec.ts | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/compiler/transformers/test/parse-props.spec.ts b/src/compiler/transformers/test/parse-props.spec.ts index 4161eb5dc8b..4c0881c8730 100644 --- a/src/compiler/transformers/test/parse-props.spec.ts +++ b/src/compiler/transformers/test/parse-props.spec.ts @@ -28,10 +28,10 @@ describe('parse props', () => { }, }); - expect(t.property.attribute).toBe('val'); - expect(t.property.type).toBe('string'); - expect(t.property.optional).toBe(true); - expect(t.cmp.hasProp).toBe(true); + expect(t.property?.attribute).toBe('val'); + expect(t.property?.type).toBe('string'); + expect(t.property?.optional).toBe(true); + expect(t.cmp?.hasProp).toBe(true); }); it('prop required', () => { @@ -60,7 +60,7 @@ describe('parse props', () => { type: 'string', }, }); - expect(t.property.required).toBe(true); + expect(t.property?.required).toBe(true); }); it('prop mutable', () => { @@ -90,7 +90,7 @@ describe('parse props', () => { type: 'string', }, }); - expect(t.property.mutable).toBe(true); + expect(t.property?.mutable).toBe(true); }); it('prop reflectAttr', () => { @@ -119,8 +119,8 @@ describe('parse props', () => { type: 'string', }, }); - expect(t.property.reflect).toBe(true); - expect(t.cmp.hasReflect).toBe(true); + expect(t.property?.reflect).toBe(true); + expect(t.cmp?.hasReflect).toBe(true); }); it('prop array', () => { @@ -147,9 +147,9 @@ describe('parse props', () => { type: 'unknown', }, }); - expect(t.property.type).toBe('unknown'); - expect(t.property.attribute).toBe(undefined); - expect(t.property.reflect).toBe(false); + expect(t.property?.type).toBe('unknown'); + expect(t.property?.attribute).toBe(undefined); + expect(t.property?.reflect).toBe(false); }); it('prop object', () => { @@ -182,9 +182,9 @@ describe('parse props', () => { type: 'any', }, }); - expect(t.property.type).toBe('any'); - expect(t.property.attribute).toBe('val'); - expect(t.property.reflect).toBe(false); + expect(t.property?.type).toBe('any'); + expect(t.property?.attribute).toBe('val'); + expect(t.property?.reflect).toBe(false); }); it('prop multiword', () => { @@ -214,8 +214,8 @@ describe('parse props', () => { type: 'string', }, }); - expect(t.property.name).toBe('multiWord'); - expect(t.property.attribute).toBe('multi-word'); + expect(t.property?.name).toBe('multiWord'); + expect(t.property?.attribute).toBe('multi-word'); }); it('prop w/ string type', () => { @@ -244,8 +244,8 @@ describe('parse props', () => { type: 'string', }, }); - expect(t.property.type).toBe('string'); - expect(t.property.attribute).toBe('val'); + expect(t.property?.type).toBe('string'); + expect(t.property?.attribute).toBe('val'); }); it('prop w/ number type', () => { @@ -274,8 +274,8 @@ describe('parse props', () => { type: 'number', }, }); - expect(t.property.type).toBe('number'); - expect(t.property.attribute).toBe('val'); + expect(t.property?.type).toBe('number'); + expect(t.property?.attribute).toBe('val'); }); it('prop w/ boolean type', () => { @@ -304,8 +304,8 @@ describe('parse props', () => { type: 'boolean', }, }); - expect(t.property.type).toBe('boolean'); - expect(t.property.attribute).toBe('val'); + expect(t.property?.type).toBe('boolean'); + expect(t.property?.attribute).toBe('val'); }); it('prop w/ any type', () => { @@ -334,8 +334,8 @@ describe('parse props', () => { type: 'any', }, }); - expect(t.property.type).toBe('any'); - expect(t.property.attribute).toBe('val'); + expect(t.property?.type).toBe('any'); + expect(t.property?.attribute).toBe('val'); }); it('prop w/ inferred string type', () => { @@ -365,8 +365,8 @@ describe('parse props', () => { type: 'string', }, }); - expect(t.property.type).toBe('string'); - expect(t.property.attribute).toBe('val'); + expect(t.property?.type).toBe('string'); + expect(t.property?.attribute).toBe('val'); }); it('prop w/ inferred number type', () => { @@ -396,8 +396,8 @@ describe('parse props', () => { type: 'number', }, }); - expect(t.property.type).toBe('number'); - expect(t.property.attribute).toBe('val'); + expect(t.property?.type).toBe('number'); + expect(t.property?.attribute).toBe('val'); }); it('prop w/ inferred boolean type', () => { @@ -427,8 +427,8 @@ describe('parse props', () => { type: 'boolean', }, }); - expect(t.property.type).toBe('boolean'); - expect(t.property.attribute).toBe('val'); + expect(t.property?.type).toBe('boolean'); + expect(t.property?.attribute).toBe('val'); }); it('prop w/ inferred any type from null', () => { @@ -459,7 +459,7 @@ describe('parse props', () => { type: 'any', }, }); - expect(t.property.type).toBe('any'); - expect(t.property.attribute).toBe('val'); + expect(t.property?.type).toBe('any'); + expect(t.property?.attribute).toBe('val'); }); });