Created
January 22, 2018 04:22
-
-
Save PavanKu/a3de6a9ecd15a8bbcf18e58b8b221cf7 to your computer and use it in GitHub Desktop.
Unit Testing of Model Class In AngularJS V5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Contact } from './contact'; | |
describe('Contact', () => { | |
it('should create an instance', () => { | |
expect(new Contact()).toBeTruthy(); | |
}); | |
it('should accept values from constructor', () => { | |
let contact = new Contact({ | |
firstName: 'John', | |
lastName: 'Reed' | |
}); | |
expect(contact.firstName).toEqual('John'); | |
expect(contact.lastName).toEqual('Reed'); | |
expect(contact.id).toBeUndefined(); | |
expect(contact.phone).toBeFalsy(); | |
expect(contact.country).toBeFalsy(); | |
}); | |
it('contact#save should update the full name', () => { | |
let contact = new Contact({ | |
firstName: 'Tony', | |
lastName: 'Stark', | |
phone: '+1 230130280', | |
country: 'United States of America' | |
}); | |
expect(contact.fullName).toBeFalsy(); | |
contact.save(); | |
expect(contact.fullName).toEqual('Tony Stark'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment