Skip to content

Commit

Permalink
Merge branch 'main' into scrollable-tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Meyer authored Oct 23, 2024
2 parents d526d69 + 858c553 commit ce55e55
Show file tree
Hide file tree
Showing 132 changed files with 652 additions and 982 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Remove hard-coded nimble tag name strings",
"packageName": "@ni/nimble-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Remove hard-coded nimble tag name strings",
"packageName": "@ni/spright-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { html } from '@microsoft/fast-element';
import { parameterizeSpec } from '@ni/jasmine-parameterized';
import { AnchorButton } from '..';
import { AnchorButton, anchorButtonTag } from '..';
import { waitForUpdatesAsync } from '../../testing/async-helpers';
import { fixture, Fixture } from '../../utilities/tests/fixture';

async function setup(): Promise<Fixture<AnchorButton>> {
return await fixture<AnchorButton>(
html`<nimble-anchor-button></nimble-anchor-button>`
html`<${anchorButtonTag}></${anchorButtonTag}>`
);
}

Expand All @@ -24,7 +24,7 @@ describe('AnchorButton', () => {
});

it('can construct an element instance', () => {
expect(document.createElement('nimble-anchor-button')).toBeInstanceOf(
expect(document.createElement(anchorButtonTag)).toBeInstanceOf(
AnchorButton
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { customElement, html, ref } from '@microsoft/fast-element';
import { MenuItem as FoundationMenuItem } from '@microsoft/fast-foundation';
import { parameterizeSpec } from '@ni/jasmine-parameterized';
import { AnchorMenuItem } from '..';
import type { IconCheck } from '../../icons/check';
import type { IconXmark } from '../../icons/xmark';
import type { Menu } from '../../menu';
import { AnchorMenuItem, anchorMenuItemTag } from '..';
import { iconCheckTag, type IconCheck } from '../../icons/check';
import { iconXmarkTag, type IconXmark } from '../../icons/xmark';
import { menuTag, type Menu } from '../../menu';
import { waitForUpdatesAsync } from '../../testing/async-helpers';
import { fixture, Fixture } from '../../utilities/tests/fixture';
import { menuItemTag } from '../../menu-item';

@customElement('foundation-menu-item')
export class TestMenuItem extends FoundationMenuItem {}
Expand All @@ -20,16 +21,16 @@ describe('Anchor Menu Item', () => {

async function setup(source: Model): Promise<Fixture<AnchorMenuItem>> {
return await fixture<AnchorMenuItem>(
html`<nimble-anchor-menu-item href="#">
<nimble-xmark-icon
html`<${anchorMenuItemTag} href="#">
<${iconXmarkTag}
${ref('xmarkIcon')}
slot="start"
></nimble-xmark-icon>
<nimble-check-icon
></${iconXmarkTag}>
<${iconCheckTag}
${ref('checkIcon')}
slot="end"
></nimble-check-icon>
</nimble-anchor-menu-item>`,
></${iconCheckTag}>
</${anchorMenuItemTag}>`,
{ source }
);
}
Expand All @@ -49,9 +50,9 @@ describe('Anchor Menu Item', () => {
});

it('can construct an element instance', () => {
expect(
document.createElement('nimble-anchor-menu-item')
).toBeInstanceOf(AnchorMenuItem);
expect(document.createElement(anchorMenuItemTag)).toBeInstanceOf(
AnchorMenuItem
);
});

it('should set the role to menuitem', async () => {
Expand Down Expand Up @@ -118,32 +119,32 @@ describe('Anchor Menu Item', () => {
async function setup(source: Model): Promise<Fixture<Menu>> {
return await fixture<Menu>(
html`
<nimble-menu>
<nimble-menu-item>
<nimble-icon-xmark slot="start"></nimble-icon-xmark>
<${menuTag}>
<${menuItemTag}>
<${iconXmarkTag} slot="start"></${iconXmarkTag}>
Item 1
</nimble-menu-item>
<nimble-anchor-menu-item ${ref('item2')} href="a"
>Item 2</nimble-anchor-menu-item
</${menuItemTag}>
<${anchorMenuItemTag} ${ref('item2')} href="a"
>Item 2</${anchorMenuItemTag}
>
<nimble-anchor-menu-item ${ref('item3')} href="b"
>Item 3</nimble-anchor-menu-item
<${anchorMenuItemTag} ${ref('item3')} href="b"
>Item 3</${anchorMenuItemTag}
>
<nimble-menu-item>
<nimble-menu>
<nimble-menu-item>Item 4.1</nimble-menu-item>
<nimble-anchor-menu-item
<${menuItemTag}>
<${menuTag}>
<${menuItemTag}>Item 4.1</${menuItemTag}>
<${anchorMenuItemTag}
${ref('item4dot2')}
href="c"
>Item 4.2</nimble-anchor-menu-item
>Item 4.2</${anchorMenuItemTag}
>
<nimble-anchor-menu-item href="d"
>Item 4.3</nimble-anchor-menu-item
<${anchorMenuItemTag} href="d"
>Item 4.3</${anchorMenuItemTag}
>
</nimble-menu>
</${menuTag}>
Item 4
</nimble-menu-item>
</nimble-menu>
</${menuItemTag}>
</${menuTag}>
`,
{ source }
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { html } from '@microsoft/fast-element';
import { parameterizeSpec } from '@ni/jasmine-parameterized';
import { AnchorTab } from '..';
import { AnchorTab, anchorTabTag } from '..';
import { waitForUpdatesAsync } from '../../testing/async-helpers';
import { Fixture, fixture } from '../../utilities/tests/fixture';

async function setup(): Promise<Fixture<AnchorTab>> {
return await fixture<AnchorTab>(
html`<nimble-anchor-tab></nimble-anchor-tab>`
);
return await fixture<AnchorTab>(html`<${anchorTabTag}></${anchorTabTag}>`);
}

describe('AnchorTab', () => {
Expand All @@ -24,9 +22,7 @@ describe('AnchorTab', () => {
});

it('can construct an element instance', () => {
expect(document.createElement('nimble-anchor-tab')).toBeInstanceOf(
AnchorTab
);
expect(document.createElement(anchorTabTag)).toBeInstanceOf(AnchorTab);
});

const attributeNames = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
keyTab
} from '@microsoft/fast-web-utilities';
import { parameterizeSpec } from '@ni/jasmine-parameterized';
import { AnchorTabs } from '..';
import { AnchorTabs, anchorTabsTag } from '..';
import '../../anchor-tab';
import type { AnchorTab } from '../../anchor-tab';
import { anchorTabTag, type AnchorTab } from '../../anchor-tab';
import { waitForUpdatesAsync } from '../../testing/async-helpers';
import { fixture, Fixture } from '../../utilities/tests/fixture';
import { AnchorTabsPageObject } from '../testing/anchor-tabs.pageobject';
Expand All @@ -33,11 +33,11 @@ describe('AnchorTabs', () => {
describe('without hrefs', () => {
async function setup(): Promise<Fixture<AnchorTabs>> {
return await fixture<AnchorTabs>(
html`<nimble-anchor-tabs activeid="tab-two">
<nimble-anchor-tab></nimble-anchor-tab>
<nimble-anchor-tab id="tab-two"></nimble-anchor-tab>
<nimble-anchor-tab id="tab-three"></nimble-anchor-tab>
</nimble-anchor-tabs>`
html`<${anchorTabsTag} activeid="tab-two">
<${anchorTabTag}></${anchorTabTag}>
<${anchorTabTag} id="tab-two"></${anchorTabTag}>
<${anchorTabTag} id="tab-three"></${anchorTabTag}>
</${anchorTabsTag}>`
);
}

Expand All @@ -52,7 +52,7 @@ describe('AnchorTabs', () => {
});

it('can construct an element instance', () => {
expect(document.createElement('nimble-anchor-tabs')).toBeInstanceOf(
expect(document.createElement(anchorTabsTag)).toBeInstanceOf(
AnchorTabs
);
});
Expand Down Expand Up @@ -86,15 +86,9 @@ describe('AnchorTabs', () => {

it('should populate tabs array with anchor tabs', () => {
expect(element.tabs.length).toBe(3);
expect(element.tabs[0]?.nodeName.toLowerCase()).toBe(
'nimble-anchor-tab'
);
expect(element.tabs[1]?.nodeName.toLowerCase()).toBe(
'nimble-anchor-tab'
);
expect(element.tabs[2]?.nodeName.toLowerCase()).toBe(
'nimble-anchor-tab'
);
expect(element.tabs[0]?.nodeName.toLowerCase()).toBe(anchorTabTag);
expect(element.tabs[1]?.nodeName.toLowerCase()).toBe(anchorTabTag);
expect(element.tabs[2]?.nodeName.toLowerCase()).toBe(anchorTabTag);
});

it('should set activetab property based on activeid', () => {
Expand Down Expand Up @@ -157,17 +151,17 @@ describe('AnchorTabs', () => {
describe('with hrefs', () => {
async function setupWithHrefs(): Promise<Fixture<AnchorTabs>> {
return await fixture<AnchorTabs>(
html`<nimble-anchor-tabs activeid="tab-two">
<nimble-anchor-tab href="foo"></nimble-anchor-tab>
<nimble-anchor-tab
html`<${anchorTabsTag} activeid="tab-two">
<${anchorTabTag} href="foo"></${anchorTabTag}>
<${anchorTabTag}
href="foo"
id="tab-two"
></nimble-anchor-tab>
<nimble-anchor-tab
></${anchorTabTag}>
<${anchorTabTag}
href="foo"
id="tab-three"
></nimble-anchor-tab>
</nimble-anchor-tabs>`
></${anchorTabTag}>
</${anchorTabsTag}>`
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { customElement, html, ref } from '@microsoft/fast-element';
import { TreeItem as FoundationTreeItem } from '@microsoft/fast-foundation';
import { parameterizeSpec } from '@ni/jasmine-parameterized';
import { AnchorTreeItem } from '..';
import type { IconCheck } from '../../icons/check';
import type { IconXmark } from '../../icons/xmark';
import { AnchorTreeItem, anchorTreeItemTag } from '..';
import { iconCheckTag, type IconCheck } from '../../icons/check';
import { iconXmarkTag, type IconXmark } from '../../icons/xmark';
import { waitForUpdatesAsync } from '../../testing/async-helpers';
import type { TreeItem } from '../../tree-item';
import type { TreeView } from '../../tree-view';
import { treeItemTag, type TreeItem } from '../../tree-item';
import { treeViewTag, type TreeView } from '../../tree-view';
import { fixture, Fixture } from '../../utilities/tests/fixture';

@customElement('foundation-tree-item')
Expand All @@ -21,16 +21,16 @@ describe('Anchor Tree Item', () => {

async function setup(source: Model): Promise<Fixture<AnchorTreeItem>> {
return await fixture<AnchorTreeItem>(
html`<nimble-anchor-tree-item href="#">
<nimble-xmark-icon
html`<${anchorTreeItemTag} href="#">
<${iconXmarkTag}
${ref('xmarkIcon')}
slot="start"
></nimble-xmark-icon>
<nimble-check-icon
></${iconXmarkTag}>
<${iconCheckTag}
${ref('checkIcon')}
slot="end"
></nimble-check-icon>
</nimble-anchor-tree-item>`,
></${iconCheckTag}>
</${anchorTreeItemTag}>`,
{ source }
);
}
Expand All @@ -50,9 +50,9 @@ describe('Anchor Tree Item', () => {
});

it('can construct an element instance', () => {
expect(
document.createElement('nimble-anchor-tree-item')
).toBeInstanceOf(AnchorTreeItem);
expect(document.createElement(anchorTreeItemTag)).toBeInstanceOf(
AnchorTreeItem
);
});

it('should set the role to treeitem', async () => {
Expand Down Expand Up @@ -128,19 +128,19 @@ describe('Anchor Tree Item', () => {
return await fixture<TreeView>(
// prettier-ignore
html<Model>`
<nimble-tree-view ${ref('treeView')}>
<nimble-tree-item ${ref('root1')}>Root1
<nimble-tree-item ${ref('subRoot1')}>SubRoot
<nimble-anchor-tree-item ${ref('leaf1')} href="#" selected>Leaf1</nimble-anchor-tree-item>
</nimble-tree-item>
<nimble-anchor-tree-item ${ref('leaf2')} href="#">Leaf 2</nimble-anchor-tree-item>
</nimble-tree-item>
<nimble-tree-item ${ref('root2')}>Root2
<nimble-tree-item ${ref('subRoot2')}>SubRoot 2
<nimble-anchor-tree-item ${ref('leaf3')} href="#">Leaf 3</nimble-anchor-tree-item>
</nimble-tree-item>
</nimble-tree-item>
</nimble-tree-view>`,
<${treeViewTag} ${ref('treeView')}>
<${treeItemTag} ${ref('root1')}>Root1
<${treeItemTag} ${ref('subRoot1')}>SubRoot
<${anchorTreeItemTag} ${ref('leaf1')} href="#" selected>Leaf1</${anchorTreeItemTag}>
</${treeItemTag}>
<${anchorTreeItemTag} ${ref('leaf2')} href="#">Leaf 2</${anchorTreeItemTag}>
</${treeItemTag}>
<${treeItemTag} ${ref('root2')}>Root2
<${treeItemTag} ${ref('subRoot2')}>SubRoot 2
<${anchorTreeItemTag} ${ref('leaf3')} href="#">Leaf 3</${anchorTreeItemTag}>
</${treeItemTag}>
</${treeItemTag}>
</${treeViewTag}>`,
{ source }
);
}
Expand Down
10 changes: 3 additions & 7 deletions packages/nimble-components/src/anchor/tests/anchor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { waitForUpdatesAsync } from '../../testing/async-helpers';
import { fixture, Fixture } from '../../utilities/tests/fixture';

async function setup(): Promise<Fixture<Anchor>> {
return await fixture<Anchor>(html`<nimble-anchor></nimble-anchor>`);
return await fixture<Anchor>(html`<${anchorTag}></${anchorTag}>`);
}

describe('Anchor', () => {
Expand All @@ -21,12 +21,8 @@ describe('Anchor', () => {
await disconnect();
});

it('should export its tag', () => {
expect(anchorTag).toBe('nimble-anchor');
});

it('can construct an element instance', () => {
expect(document.createElement('nimble-anchor')).toBeInstanceOf(Anchor);
expect(document.createElement(anchorTag)).toBeInstanceOf(Anchor);
});

it('should set the "control" class on the internal control', async () => {
Expand Down Expand Up @@ -157,7 +153,7 @@ describe('Anchor', () => {
describe('with contenteditable without value', () => {
async function setupWithContenteditable(): Promise<Fixture<Anchor>> {
return await fixture<Anchor>(
html`<nimble-anchor contenteditable></nimble-anchor>`
html`<${anchorTag} contenteditable></${anchorTag}>`
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { AnchoredRegion, anchoredRegionTag } from '..';

describe('Anchored Region', () => {
it('should export its tag', () => {
expect(anchoredRegionTag).toBe('nimble-anchored-region');
});

it('can construct an element instance', () => {
expect(document.createElement('nimble-anchored-region')).toBeInstanceOf(
expect(document.createElement(anchoredRegionTag)).toBeInstanceOf(
AnchoredRegion
);
});
Expand Down
Loading

0 comments on commit ce55e55

Please sign in to comment.