123456789101112131415161718192021222324252627282930313233343536373839 |
- export default class TestContext {
-
- constructor() {
- this.tests = []
- this.context = null
- }
-
- describe (desc, fn) {
-
- this.tests.push({
- status : 'running',
- result : null,
- asserts : [],
- desc, fn,
- })
-
- }
-
- run (context) {
- this.context = context
- let promise = Promise.resolve()
- for(let i in this.tests) {
- promise = promise.then(function(update, data) {
- return this.fn(update, data)
- }.bind(
- this.tests[i],
- this.update.bind(this, i)
- ))
- }
- return promise
- }
-
- update(i, ...data) {
- Object.assign(this.tests[i], {result : [...data]})
- this.context.forceUpdate()
- }
-
- }
|