it('should send messages to the custom logger', () => { let spyCallCount = 0 const data = { JSON: JSON.stringify({ name: 'env-var' }) } const env = mod.from(data, {}, (str) => { expect(str).to.be.a('string') spyCallCount++ }) const result = env.get('JSON').asJson() expect(result).to.deep.equal({ name: 'env-var' }) expect(spyCallCount).to.be.greaterThan(0) })
it('does not expire values in the background, by default', async () => { const store = new MemoryStore(); expect(store._interval).to.be.undefined; await store.set('key', 'value', { ttl: 10 }); expect(await store.get('key')).to.equal('value'); const item = store._store.get('key'); expect(item.expiration).to.be.greaterThan(Date.now()); clock.tick(20); expect(item.expiration).to.be.lessThan(Date.now()); expect(store._store.size).to.equal(1); });
describe('$sleep Suite', () => { it('should pause execution', async () => { const first = Date.now() await $sleep(10) const second = Date.now() expect(second - first).greaterThan(8) }) })
it('should be have time stamp when none given', function () { let sample = openBCIUtilities.parsePacketStandardAccel({ rawDataPacket: sampleBuf, channelSettings: defaultChannelSettingsArray, scale: true }); expect(sample.boardTime).to.equal(0); expect(sample.timestamp).to.be.greaterThan(0); });
it('removes expired values on attempted retrieval', async () => { const store = new MemoryStore(); await store.set('key', 'value', { ttl: 10 }); const spy = sinon.spy(store._store, 'delete'); expect(await store.get('key')).to.equal('value'); const item = store._store.get('key'); expect(item.expiration).to.be.greaterThan(Date.now()); clock.tick(20); expect(item.expiration).to.be.lessThan(Date.now()); expect(await store.get('key')).to.be.undefined; expect(spy.calledOnceWith('key')).to.be.true; });
describe('<NoteListItem />', function () { it('should render title and timestamp', function () { const title = 'Note title here' const updatedAt = 1503597714631 const wrapper = mount( <NoteListItem note={{title, updatedAt}}/> ) wrapper.find('h5').text().should.equal(title) wrapper.find('p').text().should.equal('8/24/17') }) it('should set default title if no title set', function () { const wrapper = mount( <NoteListItem note={{title: '', updatedAt: moment() }}/> ) wrapper.find('h5').text().length.should.be.greaterThan(0) }) })
it('should be able to set positive drift', function () { simulator = new OpenBCISimulator(portName, { drift: 1 }); expect(simulator.options.drift).to.be.greaterThan(0); });
describe("Get client wallet's transactions", function () { var clientWallets; var transactions; before(function (done) { api.Clients.getClientWallets(function (data, response) { clientWallets = data; api.Clients.getClientWalletTransactions(clientWallets[0].FundsType, clientWallets[0].Currency , function (data, response) { transactions = data; done(); }); }); }); it('should get transactions', function () { expect(transactions).not.to.be.undefined; expect(transactions.length).to.be.greaterThan(0); }) });
it('if expirationPoll option is provided, removes expired values even when not retrieved', async () => { const store = new MemoryStore({ expirationPoll: 5 }); expect(store._interval).to.be.ok; const spy = sinon.spy(store._store, 'delete'); await store.set('key', 'value', { ttl: 10 }); expect(await store.get('key')).to.equal('value'); const item = store._store.get('key'); expect(item.expiration).to.be.greaterThan(Date.now()); clock.tick(20); expect(item.expiration).to.be.lessThan(Date.now()); expect(store._store.size).to.equal(0); expect(spy.calledOnceWith('key')).to.be.true; });
describe('#find after update', () => { it('should find data as updated without errors', (done) => { models.instance.Person.find({ userID: 1234, age: 32 }, (err, people) => { if (err) done(err); people.length.should.equal(1); const person = people[0]; person.Name.should.equal('Stupid'); should.not.exist(person.info.hello); person.info.new.should.equal('addition'); person.phones.length.should.equal(1); person.phones[0].should.equal('56788'); person.emails.length.should.equal(1); person.emails[0].should.equal('c@d.com'); person.active.should.equal(false); person.timeId.toString().length.should.equal(36); should.exist(person.intSetDefault); should.exist(person.timestamp); // test auto timestamp fields should.exist(person.created_at); should.exist(person.updatedAt); (person.updatedAt - person.created_at).should.be.greaterThan(1); // test auto version fields person.__v.toString().length.should.equal(36); done(); }); }); });
describe('User API Tests', () => { it('should allow the user\'s available security questions to be listed', async () => { const newUser = { profile: utils.getMockProfile('user-list-available-security-questions'), credentials: { password: { value: 'Abcd1234' } } }; // Cleanup the user if user exists await utils.cleanup(client, newUser); const createdUser = await client.createUser(newUser); const questions = []; await createdUser.listSupportedSecurityQuestions().each(factor => questions.push(factor)); expect(questions.length).to.be.greaterThan(1); questions.forEach(factor => expect(factor).to.be.instanceof(models.SecurityQuestion)); return await utils.deleteUser(createdUser); }); });
it('should be have time stamp when none given', function () { packet1 = openBCIUtilities.samplePacketAccelTimeSynced(0); let sample = openBCIUtilities.parsePacketTimeSyncedAccel({ rawDataPacket: packet1, channelSettings: defaultChannelSettingsArray, scale: true }); expect(sample.boardTime).to.equal(1); expect(sample.timestamp).to.be.greaterThan(0); });
describe.only('PyPI', function() { var rawXML; var packageNames; it('should be able to fetch raw XML of recent packages feed', async function() { this.timeout(10000); rawXML = await PyPI.fetchXMLFromPyPI(); expect(rawXML).to.be.a('string'); }); it('should be able to parse package names out of the XML', async function() { packageNames = PyPI.parsePackageNamesFromXML(rawXML); expect(packageNames).to.be.an('array'); expect(packageNames.length).to.be.greaterThan(0); }); it('should be able to fetch the Github for a package', async function() { this.timeout(10000); var packageRepo = await PyPI.packageNameToRepo('cognite-sdk'); expect(packageRepo).to.equal('cognitedata/cognite-sdk-python'); }); it.skip('should upsert recent packages from the entry point', async function() { this.timeout(10000); await PyPI.upsertRecentPackageRepos(); }); });
it('should be able to make the internal clock of the simulator run fast', () => { let ourBoard1 = new Cyton({ simulatorInternalClockDrift: 1 }); expect(ourBoard1.options.simulatorInternalClockDrift).to.be.greaterThan(0); // Verify multi case support let ourBoard2 = new Cyton({ simulatorinternalclockdrift: 1 }); expect(ourBoard2.options.simulatorInternalClockDrift).to.be.greaterThan(0); });
describe('User API Tests', () => { it('should allow the user\'s factor catalog (supported factors) to be listed', async () => { const newUser = { profile: utils.getMockProfile('user-list-available-factors'), credentials: { password: { value: 'Abcd1234' } } }; // Cleanup the user if user exists await utils.cleanup(client, newUser); const createdUser = await client.createUser(newUser); const factors = []; await createdUser.listSupportedFactors().each(factor => factors.push(factor)); expect(factors.length).to.be.greaterThan(1); factors.forEach(factor => expect(factor).to.be.instanceof(models.UserFactor) ); return await utils.deleteUser(createdUser); }); });