|
|
@@ -1,8 +1,6 @@
|
|
|
-import chai from 'chai';
|
|
|
import {expect} from 'chai';
|
|
|
import {Service} from './service.js';
|
|
|
import {ServiceContainer} from './service-container.js';
|
|
|
-const {spy} = chai;
|
|
|
|
|
|
describe('Service', function () {
|
|
|
describe('constructor', function () {
|
|
|
@@ -21,11 +19,11 @@ describe('Service', function () {
|
|
|
describe('getService', function () {
|
|
|
it('calls the container "get" method', function () {
|
|
|
const service = new Service();
|
|
|
- spy.on(service.container, 'get', (ctor, ...args) => {
|
|
|
+ service.container.get = function (ctor, ...args) {
|
|
|
expect(ctor).to.be.eq(Date);
|
|
|
expect(args).to.be.eql(['foo', 'bar', 'baz']);
|
|
|
return 'OK';
|
|
|
- });
|
|
|
+ };
|
|
|
const res = service.getService(Date, 'foo', 'bar', 'baz');
|
|
|
expect(res).to.be.eq('OK');
|
|
|
});
|
|
|
@@ -34,10 +32,10 @@ describe('Service', function () {
|
|
|
describe('hasService', function () {
|
|
|
it('calls the container "has" method', function () {
|
|
|
const service = new Service();
|
|
|
- spy.on(service.container, 'has', ctor => {
|
|
|
+ service.container.has = function (ctor) {
|
|
|
expect(ctor).to.be.eq(Date);
|
|
|
return 'OK';
|
|
|
- });
|
|
|
+ };
|
|
|
const res = service.hasService(Date);
|
|
|
expect(res).to.be.eq('OK');
|
|
|
});
|
|
|
@@ -46,10 +44,10 @@ describe('Service', function () {
|
|
|
describe('addService', function () {
|
|
|
it('calls the container "add" method', function () {
|
|
|
const service = new Service();
|
|
|
- spy.on(service.container, 'add', (ctor, ...args) => {
|
|
|
+ service.container.add = function (ctor, ...args) {
|
|
|
expect(ctor).to.be.eq(Date);
|
|
|
expect(args).to.be.eql(['foo', 'bar', 'baz']);
|
|
|
- });
|
|
|
+ };
|
|
|
const res = service.addService(Date, 'foo', 'bar', 'baz');
|
|
|
expect(res).to.be.eq(service);
|
|
|
});
|
|
|
@@ -58,10 +56,10 @@ describe('Service', function () {
|
|
|
describe('useService', function () {
|
|
|
it('calls the container "use" method', function () {
|
|
|
const service = new Service();
|
|
|
- spy.on(service.container, 'use', (ctor, ...args) => {
|
|
|
+ service.container.use = function (ctor, ...args) {
|
|
|
expect(ctor).to.be.eq(Date);
|
|
|
expect(args).to.be.eql(['foo', 'bar', 'baz']);
|
|
|
- });
|
|
|
+ };
|
|
|
const res = service.addService(Date, 'foo', 'bar', 'baz');
|
|
|
expect(res).to.be.eq(service);
|
|
|
});
|
|
|
@@ -71,10 +69,10 @@ describe('Service', function () {
|
|
|
it('calls the container "set" method', function () {
|
|
|
const service = new Service();
|
|
|
const date = new Date();
|
|
|
- spy.on(service.container, 'set', (ctor, input) => {
|
|
|
+ service.container.set = function (ctor, input) {
|
|
|
expect(ctor).to.be.eq(Date);
|
|
|
expect(input).to.be.eq(date);
|
|
|
- });
|
|
|
+ };
|
|
|
const res = service.addService(Date, date);
|
|
|
expect(res).to.be.eq(service);
|
|
|
});
|