(reflectContext: NamespacedReflect)
| 34 | }); |
| 35 | |
| 36 | function runTests(reflectContext: NamespacedReflect) { |
| 37 | afterEach(resetMetadata); |
| 38 | |
| 39 | it('adds metadata to a class', () => { |
| 40 | const metadataValue: object = {value: 'sample'}; |
| 41 | // define a metadata using the namespaced reflectContext |
| 42 | reflectContext.defineMetadata('key', metadataValue, SubClass); |
| 43 | |
| 44 | // get the defined metadata using the namespaced reflectContext |
| 45 | let metadata = reflectContext.getMetadata('key', SubClass); |
| 46 | expect(metadata).to.be.equal(metadataValue); |
| 47 | |
| 48 | metadata = reflectContext.getOwnMetadata('key', SubClass); |
| 49 | expect(metadata).to.be.equal(metadataValue); |
| 50 | |
| 51 | // base class should not be impacted |
| 52 | metadata = reflectContext.getOwnMetadata('key', BaseClass); |
| 53 | expect(metadata).to.be.undefined(); |
| 54 | |
| 55 | metadata = reflectContext.getMetadata('key', BaseClass); |
| 56 | expect(metadata).to.be.undefined(); |
| 57 | |
| 58 | let result = reflectContext.hasOwnMetadata('key', SubClass); |
| 59 | expect(result).to.be.true(); |
| 60 | |
| 61 | result = reflectContext.hasMetadata('key', SubClass); |
| 62 | expect(result).to.be.true(); |
| 63 | }); |
| 64 | |
| 65 | it('adds metadata to a static method', () => { |
| 66 | const metadataValue: object = {value: 'sample'}; |
| 67 | // define a metadata using the namespaced reflectContext |
| 68 | reflectContext.defineMetadata( |
| 69 | 'key', |
| 70 | metadataValue, |
| 71 | SubClass, |
| 72 | 'subStaticMethod', |
| 73 | ); |
| 74 | |
| 75 | // get the defined metadata using the namespaced reflectContext |
| 76 | let metadata = reflectContext.getMetadata( |
| 77 | 'key', |
| 78 | SubClass, |
| 79 | 'subStaticMethod', |
| 80 | ); |
| 81 | expect(metadata).to.be.equal(metadataValue); |
| 82 | |
| 83 | metadata = reflectContext.getOwnMetadata( |
| 84 | 'key', |
| 85 | SubClass, |
| 86 | 'subStaticMethod', |
| 87 | ); |
| 88 | expect(metadata).to.be.equal(metadataValue); |
| 89 | |
| 90 | let result = reflectContext.hasOwnMetadata( |
| 91 | 'key', |
| 92 | SubClass, |
| 93 | 'subStaticMethod', |
no test coverage detected