@becollective/utils 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@becollective/utils",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Common utilities",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "NODE_ENV=localtest jest tests/*"
7
+ "test": "NODE_ENV=localtest ./node_modules/.bin/jest tests/*"
8
8
  },
9
9
  "author": "",
10
- "license": "ISC"
10
+ "license": "ISC",
11
+ "devDependencies": {
12
+ "jest": "^23.6.0"
13
+ }
11
14
  }
package/password.js CHANGED
@@ -28,6 +28,15 @@ const password = {
28
28
  }
29
29
 
30
30
  return true;
31
+ },
32
+ isValid: (input) => {
33
+ try {
34
+ password.validate(input);
35
+ return true;
36
+ }
37
+ catch (e) {
38
+ return false
39
+ }
31
40
  }
32
41
  }
33
42
 
@@ -52,4 +52,19 @@ describe('password.valiate', () => {
52
52
  util.password.validate(password);
53
53
  }).toThrow('not-string');
54
54
  }, 1000);
55
+ test('returns false for invalid passwords', async () => {
56
+ const someValid = [
57
+ 'short',
58
+ '1234567a',
59
+ '123456aa',
60
+ '1aB!',
61
+ ]
62
+ .map(util.password.isValid)
63
+ .some(val => val);
64
+ expect(someValid).toBe(false);
65
+ });
66
+ test('returns true for a valid password', async () => {
67
+ const password = 'Password@123';
68
+ expect(util.password.isValid(password)).toBe(true);
69
+ });
55
70
  });