scrimba
Unit Testing
Skipping and Focusing (Challenge)
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

Skipping and Focusing (Challenge)
AboutCommentsNotes
Skipping and Focusing (Challenge)
Expand for more info
main.js
run
preview
console
/* Unit Testing: Skipping and Focusing Challenge
*
* 1. Listen and hear the importance of what I am about to say.
* 2. Raise your right hand and say,
* 'I will be a quality developer that protects the code and my sanity.'
* 3. Type out below:
* 'I understand the value testing brings and will help to educate those about it.'
*/

/*
* Challenge Prompt Here
* ------------------------
*
*/

// Test Suite
describe(`${User.name} Class`, () => {
let model;

beforeEach(() => {
model = new User();
});

describe('default values', () => {
it('first name defaults to empty', () => {
// assert
expect(model.firstName).toBe('');
});

it('last name defaults to empty', () => {
// assert
expect(model.lastName).toBe('');
});

it('middle name defaults to empty', () => {
// assert
expect(model.middleName).toBe('');
});
});

describe('full name', () => {
beforeEach(() => {
model = new User({ firstName: 'Dylan', lastName: 'Israel' });
});

it('middle initial when middleName is defined with first and last', () => {
// arrange
model.middleName = 'Christopher';

// act
const result = model.fullName;

// assert
expect(result).toBe(`${model.firstName} ${model.middleName[0]}. ${model.lastName}`);
});

it('when no middle name return just first and last', () => {
// arrange
model.middleName = '';

// act
const result = model.fullName;

// assert
expect(result).toBe(`${model.firstName} ${model.lastName}`);
});
});
});
Console
/index.html
-4:10