UNPKG

magic-core

Version:
30 lines (26 loc) 570 B
class TestSuite { constructor(conf) { Object.assign(this, { name: '', // 唯一 remark: '', // 备注 handlers: {}, // 包含的接口 }, conf) } accept(handler) { const { id } = handler const h = this.handlers[id] if (h) { if (h.accept) { return new Function('params', 'conf', h.accept) } return () => true } else { throw new Error(`Handler ${handler} does not exists`) } } static fromJSON(json) { const ts = new TestSuite(json) return ts } } export default TestSuite