1- import { describe , it , expect } from 'test_lib/test_lib' ;
1+ import { describe , it , expect , beforeEach } from 'test_lib/test_lib' ;
22import { Key } from 'di/di' ;
33
44export function main ( ) {
55 describe ( "key" , function ( ) {
6+ beforeEach ( function ( ) {
7+ Key . clear ( ) ;
8+ } ) ;
9+
610 it ( 'should be equal to another key if type is the same' , function ( ) {
711 expect ( Key . get ( 'car' ) ) . toBe ( Key . get ( 'car' ) ) ;
812 } ) ;
@@ -14,5 +18,32 @@ export function main() {
1418 it ( 'should return the passed in key' , function ( ) {
1519 expect ( Key . get ( Key . get ( 'car' ) ) ) . toBe ( Key . get ( 'car' ) ) ;
1620 } ) ;
21+
22+ describe ( "metadata" , function ( ) {
23+ it ( "should assign metadata to a key" , function ( ) {
24+ var key = Key . get ( 'car' ) ;
25+
26+ Key . setMetadata ( key , "meta" ) ;
27+
28+ expect ( key . metadata ) . toEqual ( "meta" ) ;
29+ } ) ;
30+
31+ it ( "should allow assigning the same metadata twice" , function ( ) {
32+ var key = Key . get ( 'car' ) ;
33+
34+ Key . setMetadata ( key , "meta" ) ;
35+ Key . setMetadata ( key , "meta" ) ;
36+
37+ expect ( key . metadata ) . toEqual ( "meta" ) ;
38+ } ) ;
39+
40+ it ( "should throw when assigning different metadata" , function ( ) {
41+ var key = Key . get ( 'car' ) ;
42+
43+ Key . setMetadata ( key , "meta1" ) ;
44+
45+ expect ( ( ) => Key . setMetadata ( key , "meta2" ) ) . toThrowError ( ) ;
46+ } ) ;
47+ } ) ;
1748 } ) ;
1849}
0 commit comments