Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add missing test cases #70

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
});
});
Loading