-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/container fetch method renamed (#3)
* Container.fetch method renamed to 'get' * Added tests with Jest
- Loading branch information
1 parent
0899c0d
commit b5b4fdf
Showing
6 changed files
with
36 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015"] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules/ | ||
yarn.lock |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Container from '../src/Container'; | ||
|
||
describe('Container', () => { | ||
const container = new Container(); | ||
class MyClass { } | ||
container.registerDefinition('my:class', MyClass); | ||
|
||
describe('Container.get()', () => { | ||
test('should return the expected service when asked for', () => { | ||
expect(container.get('my:class')).toBeInstanceOf(MyClass); | ||
}); | ||
|
||
test('should throw an error if an unexisting service or param is accessed', () => { | ||
expect(() => { | ||
container.get('unexisting:service'); | ||
}).toThrowError('Service or parameter "unexisting:service" not found.'); | ||
}); | ||
}); | ||
}); |