The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

midryndhil (2) [Avatar] Offline
#1
Hi,

Describe is used instead of it:

import { ContactsComponent } from './contacts.component';
describe('ContactsComponent Tests', () => {
let contactsComponent: Object = null;
beforeEach(() => {
contactsComponent = new ContactsComponent();
});
describe('The contacts component should have a valid constuctor', () => {
expect(contactsComponent).toBeAnInstanceOf(ContactsComponent);
});
describe('There should be no contacts if there is no data', () => {
expect(contactsComponent.contacts.length).toBe(0);
});
describe('There should be contacts if there is data', () => {
contactsComponent.contacts = [
{
id: 1,
name: 'Jason Pipemaker'
}];
expect(contactsComponent.contacts.length).toBe(1);
});
});


works with "it" :

import {ContactsComponent} from './contacts.component';

describe('ContactsComponent Tests', () => {
  let contactsComponent: ContactsComponent = null;
  beforeEach(() => {
    contactsComponent = new ContactsComponent();
  });
  it('The contacts component should have a valid constructor', () => {
    expect(contactsComponent).toBeDefined();
  });
  it('There should be no contacts if there is no data', () => {
    expect(contactsComponent.contacts.length).toBe(0);
  });
  it('There should be contacts if there is data', () => {
    contactsComponent.contacts = [
      {
        id: 1,
        name: 'Jason Pipemaker'
      }];
    expect(contactsComponent.contacts.length).toBe(1);
  });
});


the variable should be also of type contactsComponent and not object like in the listing.

Regards,
Jesse Palmer (53) [Avatar] Offline
#2
Thanks for catching these! They will be updated in the next version of the MEAP.