suite(module_path, function () { test('throws an error if a `arenaId` is not 32 characters', cothunkify(function* () { var failed = false; try { under_test.arenaId.set('123456789'); failed = true; } catch (e) { expect(e).to.be.an.instanceOf(Error); expect(e.name).to.equal('RangeError'); expect(e.message).to.equal('Invalid Arena ID (123456789) specified.'); } finally { expect(failed).to.be.false; } failed = false; try { under_test.arenaId.set('123456789123456789123456789123456789'); failed = true; } catch (e) { expect(e).to.be.an.instanceOf(Error); expect(e.name).to.equal('RangeError'); expect(e.message).to.equal('Invalid Arena ID (123456789123456789123456789123456789) specified.'); } finally { expect(failed).to.be.false; } })); test('returns the `arenaId` if it is 32 characters', cothunkify(function* () { expect(under_test.arenaId.set('12345678912345678912345678912345')).to.equal('12345678912345678912345678912345'); })); });
describe('su-apisession/cache', function() { it('should cache a response if it\'s valid', cothunkify(function* () { token = yield session.set(sessionData); yield underTest.set.call({ data : { foo : 'bar' }, su : { req : { xcsrf : token } }, request : { method : 'GET', url : '/foo/bar' }, status : 200 }, function* () {}); var data = yield session.getCached(token, 'GET:/foo/bar'); expect(data.data).to.deep.equal({ foo : 'bar' }); })); it('should get the `cached` data on the context if there iseses one', cothunkify(function* () { var ctx = { su : { req : { xcsrf : token } }, request : { method : 'GET', url : '/foo/bar' } }; yield underTest.get.call(ctx, function* () {}); expect(ctx.su.req.cached.data).to.deep.equal({ foo : 'bar' }); })); });