| 58 | }; |
| 59 | |
| 60 | describe(opts, fn) { |
| 61 | const { el } = this.options; |
| 62 | |
| 63 | if (typeof opts === 'string') { |
| 64 | opts = { |
| 65 | title: opts, |
| 66 | id: opts |
| 67 | }; |
| 68 | } |
| 69 | |
| 70 | const describer = (this.describer = lay.extend( |
| 71 | { |
| 72 | suiteElem: lay.elem('div', { |
| 73 | class: 'layui-text test-suite', |
| 74 | id: opts.id |
| 75 | }), |
| 76 | itemsElem: lay.elem('div', { |
| 77 | class: 'test-items' |
| 78 | }) |
| 79 | }, |
| 80 | opts |
| 81 | )); |
| 82 | |
| 83 | lay(describer.suiteElem).append(`<h2>${opts.title} : </h2>`); |
| 84 | lay(describer.suiteElem).append(describer.itemsElem); |
| 85 | el.append(describer.suiteElem); |
| 86 | |
| 87 | fn?.(this.#it.bind(this)); |
| 88 | return this; |
| 89 | } |
| 90 | |
| 91 | #it(opts = {}) { |
| 92 | let { code, expected, title, assert } = opts; |