Skip to content

Commit

Permalink
test: Add missing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
davidparsson committed Jun 16, 2024
1 parent 9858f3e commit 3418a7c
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion spec/test_case.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe('Test Case builder', () => {
let propertiesElement: XMLElement;
let testCaseElement: XMLElement;
let failureElement: XMLElement;
let errorElement: XMLElement;
let skippedElement: XMLElement;
let systemOutElement: XMLElement;
let systemErrElement: XMLElement;
Expand All @@ -24,6 +25,7 @@ describe('Test Case builder', () => {
parentElement = createElementMock();
testCaseElement = createElementMock();
failureElement = createElementMock();
errorElement = createElementMock();
skippedElement = createElementMock();
systemOutElement = createElementMock();
systemErrElement = createElementMock();
Expand All @@ -50,7 +52,7 @@ describe('Test Case builder', () => {
case 'properties':
return propertiesElement;
case 'error':
return createElementMock();
return errorElement;
}
throw new Error(`Unexpected element name: ${elementName}`);
});
Expand Down Expand Up @@ -143,6 +145,17 @@ describe('Test Case builder', () => {
});
});

it('should add a failure node with message and type when test failed', () => {
testCase.failure('Failure message', 'Failure type');

testCase.build(parentElement);

expect(testCaseElement.ele).toHaveBeenCalledWith('failure', {
message: 'Failure message',
type: 'Failure type',
});
});

it('should add the stactrace to the failure node when stacktrace provided', () => {
testCase.stacktrace('This is a stacktrace');

Expand Down Expand Up @@ -197,6 +210,29 @@ describe('Test Case builder', () => {
});
});

it('should add a error node with message and type when test errored', () => {
testCase.error('Error message', 'Error type');

testCase.build(parentElement);

expect(testCaseElement.ele).toHaveBeenCalledWith('error', {
message: 'Error message',
type: 'Error type',
});
});

it('should add a error node with message, type and content when test errored', () => {
testCase.error('Error message', 'Error type', 'Error content');

testCase.build(parentElement);

expect(testCaseElement.ele).toHaveBeenCalledWith('error', {
message: 'Error message',
type: 'Error type',
});
expect(errorElement.cdata).toHaveBeenCalledWith('Error content');
});

describe('system-out', () => {
it('should not create a system-out tag when nothing logged', () => {
testCase.build(parentElement);
Expand Down Expand Up @@ -310,4 +346,8 @@ describe('Test Case builder', () => {
expect(testCase.getSkippedCount()).toBe(1);
});
});

describe('test case counting', () => {
it('should be 1 for a test case', () => expect(testCase.getTestCaseCount()).toBe(1));
});
});

0 comments on commit 3418a7c

Please sign in to comment.