選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

38 行
1.3 KiB

  1. import test from 'ava';
  2. import lesspass from '../index';
  3. test('should print different password if templates different', t => {
  4. const encryptedLogin = '78ae5892055ab59fdd54489ae30928d322841a27590b65cf875fcfdd083f7c32';
  5. t.not(lesspass._prettyPrint(encryptedLogin, 'cv'), lesspass._prettyPrint(encryptedLogin, 'vc'));
  6. });
  7. test('must return a string of the same length as the input', t => {
  8. const hash = 'f5785e569ab5d38b02e2248c798ac17df90f57a85f34a9d5382408c2f0d9532d';
  9. t.is(hash.length, lesspass._prettyPrint(hash, 'cv').length);
  10. });
  11. test('should return char inside a string based on modulo of the index', t => {
  12. const template = 'cv';
  13. t.is('c', lesspass._getCharType(template, 0));
  14. t.is('v', lesspass._getCharType(template, 1));
  15. t.is('c', lesspass._getCharType(template, 10));
  16. });
  17. test('should convert a string into an array of char code', t => {
  18. const charCodes = lesspass._string2charCodes('ab40f6ee71');
  19. t.is(97, charCodes[0]);
  20. t.is(98, charCodes[1]);
  21. t.is(10, charCodes.length);
  22. });
  23. test('should get password char based on its type and index', t => {
  24. const typeVowel = 'V';
  25. t.is('A', lesspass._getPasswordChar(typeVowel, 0));
  26. });
  27. test('should modulo if overflow', t => {
  28. const typeVowel = 'V';
  29. t.is('E', lesspass._getPasswordChar(typeVowel, 1));
  30. t.is('E', lesspass._getPasswordChar(typeVowel, 7));
  31. });