Browse Source

chore: upgrades "chai" and removes chai plugins

e22m4u 1 year ago
parent
commit
b9f2bccb02
4 changed files with 11 additions and 27 deletions
  1. 0 3
      .mocharc.cjs
  2. 0 8
      mocha.setup.js
  3. 1 4
      package.json
  4. 10 12
      src/service.spec.js

+ 0 - 3
.mocharc.cjs

@@ -1,7 +1,4 @@
-const path = require('path');
-
 module.exports = {
   extension: ['js'],
   spec: 'src/**/*.spec.js',
-  require: [path.join(__dirname, 'mocha.setup.js')],
 }

+ 0 - 8
mocha.setup.js

@@ -1,8 +0,0 @@
-import chai from 'chai';
-import chaiSpies from 'chai-spies';
-import chaiSubset from 'chai-subset';
-import chaiAsPromised from 'chai-as-promised';
-
-chai.use(chaiSpies);
-chai.use(chaiSubset);
-chai.use(chaiAsPromised);

+ 1 - 4
package.json

@@ -32,10 +32,7 @@
     "@commitlint/cli": "~19.3.0",
     "@commitlint/config-conventional": "~19.2.2",
     "c8": "~10.1.2",
-    "chai": "~4.4.1",
-    "chai-as-promised": "~7.1.2",
-    "chai-spies": "~1.1.0",
-    "chai-subset": "~1.6.0",
+    "chai": "~5.1.1",
     "eslint": "~8.57.0",
     "eslint-config-prettier": "~9.1.0",
     "eslint-plugin-chai-expect": "~3.1.0",

+ 10 - 12
src/service.spec.js

@@ -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);
     });