Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
DNizovtsev committed Apr 4, 2015
1 parent 55a3625 commit 565ffc4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var jar = new CookieJar(new FileCookieStore("./cookie.txt", {lockfile : true}));
```

## Installation

If you have npm installed, you can simply type:

npm install file-cookie-store
Expand Down Expand Up @@ -52,6 +53,20 @@ Q.nbind(jar.setCookie, jar)(new new TOUGH.Cookie({...}), 'http://test.com/')
});
```

#### Export cookies

For receive all cookies from the store might be used method export:

``` javascript
cookie_store.export(function(cookies) {
//array cookies
});

cookie_store.export(new MemoryCookieStore(),function(memory_cookie_store) {
//memory_cookie_store
});
```

#### Store file format

Cookies stored in [Netscape's cookie.txt file](http://www.cookiecentral.com/faq/#3.5).
Expand Down
12 changes: 9 additions & 3 deletions test/file-store.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,15 +817,15 @@ describe('Test file cookie store', function() {
var cookies_urls = ['http://aff.store.com/', 'http://www.aff.store.com/',
'http://store.com', 'http://www.store.com'],
fns = [];
for (i = 0; i < cookies_urls.length; i++) {
for (i = 0; i < cookies_urls.length; i++) {
var func = Q.nbind(cookie_jar.getCookies, cookie_jar);
fns.push(func(cookies_urls[i]));
}

var cookie_store2 = new FileCookieStore(COOKIES_TEST_FILE_NEW),
cookie_jar2 = new TOUGH.CookieJar(new FileCookieStore(COOKIES_TEST_FILE_NEW));

Q.all(fns).spread(function(cookies1,cookies2,cookies3,cookies4){
Q.all(fns).spread(function(cookies1,cookies2,cookies3,cookies4){
expect(cookies1).to.be.a(Array);
expect(cookies1).to.have.length(6);
expect(cookies2).to.be.a(Array);
Expand Down Expand Up @@ -864,7 +864,13 @@ describe('Test file cookie store', function() {

describe("#export", function () {
it('should export cookies to the array', function (done) {

cookie_store.export(function (err, cookies) {

cookies.forEach(function(c, i){
console.log(c.toString());
});

if (err) {
done(err);
} else {
Expand Down Expand Up @@ -900,7 +906,7 @@ describe('Test file cookie store', function() {
done();
}
});
});
});
});

});

0 comments on commit 565ffc4

Please sign in to comment.