Skip to content

Instantly share code, notes, and snippets.

@linuxsimba
Created February 25, 2021 08:47
Show Gist options
  • Save linuxsimba/ffdf3ef7964523f57a4f9cbcdd6462e8 to your computer and use it in GitHub Desktop.
Save linuxsimba/ffdf3ef7964523f57a4f9cbcdd6462e8 to your computer and use it in GitHub Desktop.
NG10/NS7 Test Service unit test
import { customNsTestBedAfterEach, customNsTestBedBeforeEach } from './setup';
import { Injectable } from '@angular/core';
import { TestBed } from '@angular/core/testing';
@Injectable({
providedIn: 'root'
})
export class TestService {
hello(): string {
return 'hello';
}
}
describe('Test Service', () => {
let testService: TestService;
beforeEach(customNsTestBedBeforeEach(
[],
[ TestService ],
));
afterEach(() => customNsTestBedAfterEach());
describe('Function Tests -', () => {
beforeEach(() => {
testService = TestBed.inject(TestService);
});
describe('hello()', () => {
it('should return the string "hello"', () => {
expect(testService.hello()).toEqual('hello');
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment