Update prettier and reformat code
This commit is contained in:
@ -4,23 +4,23 @@ import { expect } from 'chai';
|
||||
import { Resources } from '../../src/Core/Resources';
|
||||
import { calcGatheringTimings, GatheringTimings } from '../../src/Core/GatheringTimings';
|
||||
|
||||
describe('Gathering timings', function() {
|
||||
it('Can calc common from numbers', function() {
|
||||
describe('Gathering timings', function () {
|
||||
it('Can calc common from numbers', function () {
|
||||
const timings = GatheringTimings.create(10, 20, 15, 5);
|
||||
expect(20).to.equals(timings.slowest.seconds);
|
||||
});
|
||||
|
||||
it('Can calc common with never', function() {
|
||||
it('Can calc common with never', function () {
|
||||
const timings = GatheringTimings.create(10, 20, 'never', 5);
|
||||
expect(true).to.equals(timings.slowest.never);
|
||||
});
|
||||
|
||||
it('Can calc common with all never', function() {
|
||||
it('Can calc common with all never', function () {
|
||||
const timings = GatheringTimings.create('never', 'never', 'never', 'never');
|
||||
expect(true).to.equals(timings.slowest.never);
|
||||
});
|
||||
|
||||
it('Can calc timings', function() {
|
||||
it('Can calc timings', function () {
|
||||
const resources = new Resources(10, 10, 10, 10);
|
||||
const desired = new Resources(60, 60, 60, 60);
|
||||
const speed = new Resources(5, 5, 5, 5);
|
||||
@ -28,7 +28,7 @@ describe('Gathering timings', function() {
|
||||
expect(10 * 3600).to.equals(timings.slowest.seconds);
|
||||
});
|
||||
|
||||
it('Can calc timings with different speed', function() {
|
||||
it('Can calc timings with different speed', function () {
|
||||
const resources = new Resources(10, 10, 10, 10);
|
||||
const desired = new Resources(60, 60, 60, 60);
|
||||
const speed = new Resources(5, 10, 25, 5);
|
||||
@ -40,7 +40,7 @@ describe('Gathering timings', function() {
|
||||
expect(10 * 3600).to.equals(timings.slowest.seconds);
|
||||
});
|
||||
|
||||
it('Can calc timings with negative speed', function() {
|
||||
it('Can calc timings with negative speed', function () {
|
||||
const resources = new Resources(10, 10, 10, 10);
|
||||
const desired = new Resources(60, 60, 60, 60);
|
||||
const speed = new Resources(5, 10, 25, -5);
|
||||
|
@ -5,14 +5,14 @@ import { calcHeroResource } from '../../src/Core/HeroBalance';
|
||||
import { Resources } from '../../src/Core/Resources';
|
||||
import { ResourceType } from '../../src/Core/ResourceType';
|
||||
|
||||
describe('HeroBalance', function() {
|
||||
it('Get resource for single requirement', function() {
|
||||
describe('HeroBalance', function () {
|
||||
it('Get resource for single requirement', function () {
|
||||
const req = new Resources(0, 0, -100, 0);
|
||||
const heroRes = calcHeroResource([req]);
|
||||
expect(heroRes).to.equals(ResourceType.Iron);
|
||||
});
|
||||
|
||||
it('Get resource for second requirement', function() {
|
||||
it('Get resource for second requirement', function () {
|
||||
const req1 = new Resources(0, 0, 100, 0);
|
||||
const req2 = new Resources(0, -200, 20, 0);
|
||||
const heroRes = calcHeroResource([req1, req2]);
|
||||
|
@ -3,45 +3,45 @@ import { expect } from 'chai';
|
||||
|
||||
import { Resources } from '../../src/Core/Resources';
|
||||
|
||||
describe('Resources', function() {
|
||||
it('Can compare with lt', function() {
|
||||
describe('Resources', function () {
|
||||
it('Can compare with lt', function () {
|
||||
const x = new Resources(0, 0, 0, 0);
|
||||
const y = new Resources(5, 5, 5, 5);
|
||||
expect(x.anyLower(y)).is.true;
|
||||
});
|
||||
|
||||
it('Can compare with lt (mixed)', function() {
|
||||
it('Can compare with lt (mixed)', function () {
|
||||
const x = new Resources(20, 20, 5, 20);
|
||||
const y = new Resources(10, 10, 10, 10);
|
||||
expect(x.anyLower(y)).is.true;
|
||||
});
|
||||
|
||||
it('Can compare with gt', function() {
|
||||
it('Can compare with gt', function () {
|
||||
const x = new Resources(5, 5, 5, 5);
|
||||
const y = new Resources(0, 0, 0, 0);
|
||||
expect(x.allGreater(y)).is.true;
|
||||
});
|
||||
|
||||
it('Can compare with gt (mixed)', function() {
|
||||
it('Can compare with gt (mixed)', function () {
|
||||
const x = new Resources(30, 30, 10, 30);
|
||||
const y = new Resources(20, 20, 20, 20);
|
||||
expect(x.allGreater(y)).is.false;
|
||||
});
|
||||
|
||||
it('Can up to 1', function() {
|
||||
it('Can up to 1', function () {
|
||||
const resources = new Resources(0, 4, 10, 18);
|
||||
const upped = resources.upTo(1);
|
||||
expect(upped.eq(resources)).is.true;
|
||||
});
|
||||
|
||||
it('Can up to 10', function() {
|
||||
it('Can up to 10', function () {
|
||||
const resources = new Resources(0, 4, 10, 18);
|
||||
const expected = new Resources(0, 10, 10, 20);
|
||||
const upped = resources.upTo(10);
|
||||
expect(upped.eq(expected)).is.true;
|
||||
});
|
||||
|
||||
it('Can down to 10', function() {
|
||||
it('Can down to 10', function () {
|
||||
const resources = new Resources(0, 4, 10, 18);
|
||||
const expected = new Resources(0, 0, 10, 10);
|
||||
const lowed = resources.downTo(10);
|
||||
|
@ -2,36 +2,36 @@ import { it, describe } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { elClassId, getNumber } from '../../src/Helpers/Convert';
|
||||
|
||||
describe('Utils', function() {
|
||||
describe('getNumber', function() {
|
||||
it('Can parse positive number', function() {
|
||||
describe('Utils', function () {
|
||||
describe('getNumber', function () {
|
||||
it('Can parse positive number', function () {
|
||||
const text = '123';
|
||||
expect(getNumber(text)).to.be.equals(123);
|
||||
});
|
||||
|
||||
it('Can parse positive number with noise', function() {
|
||||
it('Can parse positive number with noise', function () {
|
||||
const text = ' 123 ';
|
||||
expect(getNumber(text)).to.be.equals(123);
|
||||
});
|
||||
|
||||
it('Can parse negative number', function() {
|
||||
it('Can parse negative number', function () {
|
||||
const text = '-146';
|
||||
expect(getNumber(text)).to.be.equals(-146);
|
||||
});
|
||||
|
||||
it('Can parse negative number with minus sign', function() {
|
||||
it('Can parse negative number with minus sign', function () {
|
||||
const text = '\u2212132';
|
||||
expect(getNumber(text)).to.be.equals(-132);
|
||||
});
|
||||
});
|
||||
|
||||
describe('elClassId', function() {
|
||||
it('Can parse number with prefix', function() {
|
||||
describe('elClassId', function () {
|
||||
it('Can parse number with prefix', function () {
|
||||
const text = 'foo bar12 baz';
|
||||
expect(elClassId(text, 'bar')).to.be.equals(12);
|
||||
});
|
||||
|
||||
it('Can parse number from parts with same prefix', function() {
|
||||
it('Can parse number from parts with same prefix', function () {
|
||||
const text = 'foo12 foobar';
|
||||
expect(elClassId(text, 'foo')).to.be.equals(12);
|
||||
});
|
||||
|
@ -2,28 +2,28 @@ import { it, describe } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { path, uniqPaths } from '../../src/Helpers/Path';
|
||||
|
||||
describe('Path', function() {
|
||||
it('Can build path with empty query', function() {
|
||||
describe('Path', function () {
|
||||
it('Can build path with empty query', function () {
|
||||
const p = path('/info.php');
|
||||
expect(p).to.be.equals('/info.php');
|
||||
});
|
||||
|
||||
it('Can build path with query', function() {
|
||||
it('Can build path with query', function () {
|
||||
const p = path('/info.php', { foo: 'bar' });
|
||||
expect(p).to.be.equals('/info.php?foo=bar');
|
||||
});
|
||||
|
||||
it('Can build path with complex query', function() {
|
||||
it('Can build path with complex query', function () {
|
||||
const p = path('/info.php', { a: 'x', b: 'y', c: 5 });
|
||||
expect(p).to.be.equals('/info.php?a=x&b=y&c=5');
|
||||
});
|
||||
|
||||
it('Can build path with query (undefined part)', function() {
|
||||
it('Can build path with query (undefined part)', function () {
|
||||
const p = path('/info.php', { foo: 'bar', foobar: undefined });
|
||||
expect(p).to.be.equals('/info.php?foo=bar');
|
||||
});
|
||||
|
||||
it('Can keep uniq paths', function() {
|
||||
it('Can keep uniq paths', function () {
|
||||
const p1 = { name: '/info.php', query: { a: 'b' } };
|
||||
const p2 = { name: '/info.php', query: { a: 'b' } };
|
||||
const up = uniqPaths([p1, p2]);
|
||||
|
@ -15,15 +15,15 @@ class MemoryStatisticsStorage implements StatisticsStorageInterface {
|
||||
}
|
||||
}
|
||||
|
||||
describe('Statistics', function() {
|
||||
it('Can save statistics item', function() {
|
||||
describe('Statistics', function () {
|
||||
it('Can save statistics item', function () {
|
||||
const storage = new MemoryStatisticsStorage();
|
||||
const statistics = new Statistics(storage);
|
||||
statistics.incrementAction(1588408294);
|
||||
expect(Object.keys(statistics.getActionStatistics())).to.has.lengthOf(1);
|
||||
});
|
||||
|
||||
it('Can trim statistics', function() {
|
||||
it('Can trim statistics', function () {
|
||||
const storage = new MemoryStatisticsStorage();
|
||||
const statistics = new Statistics(storage);
|
||||
const baseTime = 1588408294;
|
||||
|
@ -6,34 +6,34 @@ import { NullLogger } from '../../src/Logger';
|
||||
import { ArrayTaskProvider } from '../../src/Queue/TaskProvider/ArrayTaskProvider';
|
||||
import { Task } from '../../src/Queue/Task';
|
||||
|
||||
describe('Task Queue', function() {
|
||||
it('Can get task from queue', function() {
|
||||
describe('Task Queue', function () {
|
||||
it('Can get task from queue', function () {
|
||||
const provider = new ArrayTaskProvider([new Task('1', 0, 'task', {})]);
|
||||
const queue = new TaskQueue(provider, new NullLogger());
|
||||
const task = queue.get(1);
|
||||
expect(task).to.be.instanceOf(Task);
|
||||
});
|
||||
|
||||
it("Don't get unready task from queue", function() {
|
||||
it("Don't get unready task from queue", function () {
|
||||
const provider = new ArrayTaskProvider([new Task('1', 5, 'task', {})]);
|
||||
const queue = new TaskQueue(provider, new NullLogger());
|
||||
const task = queue.get(1);
|
||||
expect(task).to.be.undefined;
|
||||
});
|
||||
|
||||
it('Can remove task by id', function() {
|
||||
it('Can remove task by id', function () {
|
||||
const provider = new ArrayTaskProvider([
|
||||
new Task('id1', 1, 'task1', {}),
|
||||
new Task('id2', 2, 'task2', {}),
|
||||
]);
|
||||
const queue = new TaskQueue(provider, new NullLogger());
|
||||
queue.remove(t => t.id === 'id1');
|
||||
queue.remove((t) => t.id === 'id1');
|
||||
const tasks = provider.getTasks();
|
||||
expect(tasks).to.have.lengthOf(1);
|
||||
expect(tasks[0].ts).to.be.equals(2);
|
||||
});
|
||||
|
||||
it('Can modify tasks', function() {
|
||||
it('Can modify tasks', function () {
|
||||
const provider = new ArrayTaskProvider([
|
||||
new Task('1', 1, 'task1', {}),
|
||||
new Task('2', 3, 'task2', {}),
|
||||
@ -41,8 +41,8 @@ describe('Task Queue', function() {
|
||||
]);
|
||||
const queue = new TaskQueue(provider, new NullLogger());
|
||||
queue.modify(
|
||||
t => t.ts < 4,
|
||||
t => new Task(t.id, 10, t.name, t.args)
|
||||
(t) => t.ts < 4,
|
||||
(t) => new Task(t.id, 10, t.name, t.args)
|
||||
);
|
||||
const tasks = provider.getTasks();
|
||||
expect(4).is.equals(tasks[0].ts);
|
||||
|
Reference in New Issue
Block a user