Skip to content

Commit

Permalink
add tests for @attr / @Attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
KonnorRogers committed May 6, 2024
1 parent d072db1 commit 0110361
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,84 @@
{
"kind": "field",
"name": "withoutDefault"
},
{
"kind": "field",
"name": "foo",
"type": {
"text": "string"
},
"description": "Should work with \"@attribute\" and no name",
"default": "\"bar\"",
"attribute": "foo"
},
{
"kind": "field",
"name": "myFoo",
"type": {
"text": "string"
},
"description": "Should work with \"@attribute\" and a name",
"default": "\"bar\"",
"attribute": "my-foo"
},
{
"kind": "field",
"name": "bar",
"type": {
"text": "string"
},
"description": "Should work with \"@attr\" and no name",
"default": "\"bar\"",
"attribute": "bar"
},
{
"kind": "field",
"name": "myBar",
"type": {
"text": "string"
},
"description": "Should work with \"@attr\" and a name",
"default": "\"bar\"",
"attribute": "my-bar"
}
],
"attributes": [
{
"name": "foo",
"type": {
"text": "string"
},
"description": "Should work with \"@attribute\" and no name",
"default": "\"bar\"",
"fieldName": "foo"
},
{
"name": "my-foo",
"type": {
"text": "string"
},
"description": "Should work with \"@attribute\" and a name",
"default": "\"bar\"",
"fieldName": "myFoo"
},
{
"name": "bar",
"type": {
"text": "string"
},
"description": "Should work with \"@attr\" and no name",
"default": "\"bar\"",
"fieldName": "bar"
},
{
"name": "my-bar",
"type": {
"text": "string"
},
"description": "Should work with \"@attr\" and a name",
"default": "\"bar\"",
"fieldName": "myBar"
}
],
"superclass": {
Expand Down
78 changes: 78 additions & 0 deletions packages/analyzer/fixtures/06-jsdoc/default/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,84 @@
{
"kind": "field",
"name": "withoutDefault"
},
{
"kind": "field",
"name": "foo",
"type": {
"text": "string"
},
"description": "Should work with \"@attribute\" and no name",
"default": "\"bar\"",
"attribute": "foo"
},
{
"kind": "field",
"name": "myFoo",
"type": {
"text": "string"
},
"description": "Should work with \"@attribute\" and a name",
"default": "\"bar\"",
"attribute": "my-foo"
},
{
"kind": "field",
"name": "bar",
"type": {
"text": "string"
},
"description": "Should work with \"@attr\" and no name",
"default": "\"bar\"",
"attribute": "bar"
},
{
"kind": "field",
"name": "myBar",
"type": {
"text": "string"
},
"description": "Should work with \"@attr\" and a name",
"default": "\"bar\"",
"attribute": "my-bar"
}
],
"attributes": [
{
"name": "foo",
"type": {
"text": "string"
},
"description": "Should work with \"@attribute\" and no name",
"default": "\"bar\"",
"fieldName": "foo"
},
{
"name": "my-foo",
"type": {
"text": "string"
},
"description": "Should work with \"@attribute\" and a name",
"default": "\"bar\"",
"fieldName": "myFoo"
},
{
"name": "bar",
"type": {
"text": "string"
},
"description": "Should work with \"@attr\" and no name",
"default": "\"bar\"",
"fieldName": "bar"
},
{
"name": "my-bar",
"type": {
"text": "string"
},
"description": "Should work with \"@attr\" and a name",
"default": "\"bar\"",
"fieldName": "myBar"
}
],
"superclass": {
Expand Down
28 changes: 28 additions & 0 deletions packages/analyzer/fixtures/06-jsdoc/default/package/my-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,34 @@ export class DefaultValues extends HTMLElement {
defaultWhereCodeTakesPrecedence = 'default from code';

withoutDefault;

constructor () {
super()

/**
* Should work with "@attribute" and no name
* @attribute
*/
this.foo = "bar"

/**
* Should work with "@attribute" and a name
* @attribute my-foo
*/
this.myFoo = "bar"

/**
* Should work with "@attr" and no name
* @attr
*/
this.bar = "bar"

/**
* Should work with "@attr" and a name
* @attr my-bar
*/
this.myBar = "bar"
}
}

customElements.define('default-values', DefaultValues);

0 comments on commit 0110361

Please sign in to comment.