fix(core): update
This commit is contained in:
@ -4,7 +4,7 @@ import * as lik from '../ts/index';
|
||||
let testInterestmap: lik.InterestMap<number, number>;
|
||||
|
||||
tap.test('should create an interestmap', async () => {
|
||||
testInterestmap = new lik.InterestMap(numberArg => {
|
||||
testInterestmap = new lik.InterestMap((numberArg) => {
|
||||
return numberArg.toString();
|
||||
});
|
||||
});
|
||||
|
78
test/test.objectmap.browser.ts
Normal file
78
test/test.objectmap.browser.ts
Normal file
@ -0,0 +1,78 @@
|
||||
// import test framework
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as events from 'events';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
// import the module
|
||||
import * as lik from '../ts/index';
|
||||
|
||||
// Objectmap
|
||||
interface ITestObject {
|
||||
propOne: string;
|
||||
propTwo: string;
|
||||
}
|
||||
let testObjectmap: lik.ObjectMap<ITestObject>;
|
||||
let testObject1: ITestObject = {
|
||||
propOne: 'hello',
|
||||
propTwo: 'hello2',
|
||||
};
|
||||
let testObject2: ITestObject = {
|
||||
propOne: 'hello',
|
||||
propTwo: 'hello2',
|
||||
};
|
||||
|
||||
tap.test('new lik.Objectmap() -> should correctly instantiate an Objectmap', async () => {
|
||||
testObjectmap = new lik.ObjectMap<ITestObject>();
|
||||
expect(testObjectmap).be.instanceof(lik.ObjectMap);
|
||||
});
|
||||
|
||||
tap.test('lik.Objectmap.add() -> should correctly add an object to Objectmap', async () => {
|
||||
testObjectmap.add(testObject1);
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject1)).be.true;
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject2)).be.false;
|
||||
});
|
||||
|
||||
tap.test('lik.Objectmap.remove() -> should correctly remove an object to Objectmap', async () => {
|
||||
testObjectmap.add(testObject2);
|
||||
testObjectmap.remove(testObject1);
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject1)).be.false;
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObjectmap.checkForObject(testObject2)).be.true;
|
||||
});
|
||||
|
||||
tap.test('Objectmap.forEach -> should correctly run a function forEach map object', async () => {
|
||||
testObjectmap.forEach((itemArg) => {
|
||||
expect(itemArg).to.have.property('propOne');
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('lik.Objectmap.find() -> should correctly find an object', async () => {
|
||||
let myObject = { propOne: 'helloThere', propTwo: 'helloAnyway' };
|
||||
testObjectmap.add(myObject);
|
||||
let referenceObject = testObjectmap.find((itemArg) => {
|
||||
return itemArg.propOne === 'helloThere';
|
||||
});
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(myObject === referenceObject).be.true;
|
||||
});
|
||||
|
||||
tap.test('lik.Objectmap.getArray() -> should return a cloned array', async () => {
|
||||
let myObject = { propOne: 'test1', propTwo: 'wow, how awesome' };
|
||||
testObjectmap.add(myObject);
|
||||
let clonedArray = testObjectmap.getArray();
|
||||
expect(clonedArray[clonedArray.length - 1]).to.eql(myObject);
|
||||
});
|
||||
|
||||
tap.test('should get one object and then remove it', async () => {
|
||||
let originalLength = testObjectmap.getArray().length;
|
||||
let oneObject = testObjectmap.getOneAndRemove();
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(oneObject).not.be.null;
|
||||
expect(testObjectmap.getArray().length).equal(originalLength - 1);
|
||||
expect(testObjectmap.getArray()).to.not.contain(oneObject);
|
||||
});
|
||||
|
||||
tap.start();
|
@ -14,11 +14,11 @@ interface ITestObject {
|
||||
let testObjectmap: lik.ObjectMap<ITestObject>;
|
||||
let testObject1: ITestObject = {
|
||||
propOne: 'hello',
|
||||
propTwo: 'hello2'
|
||||
propTwo: 'hello2',
|
||||
};
|
||||
let testObject2: ITestObject = {
|
||||
propOne: 'hello',
|
||||
propTwo: 'hello2'
|
||||
propTwo: 'hello2',
|
||||
};
|
||||
|
||||
tap.test('new lik.Objectmap() -> should correctly instantiate an Objectmap', async () => {
|
||||
@ -44,7 +44,7 @@ tap.test('lik.Objectmap.remove() -> should correctly remove an object to Objectm
|
||||
});
|
||||
|
||||
tap.test('Objectmap.forEach -> should correctly run a function forEach map object', async () => {
|
||||
testObjectmap.forEach(itemArg => {
|
||||
testObjectmap.forEach((itemArg) => {
|
||||
expect(itemArg).to.have.property('propOne');
|
||||
});
|
||||
});
|
||||
@ -52,7 +52,7 @@ tap.test('Objectmap.forEach -> should correctly run a function forEach map objec
|
||||
tap.test('lik.Objectmap.find() -> should correctly find an object', async () => {
|
||||
let myObject = { propOne: 'helloThere', propTwo: 'helloAnyway' };
|
||||
testObjectmap.add(myObject);
|
||||
let referenceObject = testObjectmap.find(itemArg => {
|
||||
let referenceObject = testObjectmap.find((itemArg) => {
|
||||
return itemArg.propOne === 'helloThere';
|
||||
});
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
|
@ -8,12 +8,12 @@ import * as lik from '../ts/index';
|
||||
|
||||
let testTimedAggregator: lik.TimedAggregtor<string>;
|
||||
|
||||
tap.test('should create a timed aggregaotor', async tools => {
|
||||
tap.test('should create a timed aggregaotor', async (tools) => {
|
||||
testTimedAggregator = new lik.TimedAggregtor<string>({
|
||||
aggregationIntervalInMillis: 1000,
|
||||
functionForAggregation: aggregation => {
|
||||
functionForAggregation: (aggregation) => {
|
||||
console.log(aggregation);
|
||||
}
|
||||
},
|
||||
});
|
||||
testTimedAggregator.add('This');
|
||||
testTimedAggregator.add('is a whole sentence.');
|
||||
|
@ -1 +0,0 @@
|
||||
import './test.objectmap';
|
Reference in New Issue
Block a user