update to latest standards

This commit is contained in:
Phil Kunz
2018-03-05 00:57:41 +01:00
parent 1644a9c0de
commit 53ee39a4aa
10 changed files with 159 additions and 249 deletions

View File

@ -1,46 +1,46 @@
import { expect, tap } from 'tapbundle'
import * as smartcls from '../ts/index'
import * as smartstring from 'smartstring'
import { expect, tap } from 'tapbundle';
import * as smartcls from '../ts/index';
import * as smartstring from 'smartstring';
smartcls.createNamespace('myspace')
let testNamespace = smartcls.getNamespace('myspace')
smartcls.createNamespace('myspace');
let testNamespace = smartcls.getNamespace('myspace');
tap.testParallel('should get namespace', async (tools) => {
tap.testParallel('should get namespace', async tools => {
testNamespace.run(async () => {
testNamespace.set('some', 'anything')
await tools.delayFor(1000)
expect(testNamespace.get('some')).to.equal('anything')
testNamespace.set('some', 'anything');
await tools.delayFor(1000);
expect(testNamespace.get('some')).to.equal('anything');
tools.delayFor(200).then(() => {
expect(testNamespace.get('some')).to.equal('anything')
})
})
})
expect(testNamespace.get('some')).to.equal('anything');
});
});
});
tap.testParallel('should get namespace with other values', async (tools) => {
tap.testParallel('should get namespace with other values', async tools => {
testNamespace.run(async () => {
testNamespace.set('some', 'otherthing')
await tools.delayFor(500)
expect(testNamespace.get('some')).to.equal('otherthing')
testNamespace.set('some', 'otherthing');
await tools.delayFor(500);
expect(testNamespace.get('some')).to.equal('otherthing');
tools.delayFor(200).then(() => {
expect(testNamespace.get('some')).to.equal('otherthing')
})
})
})
expect(testNamespace.get('some')).to.equal('otherthing');
});
});
});
tap.test('should not expose memory leak', async (tools) => {
let testArray = []
tap.test('should not expose memory leak', async tools => {
let testArray = [];
await tools.checkIterationLeak(async () => {
testNamespace.run(async () => {
let randomLargeString = smartstring.create.createRandomString('*', 10000, {})
let randomLargeString = smartstring.create.createRandomString('*', 10000, {});
// testArray.push(randomLargeString) // trigger memory leak
testNamespace.set('some', randomLargeString )
await tools.delayFor(10)
expect(testNamespace.get('some')).to.equal(randomLargeString)
testNamespace.set('some', randomLargeString);
await tools.delayFor(10);
expect(testNamespace.get('some')).to.equal(randomLargeString);
tools.delayFor(10).then(() => {
expect(testNamespace.get('some')).to.equal(randomLargeString)
})
})
})
})
expect(testNamespace.get('some')).to.equal(randomLargeString);
});
});
});
});
tap.start()
tap.start();