Skip to content

Commit

Permalink
Add tests for getter and setter
Browse files Browse the repository at this point in the history
  • Loading branch information
bischofmax committed Sep 25, 2023
1 parent ce1101e commit 18d3c7b
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,62 @@ import { FileElement } from './file-element.do';
import { BoardCompositeVisitor, BoardCompositeVisitorAsync } from './types';

describe(FileElement.name, () => {
describe('get caption', () => {
describe('when caption is set', () => {
it('should return the caption', () => {
const fileElement = fileElementFactory.build();

expect(fileElement.caption).toEqual(fileElement.caption);
});
});

describe('when caption is not set', () => {
it('should return an empty string', () => {
const fileElement = fileElementFactory.build({ caption: undefined });

expect(fileElement.caption).toEqual('');
});
});
});

describe('set caption', () => {
it('should set caption', () => {
const fileElement = fileElementFactory.build();
const text = 'new caption';
fileElement.caption = text;

expect(fileElement.caption).toEqual(text);
});
});

describe('get alternative text', () => {
describe('when alternative text is set', () => {
it('should return the alternative text', () => {
const fileElement = fileElementFactory.build();

expect(fileElement.alternativeText).toEqual(fileElement.alternativeText);
});
});

describe('when alternative text is not set', () => {
it('should return an empty string', () => {
const fileElement = fileElementFactory.build({ alternativeText: undefined });

expect(fileElement.alternativeText).toEqual('');
});
});
});

describe('set alternative text', () => {
it('should set alternative text', () => {
const fileElement = fileElementFactory.build();
const text = 'new alternative text';
fileElement.alternativeText = text;

expect(fileElement.alternativeText).toEqual(text);
});
});

describe('when trying to add a child to a file element', () => {
it('should throw an error ', () => {
const fileElement = fileElementFactory.build();
Expand Down

0 comments on commit 18d3c7b

Please sign in to comment.