Skip to content

Commit

Permalink
reinstate deleted Fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Alvarenga committed Nov 18, 2024
1 parent a0c86a0 commit 5ec582d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 5 additions & 4 deletions packages/openscd/src/finder-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export class FinderList extends LitElement {
return path.join('/');
}

getDisplayString(entry: string, path: string[]): string {
return entry;
}

@query('div')
container!: Element;
Expand Down Expand Up @@ -150,11 +153,9 @@ export class FinderList extends LitElement {
html`<mwc-list-item
value="${entry}"
?activated=${this.getPaths(path.length)
.map(p => {
return JSON.stringify(p)
})
.map(p => JSON.stringify(p))
.includes(JSON.stringify(path.concat(entry)))}
>${entry}</mwc-list-item
>${this.getDisplayString(entry, path)}</mwc-list-item
>`
)}
</filtered-list>`;
Expand Down
8 changes: 6 additions & 2 deletions packages/openscd/test/unit/finder-list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ function getTitle(path: Path): string {
return `Testing ${path[path.length - 1]}`;
}

function getDisplayString(entry: string, path: string[]) {
return 'Testing ' + path.length + ' ' + entry;
}

async function read(path: Path): Promise<Directory> {
const dir = path[path.length - 1];
Expand Down Expand Up @@ -108,8 +111,9 @@ describe('finder-list', () => {
.property('children')
.to.have.lengthOf(pathA.length));

describe('when provided with .getTitle method', () => {
describe('when provided with .getTitle and .getDisplayString methods', () => {
beforeEach(async () => {
element.getDisplayString = getDisplayString;
element.getTitle = getTitle;
element.requestUpdate();
await element.updateComplete;
Expand All @@ -122,7 +126,7 @@ describe('finder-list', () => {
.to.satisfy((l: string) => l.startsWith('Testing '));
});

it('overrides list-item text content using', () => {
it('overrides list-item text content using .getDisplayString', () => {
expect(element.container.querySelector('mwc-list-item'))
.property('text')
.to.satisfy((t: string) => t.startsWith('Testing '));
Expand Down

0 comments on commit 5ec582d

Please sign in to comment.