mirror of
https://github.com/bower/bower.git
synced 2026-04-24 03:00:19 -04:00
Merge branch 'master' of github.com:bower/registry-client
This commit is contained in:
@@ -30,7 +30,7 @@ Available constructor options:
|
||||
|
||||
|
||||
Note that `force` and `offline` are mutually exclusive.
|
||||
The cache will speedup operations such as `lookup` and `info`.
|
||||
The cache will speedup operations such as `list`, `lookup` and `search`.
|
||||
Different operations may have different cache expiration times.
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
"mkdirp": "~0.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "~1.7.2",
|
||||
"expect.js": "~0.2.0",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-contrib-watch": "~0.4.4",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
var RegistryClient = require('../Client'),
|
||||
expect = require('chai').expect,
|
||||
fs = require('fs'),
|
||||
expect = require('expect.js'),
|
||||
nock = require('nock');
|
||||
|
||||
describe('RegistryClient', function () {
|
||||
@@ -26,19 +27,19 @@ describe('RegistryClient', function () {
|
||||
});
|
||||
|
||||
it('should set default registry config', function () {
|
||||
expect(this.registry._config.registry).to.deep.equal(this.conf);
|
||||
expect(this.registry._config.registry).to.eql(this.conf);
|
||||
});
|
||||
|
||||
it('should set default search config', function () {
|
||||
expect(this.registry._config.registry.search[0]).to.equal(this.uri);
|
||||
expect(this.registry._config.registry.search[0]).to.eql(this.uri);
|
||||
});
|
||||
|
||||
it('should set default register config', function () {
|
||||
expect(this.registry._config.registry.register).to.equal(this.uri);
|
||||
expect(this.registry._config.registry.register).to.eql(this.uri);
|
||||
});
|
||||
|
||||
it('should set default publish config', function () {
|
||||
expect(this.registry._config.registry.publish).to.equal(this.uri);
|
||||
expect(this.registry._config.registry.publish).to.eql(this.uri);
|
||||
});
|
||||
|
||||
it('should set default cache path config', function () {
|
||||
@@ -46,7 +47,7 @@ describe('RegistryClient', function () {
|
||||
});
|
||||
|
||||
it('should set default timeout config', function () {
|
||||
expect(this.registry._config.timeout).to.equal(this.timeoutVal);
|
||||
expect(this.registry._config.timeout).to.eql(this.timeoutVal);
|
||||
});
|
||||
|
||||
it('should set default strictSsl config', function () {
|
||||
@@ -56,31 +57,31 @@ describe('RegistryClient', function () {
|
||||
});
|
||||
|
||||
it('should have a lookup prototype method', function () {
|
||||
expect(RegistryClient.prototype).to.have.ownProperty('lookup');
|
||||
expect(RegistryClient.prototype).to.have.property('lookup');
|
||||
});
|
||||
|
||||
it('should have a search prototype method', function () {
|
||||
expect(RegistryClient.prototype).to.have.ownProperty('search');
|
||||
expect(RegistryClient.prototype).to.have.property('search');
|
||||
});
|
||||
|
||||
it('should have a list prototype method', function () {
|
||||
expect(RegistryClient.prototype).to.have.ownProperty('list');
|
||||
expect(RegistryClient.prototype).to.have.property('list');
|
||||
});
|
||||
|
||||
it('should have a register prototype method', function () {
|
||||
expect(RegistryClient.prototype).to.have.ownProperty('register');
|
||||
expect(RegistryClient.prototype).to.have.property('register');
|
||||
});
|
||||
|
||||
it('should have a clearCache prototype method', function () {
|
||||
expect(RegistryClient.prototype).to.have.ownProperty('clearCache');
|
||||
expect(RegistryClient.prototype).to.have.property('clearCache');
|
||||
});
|
||||
|
||||
it('should have a resetCache prototype method', function () {
|
||||
expect(RegistryClient.prototype).to.have.ownProperty('resetCache');
|
||||
expect(RegistryClient.prototype).to.have.property('resetCache');
|
||||
});
|
||||
|
||||
it('should have a clearRuntimeCache static method', function () {
|
||||
expect(RegistryClient).to.have.ownProperty('clearRuntimeCache');
|
||||
expect(RegistryClient).to.have.property('clearRuntimeCache');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -94,12 +95,68 @@ describe('RegistryClient', function () {
|
||||
|
||||
this.registry.search('jquery', function (err, results) {
|
||||
expect(err).to.be.null;
|
||||
expect(results.length).to.equal(0);
|
||||
expect(results.length).to.eql(0);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('cache', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
nock('https://bower.herokuapp.com:443')
|
||||
.get('/packages/search/jquery')
|
||||
.replyWithFile(200, __dirname + '/fixtures/search.json');
|
||||
|
||||
this.client = new RegistryClient({
|
||||
cache: __dirname + '/cache',
|
||||
strictSsl: false
|
||||
});
|
||||
|
||||
this.cacheDir = this.client._config.cache;
|
||||
this.host = 'bower.herokuapp.com';
|
||||
this.method = 'search';
|
||||
this.pkg = 'jquery';
|
||||
|
||||
this.path = this.cacheDir + '/' + this.host + '/' + this.method + '/' + this.pkg;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
//this.client.clearCache();
|
||||
});
|
||||
|
||||
it('should fill cache', function (done) {
|
||||
var self = this;
|
||||
|
||||
// fill cache
|
||||
self.client.search(self.pkg, function (err, results) {
|
||||
expect(err).to.be.null;
|
||||
expect(results.length).to.eql(334);
|
||||
|
||||
// check for cache existance
|
||||
fs.exists(self.path, function (exists) {
|
||||
expect(exists).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should read results from cache', function (done) {
|
||||
var self = this;
|
||||
|
||||
self.client.search(self.pkg, function (err, results) {
|
||||
expect(err).to.be.null;
|
||||
expect(results.length).to.eql(334);
|
||||
|
||||
fs.exists(self.path, function (exists) {
|
||||
expect(exists).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -117,14 +174,14 @@ describe('RegistryClient', function () {
|
||||
it('should return entry type', function () {
|
||||
this.registry.lookup('jquery', function (err, entry) {
|
||||
expect(err).to.be.null;
|
||||
expect(entry.type).to.equal('alias');
|
||||
expect(entry.type).to.eql('alias');
|
||||
});
|
||||
});
|
||||
|
||||
it('should return entry url ', function () {
|
||||
this.registry.lookup('jquery', function (err, entry) {
|
||||
expect(err).to.be.null;
|
||||
expect(entry.url).to.equal('git://github.com/components/jquery.git');
|
||||
expect(entry.url).to.eql('git://github.com/components/jquery.git');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -168,7 +225,7 @@ describe('RegistryClient', function () {
|
||||
|
||||
this.registry.register(this.pkg, this.pkgUrl, function (err, entry) {
|
||||
expect(err).to.be.null;
|
||||
expect(entry.name).to.equal(self.pkg);
|
||||
expect(entry.name).to.eql(self.pkg);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -178,7 +235,7 @@ describe('RegistryClient', function () {
|
||||
|
||||
this.registry.register(this.pkg, this.pkgUrl, function (err, entry) {
|
||||
expect(err).to.be.null;
|
||||
expect(entry.url).to.equal(self.pkgUrl);
|
||||
expect(entry.url).to.eql(self.pkgUrl);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -222,7 +279,7 @@ describe('RegistryClient', function () {
|
||||
this.registry.search(this.pkg, function (err, results) {
|
||||
results.forEach(function (entry) {
|
||||
if (entry.name === self.pkg) {
|
||||
expect(entry.name).to.equal(self.pkg);
|
||||
expect(entry.name).to.eql(self.pkg);
|
||||
done();
|
||||
}
|
||||
});
|
||||
@@ -235,7 +292,7 @@ describe('RegistryClient', function () {
|
||||
this.registry.search(this.pkg, function (err, results) {
|
||||
results.forEach(function (entry) {
|
||||
if (entry.name === self.pkg) {
|
||||
expect(entry.url).to.equal(self.pkgUrl);
|
||||
expect(entry.url).to.eql(self.pkgUrl);
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var index = require('../../lib/index'),
|
||||
expect = require('chai').expect;
|
||||
expect = require('expect.js');
|
||||
|
||||
describe('index module', function () {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var list = require('../../lib/list'),
|
||||
expect = require('chai').expect;
|
||||
expect = require('expect.js');
|
||||
|
||||
describe('list module', function () {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var lookup = require('../../lib/lookup'),
|
||||
expect = require('chai').expect;
|
||||
expect = require('expect.js');
|
||||
|
||||
describe('lookup module', function () {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var register = require('../../lib/register'),
|
||||
expect = require('chai').expect;
|
||||
expect = require('expect.js');
|
||||
|
||||
describe('register module', function () {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var search = require('../../lib/search'),
|
||||
expect = require('chai').expect;
|
||||
expect = require('expect.js');
|
||||
|
||||
describe('search module', function () {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var Cache = require('../../../lib/util/Cache'),
|
||||
expect = require('chai').expect;
|
||||
expect = require('expect.js');
|
||||
|
||||
describe('Cache', function () {
|
||||
|
||||
@@ -24,7 +24,7 @@ describe('Cache', function () {
|
||||
];
|
||||
|
||||
lruMethods.forEach(function (method) {
|
||||
expect(self.cache._cache).to.have.ownProperty(method);
|
||||
expect(self.cache._cache).to.have.property(method);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -32,23 +32,23 @@ describe('Cache', function () {
|
||||
});
|
||||
|
||||
it('should have a get prototype method', function () {
|
||||
expect(Cache.prototype).to.have.ownProperty('get');
|
||||
expect(Cache.prototype).to.have.property('get');
|
||||
});
|
||||
|
||||
it('should have a set prototype method', function () {
|
||||
expect(Cache.prototype).to.have.ownProperty('set');
|
||||
expect(Cache.prototype).to.have.property('set');
|
||||
});
|
||||
|
||||
it('should have a del prototype method', function () {
|
||||
expect(Cache.prototype).to.have.ownProperty('del');
|
||||
expect(Cache.prototype).to.have.property('del');
|
||||
});
|
||||
|
||||
it('should have a clear prototype method', function () {
|
||||
expect(Cache.prototype).to.have.ownProperty('clear');
|
||||
expect(Cache.prototype).to.have.property('clear');
|
||||
});
|
||||
|
||||
it('should have a reset prototype method', function () {
|
||||
expect(Cache.prototype).to.have.ownProperty('reset');
|
||||
expect(Cache.prototype).to.have.property('reset');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var createError = require('../../../lib/util/createError'),
|
||||
expect = require('chai').expect;
|
||||
expect = require('expect.js');
|
||||
|
||||
describe('createError', function () {
|
||||
|
||||
@@ -22,11 +22,11 @@ describe('createError', function () {
|
||||
});
|
||||
|
||||
it('should return an Error with message', function () {
|
||||
expect(this.err.message).to.equal('message');
|
||||
expect(this.err.message).to.eql('message');
|
||||
});
|
||||
|
||||
it('should return an Error with code', function () {
|
||||
expect(this.err.code).to.equal(500);
|
||||
expect(this.err.code).to.eql(500);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user