Skip to content

Instantly share code, notes, and snippets.

@Qarun-Qadir-Bissoondial
Last active April 19, 2020 21:39
Show Gist options
  • Save Qarun-Qadir-Bissoondial/90a5509c08b954bf5346c7b1e49d30f2 to your computer and use it in GitHub Desktop.
Save Qarun-Qadir-Bissoondial/90a5509c08b954bf5346c7b1e49d30f2 to your computer and use it in GitHub Desktop.
InventoryService Test file - Main Functionality
import { TestBed } from '@angular/core/testing';
import { InventoryService } from './inventory.service';
fdescribe('InventoryService', () => {
let service: InventoryService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(InventoryService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
it('should initialize the count to 0', () => {
expect(service.inventoryCount).toBe(0);
})
it('should increment the count', () => {
expect(service.inventoryCount).toBe(0);
service.incrementCount();
expect(service.inventoryCount).toBe(1);
});
it('should decrement the count', () => {
service.inventoryCount = 10;
service.decrementCount();
expect(service.inventoryCount).toBe(9);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment