Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ip6Spec.js 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * Created by elgs on 3/5/16.
  3. */
  4. ;(function () {
  5. 'use strict';
  6. var ip6 = require('./ip6.js');
  7. ////////////////////////////////////////////////////////////////////////////
  8. // Public tests
  9. describe('To normalize IPv6 addresses', function () {
  10. it('should normalize IPv6 addresses', function () {
  11. expect(ip6.normalize('2404:6800:4003:808::200e')).toBe('2404:6800:4003:0808:0000:0000:0000:200e');
  12. expect(ip6.normalize('2404:6800:4003:0808:0000:0000:0000:200e')).toBe('2404:6800:4003:0808:0000:0000:0000:200e');
  13. expect(ip6.normalize('2404:6800:4003:808::')).toBe('2404:6800:4003:0808:0000:0000:0000:0000');
  14. expect(ip6.normalize('2404:68::')).toBe('2404:0068:0000:0000:0000:0000:0000:0000');
  15. expect(ip6.normalize('2404:6800:4003:0808:0:0:0:200e')).toBe('2404:6800:4003:0808:0000:0000:0000:200e');
  16. expect(ip6.normalize('::1')).toBe('0000:0000:0000:0000:0000:0000:0000:0001');
  17. expect(ip6.normalize('::')).toBe('0000:0000:0000:0000:0000:0000:0000:0000');
  18. expect(ip6.normalize('2607:5300:60:465c:0000:0000:0000::')).toBe('2607:5300:0060:465c:0000:0000:0000:0000');
  19. });
  20. });
  21. describe('To abbreviate IPv6 addresses.', function () {
  22. it('should abbreviate IPv6 addresses', function () {
  23. expect(ip6.abbreviate('2001:0000:0111:0000:0011:0000:0001:0000')).toBe('2001:0:111:0:11:0:1:0');
  24. expect(ip6.abbreviate('2001:0001:0000:0001:0000:0000:0000:0001')).toBe('2001:1:0:1::1');
  25. expect(ip6.abbreviate('2001:0001:0000:0001:0000:0000:0000:0000')).toBe('2001:1:0:1::');
  26. expect(ip6.abbreviate('0000:0000:0000:0000:0000:0000:0000:0000')).toBe('::');
  27. expect(ip6.abbreviate('0000:0000:0000:0000:0000:0000:0000:0001')).toBe('::1');
  28. expect(ip6.abbreviate('2041:0000:140F:0000:0000:0000:875B:131B')).toBe('2041:0:140F::875B:131B');
  29. expect(ip6.abbreviate('2001:0001:0002:0003:0004:0005:0006:0007')).toBe('2001:1:2:3:4:5:6:7');
  30. expect(ip6.abbreviate('2001:0000:0000:0000:1111:0000:0000:0000')).toBe('2001::1111:0:0:0');
  31. expect(ip6.abbreviate('2001:db8:0:0:0:0:2:1')).toBe('2001:db8::2:1');
  32. });
  33. });
  34. ////////////////////////////////////////////////////////////////////////////
  35. // Private test
  36. describe('To validate IPv6 addresses.', function () {
  37. beforeEach(function () {
  38. });
  39. afterEach(function () {
  40. });
  41. it('should check whether IPv6 addresses are valid', function () {
  42. expect(ip6._validate('cafe:babe')).toBeTruthy();
  43. expect(ip6._validate('hello world')).toBeFalsy();
  44. });
  45. });
  46. })();