Skip to content

Commit

Permalink
fix: linting in folder test
Browse files Browse the repository at this point in the history
  • Loading branch information
ptweety committed Oct 15, 2022
1 parent 9a88d5d commit 808099b
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 186 deletions.
343 changes: 173 additions & 170 deletions test/00 - mqtt-wildcard_spec.js
Original file line number Diff line number Diff line change
@@ -1,196 +1,199 @@
/* eslint-disable unicorn/filename-case */
/* global describe, it */

const should = require('should');
const mw = require('../nodes/lib/mqtt-wildcard.js');

should.Assertion.add('arrayEqual', function (other) {
this.params = {operator: 'to be have same items'};
describe('mqtt-wildcard', () => {
should.Assertion.add('arrayEqual', function (other) {
this.params = {operator: 'to be have same items'};

for (const [index, item] of this.obj.entries()) {
//both arrays should at least contain the same items
other[index].should.equal(item);
}
for (const [index, item] of this.obj.entries()) {
//both arrays should at least contain the same items
other[index].should.equal(item);
}

// both arrays need to have the same number of items
this.obj.length.should.be.equal(other.length);
});

describe('trivial matching', () => {
it('should return the correct array when topic equals wildcard', () => {
mw('test/123', 'test/123').should.arrayEqual([]);
// both arrays need to have the same number of items
this.obj.length.should.be.equal(other.length);
});
});

describe('mismatching', () => {
it('should return null', () => {
should(mw('test/test/test', 'test/test')).equal(null);
});
it('should return null', () => {
should(mw('test/test/test/test', 'test/test')).equal(null);
describe('trivial matching', () => {
it('should return the correct array when topic equals wildcard', () => {
mw('test/123', 'test/123').should.arrayEqual([]);
});
});
it('should return null', () => {
should(mw('test/test', 'test/test/test')).equal(null);
});
it('should return null', () => {
should(mw('test/test', 'test/test/test/test')).equal(null);
});
});

describe('wildcard # matching', () => {
it('should return the correct array when wildcard is #', () => {
mw('test', '#').should.arrayEqual(['test']);
});
it('should return the correct array when wildcard is #', () => {
mw('test/test', '#').should.arrayEqual(['test/test']);
});
it('should return the correct array when wildcard is #', () => {
mw('test/test/test', '#').should.arrayEqual(['test/test/test']);
});
it('should return the correct array', () => {
mw('test/test', 'test/#').should.arrayEqual(['test']);
});
it('should return the correct array', () => {
mw('test/test/test', 'test/#').should.arrayEqual(['test/test']);
});
it('should return the correct array', () => {
mw('test/test/test', 'test/test/#').should.arrayEqual(['test']);
});
it('should return the correct array', () => {
mw('/', '/#').should.arrayEqual(['']);
describe('mismatching', () => {
it('should return null', () => {
should(mw('test/test/test', 'test/test')).equal(null);
});
it('should return null', () => {
should(mw('test/test/test/test', 'test/test')).equal(null);
});
it('should return null', () => {
should(mw('test/test', 'test/test/test')).equal(null);
});
it('should return null', () => {
should(mw('test/test', 'test/test/test/test')).equal(null);
});
});
it('should return the correct array', () => {
mw('/test', '/#').should.arrayEqual(['test']);
});
it('should return the correct array', () => {
mw('/test/', '/#').should.arrayEqual(['test/']);
});
it('should return the correct array', () => {
mw('/test/test', '/#').should.arrayEqual(['test/test']);
});
it('should return the correct array', () => {
mw('test/', 'test/#').should.arrayEqual(['']);
});
it('should return correct array', () => {
mw('test', 'test/#').should.arrayEqual([]);
});
it('should return correct array', () => {
mw('test/test', 'test/test/#').should.arrayEqual([]);
});
});

describe('wildcard # mismatching', () => {
it('should return null', () => {
should(mw('test', '/#')).equal(null);
describe('wildcard # matching', () => {
it('should return the correct array when wildcard is #', () => {
mw('test', '#').should.arrayEqual(['test']);
});
it('should return the correct array when wildcard is #', () => {
mw('test/test', '#').should.arrayEqual(['test/test']);
});
it('should return the correct array when wildcard is #', () => {
mw('test/test/test', '#').should.arrayEqual(['test/test/test']);
});
it('should return the correct array', () => {
mw('test/test', 'test/#').should.arrayEqual(['test']);
});
it('should return the correct array', () => {
mw('test/test/test', 'test/#').should.arrayEqual(['test/test']);
});
it('should return the correct array', () => {
mw('test/test/test', 'test/test/#').should.arrayEqual(['test']);
});
it('should return the correct array', () => {
mw('/', '/#').should.arrayEqual(['']);
});
it('should return the correct array', () => {
mw('/test', '/#').should.arrayEqual(['test']);
});
it('should return the correct array', () => {
mw('/test/', '/#').should.arrayEqual(['test/']);
});
it('should return the correct array', () => {
mw('/test/test', '/#').should.arrayEqual(['test/test']);
});
it('should return the correct array', () => {
mw('test/', 'test/#').should.arrayEqual(['']);
});
it('should return correct array', () => {
mw('test', 'test/#').should.arrayEqual([]);
});
it('should return correct array', () => {
mw('test/test', 'test/test/#').should.arrayEqual([]);
});
});
it('should return null', () => {
should(mw('test/test', 'muh/#')).equal(null);
});
it('should return null', () => {
should(mw('', 'muh/#')).equal(null);
});
});

describe('wildcard + matching', () => {
it('should return the correct array', () => {
mw('test', '+').should.arrayEqual(['test']);
});
it('should return the correct array', () => {
mw('test/', 'test/+').should.arrayEqual(['']);
});
it('should return the correct array', () => {
mw('test/test', 'test/+').should.arrayEqual(['test']);
});
it('should return the correct array', () => {
mw('test/test/test', 'test/+/+').should.arrayEqual(['test', 'test']);
describe('wildcard # mismatching', () => {
it('should return null', () => {
should(mw('test', '/#')).equal(null);
});
it('should return null', () => {
should(mw('test/test', 'muh/#')).equal(null);
});
it('should return null', () => {
should(mw('', 'muh/#')).equal(null);
});
});
it('should return the correct array', () => {
mw('test/test/test', 'test/+/test').should.arrayEqual(['test']);
});
});

describe('wildcard + mismatching', () => {
it('should return null', () => {
should(mw('test', '/+')).equal(null);
});
it('should return null', () => {
should(mw('test', 'test/+')).equal(null);
});
it('should return null', () => {
should(mw('test/test', 'test/test/+')).equal(null);
describe('wildcard + matching', () => {
it('should return the correct array', () => {
mw('test', '+').should.arrayEqual(['test']);
});
it('should return the correct array', () => {
mw('test/', 'test/+').should.arrayEqual(['']);
});
it('should return the correct array', () => {
mw('test/test', 'test/+').should.arrayEqual(['test']);
});
it('should return the correct array', () => {
mw('test/test/test', 'test/+/+').should.arrayEqual(['test', 'test']);
});
it('should return the correct array', () => {
mw('test/test/test', 'test/+/test').should.arrayEqual(['test']);
});
});
});

describe('wildcard +/# matching', () => {
it('should return the correct array', () => {
mw('test/test', '+/#').should.arrayEqual(['test', 'test']);
});
it('should return the correct array', () => {
mw('test/test/', '+/test/#').should.arrayEqual(['test', '']);
});
it('should return the correct array', () => {
mw('test/test/', 'test/+/#').should.arrayEqual(['test', '']);
});
it('should return the correct array', () => {
mw('test/test/test', '+/test/#').should.arrayEqual(['test', 'test']);
});
it('should return the correct array', () => {
mw('test/test/test', 'test/+/#').should.arrayEqual(['test', 'test']);
});
it('should return the correct array', () => {
mw('test/test/test', '+/+/#').should.arrayEqual(['test', 'test', 'test']);
});
it('should return the correct array', () => {
mw('test/test/test/test', 'test/+/+/#').should.arrayEqual(['test', 'test', 'test']);
});
it('should return the correct array', () => {
mw('test', '+/#').should.arrayEqual(['test']);
});
it('should return the correct array', () => {
mw('test/test', 'test/+/#').should.arrayEqual(['test']);
describe('wildcard + mismatching', () => {
it('should return null', () => {
should(mw('test', '/+')).equal(null);
});
it('should return null', () => {
should(mw('test', 'test/+')).equal(null);
});
it('should return null', () => {
should(mw('test/test', 'test/test/+')).equal(null);
});
});
it('should return the correct array', () => {
mw('test/test/test', 'test/+/test/#').should.arrayEqual(['test']);
});
});

describe('wildcard +/# mismatching', () => {
it('should return null', () => {
should(mw('test/foo/test', '+/test/#')).equal(null);
});
it('should return null', () => {
should(mw('foo/test/test', 'test/+/#')).equal(null);
});
it('should return null', () => {
should(mw('foo/test/test/test', 'test/+/+/#')).equal(null);
describe('wildcard +/# matching', () => {
it('should return the correct array', () => {
mw('test/test', '+/#').should.arrayEqual(['test', 'test']);
});
it('should return the correct array', () => {
mw('test/test/', '+/test/#').should.arrayEqual(['test', '']);
});
it('should return the correct array', () => {
mw('test/test/', 'test/+/#').should.arrayEqual(['test', '']);
});
it('should return the correct array', () => {
mw('test/test/test', '+/test/#').should.arrayEqual(['test', 'test']);
});
it('should return the correct array', () => {
mw('test/test/test', 'test/+/#').should.arrayEqual(['test', 'test']);
});
it('should return the correct array', () => {
mw('test/test/test', '+/+/#').should.arrayEqual(['test', 'test', 'test']);
});
it('should return the correct array', () => {
mw('test/test/test/test', 'test/+/+/#').should.arrayEqual(['test', 'test', 'test']);
});
it('should return the correct array', () => {
mw('test', '+/#').should.arrayEqual(['test']);
});
it('should return the correct array', () => {
mw('test/test', 'test/+/#').should.arrayEqual(['test']);
});
it('should return the correct array', () => {
mw('test/test/test', 'test/+/test/#').should.arrayEqual(['test']);
});
});
});

describe('examples', () => {
it('should return the correct array', () => {
should(mw('test/foo/bar', 'test/+/bar')).arrayEqual(['foo']);
});
it('should return the correct array', () => {
should(mw('test/foo/bar', 'test/#')).arrayEqual(['foo/bar']);
});
it('should return the correct array', () => {
should(mw('test/foo/bar/baz', 'test/+/#')).arrayEqual(['foo', 'bar/baz']);
describe('wildcard +/# mismatching', () => {
it('should return null', () => {
should(mw('test/foo/test', '+/test/#')).equal(null);
});
it('should return null', () => {
should(mw('foo/test/test', 'test/+/#')).equal(null);
});
it('should return null', () => {
should(mw('foo/test/test/test', 'test/+/+/#')).equal(null);
});
});
it('should return the correct array', () => {
should(mw('test/foo/bar/baz', 'test/+/+/baz')).arrayEqual(['foo', 'bar']);
});
it('should return the correct array', () => {
should(mw('test', 'test/#')).arrayEqual([]);
});
it('should return the correct array', () => {
should(mw('test/', 'test/#')).arrayEqual(['']);
});
it('should return the correct array', () => {
should(mw('test/foo/bar/baz', 'test/+/+/baz/#')).arrayEqual(['foo', 'bar']);
});
it('should return null', () => {
should(mw('test/foo/bar', 'test/+')).equal(null);
});
it('should return null', () => {
should(mw('test/foo/bar', 'test/nope/bar')).equal(null);

describe('examples', () => {
it('should return the correct array', () => {
should(mw('test/foo/bar', 'test/+/bar')).arrayEqual(['foo']);
});
it('should return the correct array', () => {
should(mw('test/foo/bar', 'test/#')).arrayEqual(['foo/bar']);
});
it('should return the correct array', () => {
should(mw('test/foo/bar/baz', 'test/+/#')).arrayEqual(['foo', 'bar/baz']);
});
it('should return the correct array', () => {
should(mw('test/foo/bar/baz', 'test/+/+/baz')).arrayEqual(['foo', 'bar']);
});
it('should return the correct array', () => {
should(mw('test', 'test/#')).arrayEqual([]);
});
it('should return the correct array', () => {
should(mw('test/', 'test/#')).arrayEqual(['']);
});
it('should return the correct array', () => {
should(mw('test/foo/bar/baz', 'test/+/+/baz/#')).arrayEqual(['foo', 'bar']);
});
it('should return null', () => {
should(mw('test/foo/bar', 'test/+')).equal(null);
});
it('should return null', () => {
should(mw('test/foo/bar', 'test/nope/bar')).equal(null);
});
});
});
2 changes: 1 addition & 1 deletion test/00 - nextport_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-unused-vars, unicorn/filename-case */
/* global describe, it, after, before, afterEach */
/* eslint-disable no-unused-vars */

const should = require('should');
const HmSim = require('hm-simulator/sim');
Expand Down
2 changes: 1 addition & 1 deletion test/context_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-unused-vars, unicorn/filename-case, max-nested-callbacks */
/* global describe, it, after, before, afterEach */
/* eslint-disable no-unused-vars */

const fs = require('fs');
const path = require('path');
Expand Down
Loading

0 comments on commit 808099b

Please sign in to comment.