scrimba
Unit Testing
Setting Up Data with beforeEach()
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Setting Up Data with beforeEach()
AboutCommentsNotes
Setting Up Data with beforeEach()
Expand for more info
main.js
run
preview
console
// Unit Testing: Setting up data with beforeEach

// Test Suite
describe(`${User.name} Class`, () => {
describe('default values', () => {
it('first name defaults to empty', () => {
// arrange
const data = { firstName: null };

// act
const model = new User(data);

// assert
expect(model.firstName).toBe('');
});

it('last name defaults to empty', () => {
// arrange
const data = { lastName: null };

// act
const model = new User(data);

// assert
expect(model.lastName).toBe('');
});

it('middle name defaults to empty', () => {
// arrange
const data = { middleName: null };

// act
const model = new User(data);

// assert
expect(model.middleName).toBe('');
});
});
});
Console
/index.html
-4:03