Sha256: 30417702fc6b43bfbc05b4516e888ed4302160f6bd3a1188baca7918ffa9f5c2

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

import MethodCallTracker from './method-call-tracker';
class DebugAssert {
    constructor(methodName, env) {
        this.methodName = methodName;
        this.env = env;
        this.tracker = null;
    }
    inject() { }
    restore() {
        this.reset();
    }
    reset() {
        if (this.tracker) {
            this.tracker.restoreMethod();
        }
        this.tracker = null;
    }
    assert() {
        if (this.tracker) {
            this.tracker.assert();
        }
    }
    // Run an expectation callback within the context of a new tracker, optionally
    // accepting a function to run, which asserts immediately
    runExpectation(func, callback) {
        let originalTracker = null;
        // When helpers are passed a callback, they get a new tracker context
        if (func) {
            originalTracker = this.tracker;
            this.tracker = null;
        }
        if (!this.tracker) {
            this.tracker = new MethodCallTracker(this.env, this.methodName);
        }
        // Yield to caller with tracker instance
        callback(this.tracker);
        // Once the given callback is invoked, the pending assertions should be
        // flushed immediately
        if (func) {
            func();
            this.assert();
            this.reset();
            this.tracker = originalTracker;
        }
    }
}
export default DebugAssert;

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/internal-test-helpers/lib/ember-dev/debug.js
discourse-ember-source-3.5.1.1 dist/es/internal-test-helpers/lib/ember-dev/debug.js
discourse-ember-source-3.5.1.0 dist/dist/es/internal-test-helpers/lib/ember-dev/debug.js