@becollective/utils 1.0.1 → 1.0.3

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/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const password = require('./password');
2
2
 
3
3
  const util = {
4
- password
5
- }
4
+ password,
5
+ };
6
6
 
7
7
  module.exports = util;
package/package.json CHANGED
@@ -1,11 +1,21 @@
1
1
  {
2
2
  "name": "@becollective/utils",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Common utilities",
5
- "main": "index.js",
5
+ "main": "bundle.js",
6
6
  "scripts": {
7
- "test": "NODE_ENV=localtest jest tests/*"
7
+ "test": "NODE_ENV=localtest ./node_modules/.bin/jest tests/*",
8
+ "build": "./node_modules/rollup/bin/rollup -c",
9
+ "prepush": "npm run build; npm test;"
8
10
  },
9
11
  "author": "",
10
- "license": "ISC"
12
+ "license": "ISC",
13
+ "devDependencies": {
14
+ "@babel/core": "^7.1.6",
15
+ "@babel/preset-env": "^7.1.6",
16
+ "jest": "^23.6.0",
17
+ "rollup": "^0.67.1",
18
+ "rollup-plugin-babel": "^4.0.3",
19
+ "rollup-plugin-node-resolve": "^3.4.0"
20
+ }
11
21
  }
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
 
@@ -0,0 +1,20 @@
1
+ import resolve from 'rollup-plugin-node-resolve';
2
+ import babel from 'rollup-plugin-babel';
3
+
4
+ export default {
5
+ input: 'index.js',
6
+ output: {
7
+ file: 'bundle.js',
8
+ format: 'cjs'
9
+ },
10
+ plugins: [
11
+ resolve(),
12
+ babel({
13
+ exclude: 'node_modules/**', // only transpile our source code
14
+ babelrc: false,
15
+ presets: [
16
+ "@babel/preset-env",
17
+ ],
18
+ }),
19
+ ],
20
+ };
@@ -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
  });