Skip to content

Commit

Permalink
fix: eslint fix & list test case fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jiawei686 authored and humyfred committed Feb 28, 2022
1 parent a7661d7 commit 2b8cb1a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/core/ParagraphBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default class ParagraphBase extends SyntaxBase {
return;
}
const $sign = sign || this.$engine.md5(str);
this.cache[$sign] = {
this.cache[$sign] = {
content: str,
using: true,
};
Expand All @@ -186,10 +186,10 @@ export default class ParagraphBase extends SyntaxBase {
if (!this.needCache) {
return;
}
for (let key in this.cache) {
for (const key of Object.keys(this.cache)) {
if (!this.cache[key].using) delete this.cache[key];
}
for (let key in this.cache) {
for (const key of Object.keys(this.cache)) {
this.cache[key].using = false;
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/core/hooks/List.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ Object.defineProperty(listHook, '$engine', {
describe('core/hooks/list', () => {
it('list hook', () => {
cases.forEach((item) => {
expect(listHook.toHtml(item, (text) => ({ html: text }))).toMatchSnapshot();
listHook.makeHtml(item, (text) => ({ html: text }));
expect(listHook.cache[listHook.sign].content).toMatchSnapshot();
});
});
});
10 changes: 5 additions & 5 deletions test/core/hooks/__snapshots__/List.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`core/hooks/list list hook 1`] = `"<ul data-lines=\\"8\\" data-sign=\\"0ee90839df66d748d6faefc70677e3ee\\" class=\\"cherry-list__default\\"><li><p>1</p></li><li><p>2</p><ul class=\\"cherry-list__default\\"><li><p>2.1</p></li><li><p>2.2</p></li></ul></li><li><p>3</p><ul class=\\"cherry-list__circle\\"><li><p>3.1</p></li></ul></li><li><p>4</p><ul class=\\"cherry-list__square\\"><li><p>4.2</p></li></ul></li></ul>"`;
exports[`core/hooks/list list hook 1`] = `"<ul data-lines=\\"8\\" data-sign=\\"2052aa9811ccbbdfcace4f3e56d89249\\" class=\\"cherry-list__default\\"><li><p>1</p></li><li><p>2</p><ul class=\\"cherry-list__default\\"><li><p>2.1</p></li><li><p>2.2</p></li></ul></li><li><p>3</p><ul class=\\"cherry-list__circle\\"><li><p>3.1</p></li></ul></li><li><p>4</p><ul class=\\"cherry-list__square\\"><li><p>4.2</p></li></ul></li></ul>"`;
exports[`core/hooks/list list hook 2`] = `"<ul data-lines=\\"8\\" data-sign=\\"517b0da7dd7b1b616ab99665b9d280eb\\" class=\\"cherry-list__default\\"><li><p>1</p><ul class=\\"cherry-list__default\\"><li><p>2</p><ul class=\\"cherry-list__default\\"><li><p>2.1</p></li><li><p>2.2</p></li></ul></li></ul></li><li><p>3<br>3.1</p></li><li><p>4</p></li><li><p>4.2</p></li></ul>"`;
exports[`core/hooks/list list hook 2`] = `"<ul data-lines=\\"8\\" data-sign=\\"362f490aeca95ab73384e1e30a576e1a\\" class=\\"cherry-list__default\\"><li><p>1</p><ul class=\\"cherry-list__default\\"><li><p>2</p><ul class=\\"cherry-list__default\\"><li><p>2.1</p></li><li><p>2.2</p></li></ul></li></ul></li><li><p>3<br>3.1</p></li><li><p>4</p></li><li><p>4.2</p></li></ul>"`;
exports[`core/hooks/list list hook 3`] = `"<ul data-lines=\\"1\\" data-sign=\\"567632d2786fbb27c9e5df62189c44a7\\" class=\\"cherry-list__default\\"><li><p>1</p></li></ul><ol data-lines=\\"2\\" data-sign=\\"567632d2786fbb27c9e5df62189c44a7\\" class=\\"cherry-list__default\\"><li><p>test<br></p></li></ol><ul data-lines=\\"8\\" data-sign=\\"567632d2786fbb27c9e5df62189c44a7\\" class=\\"cherry-list__default\\"><li><p>1.1</p><ul class=\\"cherry-list__default\\"><li><p>1.1.2</p><ul class=\\"cherry-list__default\\"><li><p>blank</p></li></ul></li><li><p>1.2</p></li></ul></li><li><p>2<br>blank</p><ul class=\\"cherry-list__default\\"><li><p>2.1</p></li><li><p>2.2</p></li></ul></li></ul><ol data-lines=\\"2\\" data-sign=\\"567632d2786fbb27c9e5df62189c44a7\\" class=\\"cherry-list__default\\"><li><p>test</p><ol class=\\"cherry-list__default\\"><li><p>2</p></li></ol></li></ol>"`;
exports[`core/hooks/list list hook 3`] = `"<ul data-lines=\\"1\\" data-sign=\\"95b9a2e3d59355afad427cda2937e115\\" class=\\"cherry-list__default\\"><li><p>1</p></li></ul><ol data-lines=\\"2\\" data-sign=\\"95b9a2e3d59355afad427cda2937e115\\" class=\\"cherry-list__default\\"><li><p>test<br></p></li></ol><ul data-lines=\\"8\\" data-sign=\\"95b9a2e3d59355afad427cda2937e115\\" class=\\"cherry-list__default\\"><li><p>1.1</p><ul class=\\"cherry-list__default\\"><li><p>1.1.2</p><ul class=\\"cherry-list__default\\"><li><p>blank</p></li></ul></li><li><p>1.2</p></li></ul></li><li><p>2<br>blank</p><ul class=\\"cherry-list__default\\"><li><p>2.1</p></li><li><p>2.2</p></li></ul></li></ul><ol data-lines=\\"2\\" data-sign=\\"95b9a2e3d59355afad427cda2937e115\\" class=\\"cherry-list__default\\"><li><p>test</p><ol class=\\"cherry-list__default\\"><li><p>2</p></li></ol></li></ol>"`;
exports[`core/hooks/list list hook 4`] = `"<ol data-lines=\\"8\\" data-sign=\\"a7f4c176bd29fce6eed2db95c7433f88\\" class=\\"cherry-list__default\\"><li><p>test</p><ol class=\\"cherry-list__default\\"><li><p>test</p></li></ol></li><li><p>test</p><ol class=\\"cherry-list__cjk-ideographic\\"><li><p>test</p></li><li><p>test<br><br></p></li><li><p>test</p></li></ol></li></ol><ul data-lines=\\"1\\" data-sign=\\"a7f4c176bd29fce6eed2db95c7433f88\\" class=\\"cherry-list__default\\"><li><p>test</p></li></ul>"`;
exports[`core/hooks/list list hook 4`] = `"<ol data-lines=\\"8\\" data-sign=\\"739b7596b094aac47153f8bcbb07e2e3\\" class=\\"cherry-list__default\\"><li><p>test</p><ol class=\\"cherry-list__default\\"><li><p>test</p></li></ol></li><li><p>test</p><ol class=\\"cherry-list__cjk-ideographic\\"><li><p>test</p></li><li><p>test<br><br></p></li><li><p>test</p></li></ol></li></ol><ul data-lines=\\"1\\" data-sign=\\"739b7596b094aac47153f8bcbb07e2e3\\" class=\\"cherry-list__default\\"><li><p>test</p></li></ul>"`;
exports[`core/hooks/list list hook 5`] = `"<ul data-lines=\\"6\\" data-sign=\\"1352e6eb28a6f713e316fbe3733cdee7\\" class=\\"cherry-list__default\\"><li class=\\"check-list-item\\"><p><span class=\\"ch-icon ch-icon-square\\"></span> checklist 1</p></li><li><p>test</p><ul class=\\"cherry-list__default\\"><li class=\\"check-list-item\\"><p><span class=\\"ch-icon ch-icon-check\\"></span> checklist 2</p></li></ul></li><li class=\\"check-list-item\\"><p><span class=\\"ch-icon ch-icon-square\\"></span> checklist 3</p></li><li><p>test</p><ul class=\\"cherry-list__default\\"><li class=\\"check-list-item\\"><p><span class=\\"ch-icon ch-icon-square\\"></span> checklist 4</p></li></ul></li></ul>"`;
exports[`core/hooks/list list hook 5`] = `"<ul data-lines=\\"6\\" data-sign=\\"d1e2504747788dc560aedd3892b6705e\\" class=\\"cherry-list__default\\"><li class=\\"check-list-item\\"><p><span class=\\"ch-icon ch-icon-square\\"></span> checklist 1</p></li><li><p>test</p><ul class=\\"cherry-list__default\\"><li class=\\"check-list-item\\"><p><span class=\\"ch-icon ch-icon-check\\"></span> checklist 2</p></li></ul></li><li class=\\"check-list-item\\"><p><span class=\\"ch-icon ch-icon-square\\"></span> checklist 3</p></li><li><p>test</p><ul class=\\"cherry-list__default\\"><li class=\\"check-list-item\\"><p><span class=\\"ch-icon ch-icon-square\\"></span> checklist 4</p></li></ul></li></ul>"`;

0 comments on commit 2b8cb1a

Please sign in to comment.