Select Git revision
protectedFieldsAndGetters.test.js
Forked from
SOFT Core / SOFT 260 / JavaScript Practice
Source project has a limited visibility.
protectedFieldsAndGetters.test.js 725 B
import { Book } from './protectedFieldsAndGetters.js';
describe('the second `Book` class', () => {
test('has `_title` and `_author` fields and no others', () => {
const book = new Book('A Title', 'An Author');
expect(Object.getOwnPropertyNames(book).sort()).toEqual(['_author', '_title']);
});
test('stores the title and author given at construction time', () => {
const book = new Book('A Title', 'An Author');
expect(book.entry).toBe('A Title by An Author');
});
test('computes its entry based on the most recent title and author data', () => {
const book = new Book('A Title', 'An Author');
book._title = 'A New Title';
expect(book.entry).toBe('A New Title by An Author');
});
});