Files
jasmine/spec/html/ResultsNodeSpec.js
Steve Gravrock 434575f49d Use one declaration per statement
The old style of merging all of a function's variable declarations into
a single statement made some sense back in the days of var, but there's
no reason to keep doing it now that we use const and let.
2026-03-11 06:30:46 -07:00

63 lines
1.5 KiB
JavaScript

describe('ResultsNode', function() {
it('wraps a result', function() {
const fakeResult = {
id: 123,
message: 'foo'
};
const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
expect(node.result).toBe(fakeResult);
expect(node.type).toEqual('suite');
});
it('can add children with a type', function() {
const fakeResult = {
id: 123,
message: 'foo'
};
const fakeChildResult = {
id: 456,
message: 'bar'
};
const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
node.addChild(fakeChildResult, 'spec');
expect(node.children.length).toEqual(1);
expect(node.children[0].result).toEqual(fakeChildResult);
expect(node.children[0].type).toEqual('spec');
});
it('has a pointer back to its parent ResultNode', function() {
const fakeResult = {
id: 123,
message: 'foo'
};
const fakeChildResult = {
id: 456,
message: 'bar'
};
const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
node.addChild(fakeChildResult, 'spec');
expect(node.children[0].parent).toBe(node);
});
it('can provide the most recent child', function() {
const fakeResult = {
id: 123,
message: 'foo'
};
const fakeChildResult = {
id: 456,
message: 'bar'
};
const node = new privateUnderTest.ResultsNode(fakeResult, 'suite', null);
node.addChild(fakeChildResult, 'spec');
expect(node.last()).toBe(node.children[node.children.length - 1]);
});
});