mirror of
https://github.com/gundb/panic-server.git
synced 2026-05-07 03:00:26 -04:00
When a test finishes configuration, it's piped through the new stack interface. The stack controls what tests are being served to the client, maintaining a list of queued and completed tests. As soon as a test finishes, the next one is selected. Now each test has it's own event emitter. This'll be useful for extensions and syntactic sugar, such as when a runner is ready to run the test, or when a test finishes on a client, or when it finishes on all clients, fail events, progress events, etc... Instead of the Response constructor creating the test ID, that's been delegated to the test itself.
65 lines
1.5 KiB
JavaScript
65 lines
1.5 KiB
JavaScript
/*globals jasmine, describe, it, expect*/
|
|
/*jslint node: true*/
|
|
'use strict';
|
|
|
|
var stack = require('../../src/framework/stack');
|
|
var Emitter = require('events');
|
|
|
|
describe('The test stack', function () {
|
|
it('should expose the current test', function () {
|
|
expect(stack.current).not.toBe(undefined);
|
|
});
|
|
|
|
it('should inherit from EventEmitter', function () {
|
|
expect(stack).toEqual(jasmine.any(Emitter));
|
|
});
|
|
|
|
it('should have a list of upcoming tests', function () {
|
|
expect(stack.next).toEqual(jasmine.any(Array));
|
|
});
|
|
|
|
it('should have a list of completed tests', function () {
|
|
expect(stack.completed).toEqual(jasmine.any(Array));
|
|
});
|
|
|
|
it('should have a "push" function', function () {
|
|
expect(stack.push).toEqual(jasmine.any(Function));
|
|
});
|
|
|
|
describe('push function', function () {
|
|
it('should serve the first test', function () {
|
|
// clear the stack
|
|
stack.next = [];
|
|
stack.current = null;
|
|
var obj = {};
|
|
stack.push(obj);
|
|
expect(stack.current).toBe(obj);
|
|
});
|
|
|
|
it('should respect queued tests', function () {
|
|
var obj = {};
|
|
// first
|
|
stack.push({});
|
|
// second in line
|
|
stack.push(obj);
|
|
expect(stack.current).not.toBe(obj);
|
|
});
|
|
});
|
|
|
|
it('should select the next test when done', function () {
|
|
var obj = {};
|
|
stack.next = [obj];
|
|
stack.emit('done');
|
|
expect(stack.current).toBe(obj);
|
|
expect(stack.next.length).toBe(0);
|
|
});
|
|
|
|
it('should mark the last test as done', function () {
|
|
var obj;
|
|
stack.current = obj = {};
|
|
stack.completed = [];
|
|
stack.emit('done');
|
|
expect(stack.completed[0]).toBe(obj);
|
|
});
|
|
});
|