a zip code crypto-currency system good for red ONLY

remove-unused-fonts.spec.js 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var path_1 = require("path");
  4. var remove_unused_fonts_1 = require("./remove-unused-fonts");
  5. var helpers = require("../util/helpers");
  6. describe('Remove Fonts', function () {
  7. describe('removeUnusedFonts', function () {
  8. it('should not purge any fonts when target is not cordova', function () {
  9. var fakeFontDirPath = path_1.join(process.cwd(), 'www', 'assets', 'fonts');
  10. spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(fakeFontDirPath);
  11. spyOn(helpers, helpers.readDirAsync.name).and.returnValue(Promise.resolve(getMockFontDirData()));
  12. spyOn(helpers, helpers.unlinkAsync.name).and.returnValue(Promise.resolve());
  13. return remove_unused_fonts_1.removeUnusedFonts({ target: 'notCordova', platform: 'web' }).then(function () {
  14. expect(helpers.getStringPropertyValue).toHaveBeenCalled();
  15. expect(helpers.readDirAsync).toHaveBeenCalledWith(fakeFontDirPath);
  16. expect(helpers.unlinkAsync).not.toHaveBeenCalled();
  17. });
  18. });
  19. it('should purge all non-woffs for ionicons and roboto, and then all of noto-sans for ios', function () {
  20. var fakeFontDirPath = path_1.join(process.cwd(), 'www', 'assets', 'fonts');
  21. spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(fakeFontDirPath);
  22. spyOn(helpers, helpers.readDirAsync.name).and.returnValue(Promise.resolve(getMockFontDirData()));
  23. var unlinkSpy = spyOn(helpers, helpers.unlinkAsync.name).and.returnValue(Promise.resolve());
  24. return remove_unused_fonts_1.removeUnusedFonts({ target: 'cordova', platform: 'ios' }).then(function () {
  25. expect(helpers.readDirAsync).toHaveBeenCalledWith(fakeFontDirPath);
  26. expect(unlinkSpy.calls.all()[0].args[0]).toEqual(path_1.join(fakeFontDirPath, 'ionicons.eot'));
  27. expect(unlinkSpy.calls.all()[1].args[0]).toEqual(path_1.join(fakeFontDirPath, 'ionicons.scss'));
  28. expect(unlinkSpy.calls.all()[2].args[0]).toEqual(path_1.join(fakeFontDirPath, 'ionicons.svg'));
  29. expect(unlinkSpy.calls.all()[3].args[0]).toEqual(path_1.join(fakeFontDirPath, 'ionicons.ttf'));
  30. expect(unlinkSpy.calls.all()[4].args[0]).toEqual(path_1.join(fakeFontDirPath, 'noto-sans-bold.ttf'));
  31. expect(unlinkSpy.calls.all()[5].args[0]).toEqual(path_1.join(fakeFontDirPath, 'noto-sans-bold.woff'));
  32. expect(unlinkSpy.calls.all()[6].args[0]).toEqual(path_1.join(fakeFontDirPath, 'noto-sans-regular.ttf'));
  33. expect(unlinkSpy.calls.all()[7].args[0]).toEqual(path_1.join(fakeFontDirPath, 'noto-sans-regular.woff'));
  34. expect(unlinkSpy.calls.all()[8].args[0]).toEqual(path_1.join(fakeFontDirPath, 'noto-sans.scss'));
  35. expect(unlinkSpy.calls.all()[9].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-bold.ttf'));
  36. expect(unlinkSpy.calls.all()[10].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-light.ttf'));
  37. expect(unlinkSpy.calls.all()[11].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-medium.ttf'));
  38. expect(unlinkSpy.calls.all()[12].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-regular.ttf'));
  39. expect(unlinkSpy.calls.all()[13].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto.scss'));
  40. });
  41. });
  42. it('should purge all non-woffs for ionicons, all of roboto and noto-sans for android', function () {
  43. var fakeFontDirPath = path_1.join(process.cwd(), 'www', 'assets', 'fonts');
  44. spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(fakeFontDirPath);
  45. spyOn(helpers, helpers.readDirAsync.name).and.returnValue(Promise.resolve(getMockFontDirData()));
  46. var unlinkSpy = spyOn(helpers, helpers.unlinkAsync.name).and.returnValue(Promise.resolve());
  47. return remove_unused_fonts_1.removeUnusedFonts({ target: 'cordova', platform: 'android' }).then(function () {
  48. expect(helpers.readDirAsync).toHaveBeenCalledWith(fakeFontDirPath);
  49. expect(unlinkSpy.calls.all()[0].args[0]).toEqual(path_1.join(fakeFontDirPath, 'ionicons.eot'));
  50. expect(unlinkSpy.calls.all()[1].args[0]).toEqual(path_1.join(fakeFontDirPath, 'ionicons.scss'));
  51. expect(unlinkSpy.calls.all()[2].args[0]).toEqual(path_1.join(fakeFontDirPath, 'ionicons.svg'));
  52. expect(unlinkSpy.calls.all()[3].args[0]).toEqual(path_1.join(fakeFontDirPath, 'ionicons.ttf'));
  53. expect(unlinkSpy.calls.all()[4].args[0]).toEqual(path_1.join(fakeFontDirPath, 'noto-sans-bold.ttf'));
  54. expect(unlinkSpy.calls.all()[5].args[0]).toEqual(path_1.join(fakeFontDirPath, 'noto-sans-bold.woff'));
  55. expect(unlinkSpy.calls.all()[6].args[0]).toEqual(path_1.join(fakeFontDirPath, 'noto-sans-regular.ttf'));
  56. expect(unlinkSpy.calls.all()[7].args[0]).toEqual(path_1.join(fakeFontDirPath, 'noto-sans-regular.woff'));
  57. expect(unlinkSpy.calls.all()[8].args[0]).toEqual(path_1.join(fakeFontDirPath, 'noto-sans.scss'));
  58. expect(unlinkSpy.calls.all()[9].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-bold.ttf'));
  59. expect(unlinkSpy.calls.all()[10].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-bold.woff'));
  60. expect(unlinkSpy.calls.all()[11].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-bold.woff2'));
  61. expect(unlinkSpy.calls.all()[12].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-light.ttf'));
  62. expect(unlinkSpy.calls.all()[13].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-light.woff'));
  63. expect(unlinkSpy.calls.all()[14].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-light.woff2'));
  64. expect(unlinkSpy.calls.all()[15].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-medium.ttf'));
  65. expect(unlinkSpy.calls.all()[16].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-medium.woff'));
  66. expect(unlinkSpy.calls.all()[17].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-medium.woff2'));
  67. expect(unlinkSpy.calls.all()[18].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-regular.ttf'));
  68. expect(unlinkSpy.calls.all()[19].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-regular.woff'));
  69. expect(unlinkSpy.calls.all()[20].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto-regular.woff2'));
  70. expect(unlinkSpy.calls.all()[21].args[0]).toEqual(path_1.join(fakeFontDirPath, 'roboto.scss'));
  71. });
  72. });
  73. it('should purge all non-woffs for ionicons, all of roboto and noto-sans for windows', function () {
  74. var fakeFontDirPath = path_1.join(process.cwd(), 'www', 'assets', 'fonts');
  75. spyOn(helpers, helpers.getStringPropertyValue.name).and.returnValue(fakeFontDirPath);
  76. spyOn(helpers, helpers.readDirAsync.name).and.returnValue(Promise.resolve(getMockFontDirData()));
  77. var unlinkSpy = spyOn(helpers, helpers.unlinkAsync.name).and.returnValue(Promise.resolve());
  78. return remove_unused_fonts_1.removeUnusedFonts({ target: 'cordova', platform: 'windows' }).then(function () {
  79. expect(helpers.readDirAsync).toHaveBeenCalledWith(fakeFontDirPath);
  80. expect(helpers.unlinkAsync).not.toHaveBeenCalled();
  81. });
  82. });
  83. });
  84. });
  85. function getMockFontDirData() {
  86. return [
  87. 'ionicons.eot',
  88. 'ionicons.scss',
  89. 'ionicons.svg',
  90. 'ionicons.ttf',
  91. 'ionicons.woff',
  92. 'ionicons.woff2',
  93. 'noto-sans-bold.ttf',
  94. 'noto-sans-bold.woff',
  95. 'noto-sans-regular.ttf',
  96. 'noto-sans-regular.woff',
  97. 'noto-sans.scss',
  98. 'roboto-bold.ttf',
  99. 'roboto-bold.woff',
  100. 'roboto-bold.woff2',
  101. 'roboto-light.ttf',
  102. 'roboto-light.woff',
  103. 'roboto-light.woff2',
  104. 'roboto-medium.ttf',
  105. 'roboto-medium.woff',
  106. 'roboto-medium.woff2',
  107. 'roboto-regular.ttf',
  108. 'roboto-regular.woff',
  109. 'roboto-regular.woff2',
  110. 'roboto.scss',
  111. 'my-custom-font.eot',
  112. 'my-custom-font.scss',
  113. 'my-custom-font.svg',
  114. 'my-custom-font.ttf',
  115. 'my-custom-font.woff',
  116. 'my-custom-font.woff2'
  117. ];
  118. }