Skip to content

Instantly share code, notes, and snippets.

@joeskeen
Created October 1, 2019 23:14
Show Gist options
  • Save joeskeen/d3f86024c82f9f8c3c91ebb78d277ce9 to your computer and use it in GitHub Desktop.
Save joeskeen/d3f86024c82f9f8c3c91ebb78d277ce9 to your computer and use it in GitHub Desktop.
A sample spec demonstrating Arrange, Act, Assert
describe('PreferencesService', () => {
describe('.getPreference', () => {
it('should call getItem from LocalStorage', () => {
// Arrange: initialize spy and test subject
const getItemSpy = jasmine.createSpy('getItem');
const service = new PreferencesService({ getItem: getItemSpy } as LocalStorage);
// Act: call getPreference
service.getPreference('test key');
// Assert: make sure it called the spy
expect(getItemSpy).toHaveBeenCalled();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment