Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump sinon-chai from 3.7.0 to 4.0.0 #267

Merged
merged 4 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 47 additions & 52 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@
},
"devDependencies": {
"@sinonjs/referee": "^11.0.1",
"chai": "^4.2.0",
"chai": "^5.1.1",
"chai-as-promised": "^7.1.1",
"eslint": "^9.8.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-jsdoc": "^50.0.1",
"mocha": "^10.0.0",
"mock-require": "^3.0.3",
"sinon": "^18.0.0",
"sinon-chai": "^3.6.0"
"sinon-chai": "^4.0.0"
}
}
16 changes: 9 additions & 7 deletions test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
const client = require('../src/quant-client');
const config = require('../src/config');

// Testers.
const chai = require('chai');
const sinon = require('sinon');
const assert = chai.assert;
const expect = chai.expect;

// Stubbable.
const axios = require('axios');
const fs = require('fs');
Expand All @@ -30,7 +24,14 @@ describe('Quant Client', function () {
let requestPost;
let requestPatch;

beforeEach(function () {
let chai, sinon, assert, expect;

beforeEach(async () => {
chai = await import('chai');
sinon = await import('sinon');
assert = chai.assert;
expect = chai.expect;

cget = sinon.stub(config, 'get');
cget.withArgs('endpoint').returns('http://localhost:8081');
cget.withArgs('clientid').returns('dev');
Expand All @@ -40,6 +41,7 @@ describe('Quant Client', function () {

afterEach(function () {
cget.restore();
sinon.restore();
});

describe('GET /ping', function () {
Expand Down
16 changes: 9 additions & 7 deletions test/commands/deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
* Test the deploy command.
*/

const deploy = require('../../src/commands/deploy').handler;

// Testers.
const chai = require('chai');
const sinon = require('sinon');
const expect = chai.expect;
const path = require('path');
const deploy = require('../../src/commands/deploy').handler;

// Stubs
const getFiles = require('../../src/helper/getFiles');
Expand All @@ -25,8 +20,15 @@ describe('Deploy', function() {
let ping;
let send;

let chai, sinon, expect;

// Disable console log for neater test output.
before(() => sinon.stub(console, 'log'));
before(async () => {
chai = await import('chai');
sinon = await import('sinon');
expect = chai.expect;
sinon.stub(console, 'log')
});
after(() => sinon.restore());

beforeEach(function() {
Expand Down
20 changes: 14 additions & 6 deletions test/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@
*/

const config = require('../src/config.js');
const chai = require('chai');

const assert = chai.assert;
const expect = chai.expect;

const sinon = require('sinon');
const fs = require('fs');

describe('Config', function() {
let chai, sinon, assert, expect

beforeEach(async() => {
chai = await import('chai')
sinon = (await import('sinon')).default
assert = chai.assert
expect = chai.expect
})

afterEach(async () => {
sinon.restore();
})

describe('defaults', function() {
it('should have a default endpoint', function() {
assert.equal(config.get('endpoint'), 'https://api.quantcdn.io/v1');
Expand All @@ -35,6 +42,7 @@ describe('Config', function() {
describe('save()', function() {
let writeFileSync;
beforeEach(function() {
sinon.restore();
writeFileSync = sinon.stub(fs, 'writeFileSync').returns({});
config.set({
dir: 'build',
Expand Down
16 changes: 9 additions & 7 deletions test/crawl/detectors/images.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@
* Test the image detection.
*/

const chaiAsPromied = require("chai-as-promised");
const chai = require("chai");

const detector = require('../../../src/crawl/detectors/images');
const getFiles = require("../../../src/helper/getFiles");

const fs = require('fs');

chai.use(chaiAsPromied);
const assert = chai.assert;
const expect = chai.expect;

const cssString = fs.readFileSync('test/fixtures/test.css').toString();
const htmlString = fs.readFileSync("test/fixtures/index.html").toString();

describe('crawl:detectors:images', function() {
let chai, cap, expect, assert;

beforeEach(async () => {
chai = await import('chai');
cap = (await import('chai-as-promised')).default;
chai.use(cap);
assert = chai.assert;
expect = chai.expect;
})

describe('applies', () => {
it('should apply to HTML', () => {
Expand Down
16 changes: 9 additions & 7 deletions test/crawl/detectors/responsiveImg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
* Test the image detection.
*/

const chaiAsPromied = require("chai-as-promised");
const chai = require("chai");

const detector = require("../../../src/crawl/detectors/responsiveImg");
const fs = require('fs');

chai.use(chaiAsPromied);
const assert = chai.assert;
const expect = chai.expect;

const htmlString = fs.readFileSync("test/fixtures/responsive-images.html").toString();

describe('crawl:detectors:responsiveImg', function() {
let chai, cap, expect;

beforeEach(async () => {
chai = await import('chai');
cap = (await import('chai-as-promised')).default;
chai.use(cap);
expect = chai.expect;
})

describe('applies', () => {
it('should apply to HTML', () => {
const res = {};
Expand Down
Loading
Loading