-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
c0bb616
commit a3a9289
Showing
3 changed files
with
151 additions
and
0 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,68 @@ | ||
/** | ||
* @file Type Tests - Property | ||
* @module esast/nodes/tests/unit-d/Property | ||
*/ | ||
|
||
import type { | ||
Data, | ||
Expression, | ||
Identifier, | ||
Parent, | ||
Pattern, | ||
PropertyKind | ||
} from '@flex-development/esast' | ||
import type { Nilable, Optional } from '@flex-development/tutils' | ||
import type * as TestSubject from '../property' | ||
|
||
describe('unit-d:nodes/Property', () => { | ||
type Subject = TestSubject.default | ||
type SubjectData = TestSubject.PropertyData | ||
|
||
it('should extend Parent', () => { | ||
expectTypeOf<Subject>().toMatchTypeOf<Parent>() | ||
}) | ||
|
||
it('should match [children: [Expression | Identifier, Expression | Pattern]]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('children') | ||
.toEqualTypeOf<[Expression | Identifier, Expression | Pattern]>() | ||
}) | ||
|
||
it('should match [computed: boolean]', () => { | ||
expectTypeOf<Subject>().toHaveProperty('computed').toEqualTypeOf<boolean>() | ||
}) | ||
|
||
it('should match [data?: Optional<PropertyData>]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('data') | ||
.toEqualTypeOf<Optional<SubjectData>>() | ||
}) | ||
|
||
it('should match [kind: PropertyKind]', () => { | ||
expectTypeOf<Subject>().toHaveProperty('kind').toEqualTypeOf<PropertyKind>() | ||
}) | ||
|
||
it('should match [method: boolean]', () => { | ||
expectTypeOf<Subject>().toHaveProperty('method').toEqualTypeOf<boolean>() | ||
}) | ||
|
||
it('should match [shorthand: boolean]', () => { | ||
expectTypeOf<Subject>().toHaveProperty('shorthand').toEqualTypeOf<boolean>() | ||
}) | ||
|
||
it('should match [type: "property"]', () => { | ||
expectTypeOf<Subject>().toHaveProperty('type').toEqualTypeOf<'property'>() | ||
}) | ||
|
||
describe('PropertyData', () => { | ||
it('should extend Data', () => { | ||
expectTypeOf<SubjectData>().toMatchTypeOf<Data>() | ||
}) | ||
|
||
it('should match [assignment?: Nilable<boolean>]', () => { | ||
expectTypeOf<SubjectData>() | ||
.toHaveProperty('assignment') | ||
.toEqualTypeOf<Nilable<boolean>>() | ||
}) | ||
}) | ||
}) |
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
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,82 @@ | ||
/** | ||
* @file Nodes - Property | ||
* @module esast/nodes/Property | ||
*/ | ||
|
||
import type { | ||
Data, | ||
Expression, | ||
Identifier, | ||
Parent, | ||
Pattern, | ||
PropertyKind | ||
} from '@flex-development/esast' | ||
import type { Nilable, Optional } from '@flex-development/tutils' | ||
|
||
/** | ||
* Info associated with properties. | ||
* | ||
* @see {@linkcode Data} | ||
* | ||
* @extends {Data} | ||
*/ | ||
interface PropertyData extends Data { | ||
/** | ||
* Assignment property? | ||
*/ | ||
assignment?: Nilable<boolean> | ||
} | ||
|
||
/** | ||
* A property. | ||
* | ||
* @see {@linkcode Parent} | ||
* | ||
* @extends {Parent} | ||
*/ | ||
interface Property extends Parent { | ||
/** | ||
* List of children. | ||
* | ||
* @see {@linkcode Expression} | ||
* @see {@linkcode Identifier} | ||
* @see {@linkcode Pattern} | ||
*/ | ||
children: [key: Expression | Identifier, value: Expression | Pattern] | ||
|
||
/** | ||
* Boolean indicating if property is computed. | ||
*/ | ||
computed: boolean | ||
|
||
/** | ||
* Info from the ecosystem. | ||
* | ||
* @see {@linkcode PropertyData} | ||
*/ | ||
data?: Optional<PropertyData> | ||
|
||
/** | ||
* Property kind. | ||
* | ||
* @see {@linkcode PropertyKind} | ||
*/ | ||
kind: PropertyKind | ||
|
||
/** | ||
* Boolean indicating if property value is a method. | ||
*/ | ||
method: boolean | ||
|
||
/** | ||
* Boolean indicating if property was defined using shorthand syntax. | ||
*/ | ||
shorthand: boolean | ||
|
||
/** | ||
* Node type. | ||
*/ | ||
type: 'property' | ||
} | ||
|
||
export type { PropertyData, Property as default } |