Skip to content

Commit

Permalink
work with no config (v0.2.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaszWiktor committed Dec 3, 2015
1 parent ae71a8a commit a659731
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "voucher-code-generator",
"version": "0.2.0",
"version": "0.2.1",

"homepage": "http://www.voucherify.io/",
"description": "Voucher Code Generator",
Expand Down
9 changes: 8 additions & 1 deletion test/voucher_codes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ describe('voucher_codes', function(){
expect(code.length).toBe(default_length);
});

it('should generate code if no config provided', function(){
var default_length = 8;
var code = voucher_codes.generate()[0];

expect(code.length).toBe(default_length);
});

it('should generate 5 unique codes', function(){
var codes = voucher_codes.generate({
length: 2,
Expand Down Expand Up @@ -75,7 +82,7 @@ describe('voucher_codes', function(){
expect(code).toMatch(/-extra$/);
});

it('should generate code with prefix', function(){
it('should generate code with prefix and postfix', function(){
var code = voucher_codes.generate({
prefix: "promo-",
postfix: "-extra"
Expand Down
1 change: 1 addition & 0 deletions voucher_codes.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
}

function generate(config) {
config = config || {};
var count = config.count || 1;
var codes = {};
while (count > 0) {
Expand Down

0 comments on commit a659731

Please sign in to comment.