Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
698 B
1
Indexable
Never
describe('AppStateService', () => {
  let service: AppStateService;
  let mockLocation: any;

  beforeEach(() => {
    mockLocation = { pathname: '/safety' };
    TestBed.configureTestingModule({
      providers: [
        AppStateService,
        { provide: Location, useValue: mockLocation }
      ]
    });
    service = TestBed.inject(AppStateService);
  });

  it('should return 1 if location pathname includes "safety"', () => {
    const result = service.abc();
    expect(result).toEqual(1);
  });

  it('should return 2 if location pathname does not include "safety"', () => {
    mockLocation.pathname = '/other';
    const result = service.abc();
    expect(result).toEqual(2);
  });
});