Esempio n. 1
0
    });
    it('outer afterEach is called after inner afterEach', function () {
        $calls = [];
        $env = new Env();
        $env->describe('outer', function () use($env, &$calls) {
            $env->afterEach(function () use(&$calls) {
                $calls[] = 'outer';
            });
            $env->describe('and inner afterEach', function () use($env, &$calls) {
                $env->afterEach(function () use(&$calls) {
                    $calls[] = 'inner';
                });
                $env->it('a spec');
            });
        });
        $env->execute();
        expect($calls)->toEqual(['inner', 'outer']);
    });
    it('is supported on top level (Env)', function () {
        $wasCalled = false;
        $env = new Env();
        $env->afterEach(function () use(&$wasCalled) {
            $wasCalled = true;
        });
        $env->describe('a context', function () use($env) {
            $env->it('a spec');
        });
        $env->execute();
        expect($wasCalled)->toBe(true);
    });
});
Esempio n. 2
0
            expect($env->execute())->toBe(false);
        });
        it('returns true if no specs', function () {
            $env = new Env();
            expect($env->execute())->toBe(true);
        });
        it('returns true if all specs passes', function () {
            $env = new Env();
            $env->it('passes');
            expect($env->execute())->toBe(true);
        });
        it('returns false if a spec fails', function () {
            $env = new Env();
            $env->it('fails', function () use($env) {
                $env->expect(true)->toBe(false);
            });
            expect($env->execute())->toBe(false);
        });
    });
    it('can ignore contexts', function () {
        $wasCalled = false;
        $env = new Env();
        $env->xdescribe('this will be ignored', function () use($env, &$wasCalled) {
            $env->it('is ignored indirectly by context', function () use(&$wasCalled) {
                $wasCalled = true;
            });
        });
        $env->execute();
        expect($wasCalled)->toBe(false);
    });
});
Esempio n. 3
0
function afterEach($fn)
{
    Env::getInstance()->afterEach($fn);
}