Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Mock providers not cached #82

Description

@OliverJAsh
var di = require('di');

function Bar() {}

di.annotate(Foo, new di.Inject(Bar));
function Foo() {}

di.annotate(BarMock, new di.Provide(Bar));
function BarMock() {
    console.log('initialise BarMock');
}

var injector = new di.Injector([BarMock]);

injector.get(Foo);
injector.get(BarMock);

I expect that BarMock should only be initialised once, as the second time I call injector.getPromise, BarMock has already been initialised – the subsequent request should fetch the cached version.

I am seeing:

$ node test
initialise BarMock
initialise BarMock

I expect:

$ node test
initialise BarMock

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions