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

Back out arrow functions for Mocha tests #6927

Merged
merged 2 commits into from
Sep 8, 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
14 changes: 7 additions & 7 deletions test/core/core.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { extend } from '../../src/core/core.js';

import { expect } from 'chai';

describe('core', () => {
describe('core', function () {

describe('#extend', () => {
describe('#extend', function () {

it('combines two objects', () => {
it('combines two objects', function () {
const o1 = {
a: 'a',
b: 'b'
Expand All @@ -24,7 +24,7 @@ describe('core', () => {
expect(o3.d).to.equal('d');
});

it('combines two arrays', () => {
it('combines two arrays', function () {
const a1 = [1, 2, 3];
const a2 = [4, 5, 6];

Expand All @@ -35,7 +35,7 @@ describe('core', () => {
expect(a3[2]).to.equal(a2[2]);
});

it('combines and object and an array', () => {
it('combines and object and an array', function () {
const o1 = { a: 'a' };
const a1 = [1, 2];

Expand All @@ -45,7 +45,7 @@ describe('core', () => {
expect(o2[1]).to.equal(2);
});

it('deep combines two objects', () => {
it('deep combines two objects', function () {
const o1 = {
A: 'A'
};
Expand All @@ -62,7 +62,7 @@ describe('core', () => {
expect(o3.A).to.equal('A');
});

it('deep combines two objects and does not copy references', () => {
it('deep combines two objects and does not copy references', function () {
const o1 = {
A: 'A'
};
Expand Down
34 changes: 17 additions & 17 deletions test/core/event-handler.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@ import { EventHandler } from '../../src/core/event-handler.js';

import { expect } from 'chai';

describe('EventHandler', () => {
describe('EventHandler', function () {

describe('#hasEvent', () => {
describe('#hasEvent', function () {

it('returns true if the event is registered', () => {
it('returns true if the event is registered', function () {
const e = new EventHandler();
e.on('test', () => { });
e.on('test', function () { });
expect(e.hasEvent('test')).to.be.true;
});

it('returns false if the event is not registered', () => {
it('returns false if the event is not registered', function () {
const e = new EventHandler();
e.on('test', () => { });
e.on('test', function () { });
expect(e.hasEvent('hello')).to.be.false;
});

});

describe('#on', () => {
describe('#on', function () {

it('calls handler on fire', () => {
it('calls handler on fire', function () {
const e = new EventHandler();
let called = false;
e.on('test', () => {
e.on('test', function () {
called = true;
});
e.fire('test');
expect(called).to.be.true;
});

it('calls handler with up to 8 arguments on fire', () => {
it('calls handler with up to 8 arguments on fire', function () {
const e = new EventHandler();
let called = false;
e.on('test', (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => {
Expand All @@ -53,12 +53,12 @@ describe('EventHandler', () => {

});

describe('#once', () => {
describe('#once', function () {

it('unregisters itself after the first fire', () => {
it('unregisters itself after the first fire', function () {
const e = new EventHandler();
let count = 0;
e.once('test', () => {
e.once('test', function () {
count++;
});
expect(e.hasEvent('test')).to.be.true;
Expand All @@ -70,7 +70,7 @@ describe('EventHandler', () => {

});

describe('#off', () => {
describe('#off', function () {

it('unregisters event handler with specified callback and scope', function () {
const e = new EventHandler();
Expand All @@ -86,7 +86,7 @@ describe('EventHandler', () => {
expect(called).to.be.false;
});

it('unregisters event handler with specified callback', () => {
it('unregisters event handler with specified callback', function () {
const e = new EventHandler();
let called = false;
const callback = function () {
Expand All @@ -100,10 +100,10 @@ describe('EventHandler', () => {
expect(called).to.be.false;
});

it('unregisters all event handlers', () => {
it('unregisters all event handlers', function () {
const e = new EventHandler();
let called = false;
e.on('test', () => {
e.on('test', function () {
called = true;
});
expect(e.hasEvent('test')).to.be.true;
Expand Down
10 changes: 5 additions & 5 deletions test/core/guid.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import { guid } from '../../src/core/guid.js';

import { expect } from 'chai';

describe('guid', () => {
describe('guid', function () {

describe('#create', () => {
describe('#create', function () {

it('returns a string', () => {
it('returns a string', function () {
expect(guid.create()).to.be.a('string');
});

it('returns a string of length 36', () => {
it('returns a string of length 36', function () {
expect(guid.create()).to.have.length(36);
});

it('returns different values each time', () => {
it('returns different values each time', function () {
expect(guid.create()).to.not.equal(guid.create());
});

Expand Down
14 changes: 7 additions & 7 deletions test/core/hash.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ import { hashCode, hash32Fnv1a } from '../../src/core/hash.js';

import { expect } from 'chai';

describe('hashCode', () => {
describe('hashCode', function () {

it('returns 0 for the empty string', () => {
it('returns 0 for the empty string', function () {
expect(hashCode('')).to.equal(0);
});

it('returns the same hash for the same string', () => {
it('returns the same hash for the same string', function () {
expect(hashCode('abc')).to.equal(hashCode('abc'));
});

it('returns different hashes for different strings', () => {
it('returns different hashes for different strings', function () {
expect(hashCode('abc')).to.not.equal(hashCode('def'));
});

});

describe('[1, 2, 3]', () => {
describe('[1, 2, 3]', function () {

it('returns the same hash for the same arrays', () => {
it('returns the same hash for the same arrays', function () {
expect(hash32Fnv1a([1, 2, 3])).to.equal(hash32Fnv1a([1, 2, 3]));
});

it('returns different hashes for different arrays', () => {
it('returns different hashes for different arrays', function () {
expect(hash32Fnv1a([1, 2, 3])).to.not.equal(hash32Fnv1a([3, 2, 1]));
});

Expand Down
36 changes: 18 additions & 18 deletions test/core/indexed-list.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import { IndexedList } from '../../src/core/indexed-list.js';

import { expect } from 'chai';

describe('IndexedList', () => {
describe('IndexedList', function () {

describe('#constructor', () => {
describe('#constructor', function () {

it('creates an empty list', () => {
it('creates an empty list', function () {
const list = new IndexedList();

expect(list.list().length).to.equal(0);
});

});

describe('#clear', () => {
describe('#clear', function () {

it('removes all values', () => {
it('removes all values', function () {
const list = new IndexedList();

const key1 = 'key1';
Expand Down Expand Up @@ -58,9 +58,9 @@ describe('IndexedList', () => {

});

describe('#has', () => {
describe('#has', function () {

it('returns true if the key exists', () => {
it('returns true if the key exists', function () {
const list = new IndexedList();

const key1 = 'key1';
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('IndexedList', () => {
expect(list.has(key5)).to.equal(true);
});

it('returns false if the key does not exist', () => {
it('returns false if the key does not exist', function () {
const list = new IndexedList();

const key1 = 'key1';
Expand Down Expand Up @@ -118,9 +118,9 @@ describe('IndexedList', () => {

});

describe('#push', () => {
describe('#push', function () {

it('adds an key-value pair to the list', () => {
it('adds an key-value pair to the list', function () {
const list = new IndexedList();

const key = 'key';
Expand All @@ -136,9 +136,9 @@ describe('IndexedList', () => {

});

describe('#get', () => {
describe('#get', function () {

it('returns the value for the key', () => {
it('returns the value for the key', function () {
const list = new IndexedList();

const key = 'key';
Expand All @@ -149,7 +149,7 @@ describe('IndexedList', () => {
expect(list.get(key)).to.equal(value);
});

it('returns null if the key does not exist', () => {
it('returns null if the key does not exist', function () {
const list = new IndexedList();

const key = 'key';
Expand All @@ -163,9 +163,9 @@ describe('IndexedList', () => {

});

describe('#list', () => {
describe('#list', function () {

it('returns list in order', () => {
it('returns list in order', function () {
const list = new IndexedList();

const key1 = 'key1';
Expand Down Expand Up @@ -197,9 +197,9 @@ describe('IndexedList', () => {

});

describe('#remove', () => {
describe('#remove', function () {

it('removes the key', () => {
it('removes the key', function () {
const list = new IndexedList();

const key = 'key';
Expand All @@ -213,7 +213,7 @@ describe('IndexedList', () => {
});


it('does not affect surrounding keys', () => {
it('does not affect surrounding keys', function () {
const list = new IndexedList();

const key1 = 'key1';
Expand Down
18 changes: 9 additions & 9 deletions test/core/math/bit-packing.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { BitPacking } from '../../../src/core/math/bit-packing.js';

import { expect } from 'chai';

describe('BitPacking', () => {
describe('BitPacking', function () {

describe('#set', () => {
describe('#set', function () {

it('sets bits', () => {
it('sets bits', function () {

let d = 0;
d = BitPacking.set(d, 0b11, 1, 0b11);
Expand All @@ -18,8 +18,8 @@ describe('BitPacking', () => {
});
});

describe('#get', () => {
it('gets bits', () => {
describe('#get', function () {
it('gets bits', function () {

const d = 0b110011;
expect(BitPacking.get(d, 0, 0b111111)).to.equal(d);
Expand All @@ -29,8 +29,8 @@ describe('BitPacking', () => {
});
});

describe('#any', () => {
it('any', () => {
describe('#any', function () {
it('any', function () {

const d = 0b110011;
expect(BitPacking.any(d, 0, 0b111111)).to.equal(true);
Expand All @@ -39,8 +39,8 @@ describe('BitPacking', () => {
});
});

describe('#all', () => {
it('all', () => {
describe('#all', function () {
it('all', function () {

const d = 0b110011;
expect(BitPacking.all(d, 0, 0b111111)).to.equal(false);
Expand Down
Loading