Created
February 25, 2021 08:47
-
-
Save linuxsimba/ffdf3ef7964523f57a4f9cbcdd6462e8 to your computer and use it in GitHub Desktop.
NG10/NS7 Test Service unit test
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 { 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