Skip to content

Commit

Permalink
fix: TagNode.create with null content by default
Browse files Browse the repository at this point in the history
  • Loading branch information
JiLiZART committed Apr 25, 2024
1 parent 95d9b8a commit 36b628d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/bbob-plugin-helper/src/TagNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class TagNode implements TagNodeObject {
return `${tagStart}${content}${this.toTagEnd({ openTag, closeTag })}`;
}

static create(tag: string, attrs: Record<string, unknown> = {}, content: TagNodeTree = []) {
static create(tag: string, attrs: Record<string, unknown> = {}, content: TagNodeTree = null) {
return new TagNode(tag, attrs, content)
}

Expand Down
12 changes: 12 additions & 0 deletions packages/bbob-plugin-helper/test/TagNode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ describe('@bbob/plugin-helper/TagNode', () => {
expect(newTagNode.content).toEqual(tagNode.content);
});

test('null content', () => {
const tagNode = TagNode.create('img');

expect(String(tagNode)).toBe('[img]');
});

test('array content', () => {
const tagNode = TagNode.create('img', {}, []);

expect(String(tagNode)).toBe('[img]');
});

describe('toString', () => {
test('tag with content and params', () => {
const tagNode = TagNode.create('test', {test: 1}, ['Hello']);
Expand Down

0 comments on commit 36b628d

Please sign in to comment.