Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. 'use strict';
  2. var _templateObject = _taggedTemplateLiteral(['\n .a-id {\n font-size: 12;\n }\n '], ['\n .a-id {\n font-size: 12;\n }\n ']);
  3. var _expect = require('expect.js');
  4. var _expect2 = _interopRequireDefault(_expect);
  5. var _commonTags = require('common-tags');
  6. var _jss = require('jss');
  7. var _index = require('./index');
  8. var _index2 = _interopRequireDefault(_index);
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10. function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
  11. var settings = {
  12. createGenerateClassName: function createGenerateClassName() {
  13. return function (rule) {
  14. return rule.key + '-id';
  15. };
  16. }
  17. };
  18. describe('jss-camel-case', function () {
  19. var jss = void 0;
  20. beforeEach(function () {
  21. jss = (0, _jss.create)(settings).use((0, _index2['default'])());
  22. });
  23. describe('regular rule', function () {
  24. var sheet = void 0;
  25. beforeEach(function () {
  26. sheet = jss.createStyleSheet({
  27. a: {
  28. fontSize: '20px',
  29. zIndex: 1,
  30. lineHeight: 1.2
  31. }
  32. });
  33. });
  34. it('should generate correct CSS', function () {
  35. (0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n font-size: 20px;\n z-index: 1;\n line-height: 1.2;\n}');
  36. });
  37. });
  38. describe('@font-face with array of styles', function () {
  39. var sheet = void 0;
  40. beforeEach(function () {
  41. sheet = jss.createStyleSheet({
  42. '@font-face': [{
  43. fontFamily: 'Lato-Light',
  44. src: 'url("/fonts/Lato-Light.ttf") format("truetype")'
  45. }, {
  46. fontFamily: 'Lato-Bold',
  47. src: 'url("/fonts/Lato-Bold.ttf") format("truetype")'
  48. }]
  49. });
  50. });
  51. it('should generate correct CSS', function () {
  52. (0, _expect2['default'])(sheet.toString()).to.be('@font-face {\n' + ' font-family: Lato-Light;\n' + ' src: url("/fonts/Lato-Light.ttf") format("truetype");\n' + '}\n' + '@font-face {\n' + ' font-family: Lato-Bold;\n' + ' src: url("/fonts/Lato-Bold.ttf") format("truetype");\n' + '}');
  53. });
  54. });
  55. describe('fallbacks object', function () {
  56. var sheet = void 0;
  57. beforeEach(function () {
  58. sheet = jss.createStyleSheet({
  59. '@font-face': {
  60. fontFamily: 'MyWebFont',
  61. fallbacks: {
  62. fontFamily: 'MyWebFontFallback'
  63. }
  64. }
  65. });
  66. });
  67. it('should generate correct CSS', function () {
  68. (0, _expect2['default'])(sheet.toString()).to.be('@font-face {\n' + ' font-family: MyWebFontFallback;\n' + ' font-family: MyWebFont;\n' + '}');
  69. });
  70. });
  71. describe('fallbacks array', function () {
  72. var sheet = void 0;
  73. beforeEach(function () {
  74. sheet = jss.createStyleSheet({
  75. '@font-face': {
  76. fontFamily: 'MyWebFont',
  77. fallbacks: [{ fontFamily: 'MyWebFontFallback' }]
  78. }
  79. });
  80. });
  81. it('should generate correct CSS', function () {
  82. (0, _expect2['default'])(sheet.toString()).to.be('@font-face {\n' + ' font-family: MyWebFontFallback;\n' + ' font-family: MyWebFont;\n' + '}');
  83. });
  84. });
  85. describe('font faces with fallbacks', function () {
  86. var sheet = void 0;
  87. beforeEach(function () {
  88. sheet = jss.createStyleSheet({
  89. '@font-face': [{
  90. fontFamily: 'MyWebFont',
  91. fallbacks: {
  92. fontFamily: 'MyWebFontFallback'
  93. }
  94. }]
  95. });
  96. });
  97. it('should generate correct CSS', function () {
  98. (0, _expect2['default'])(sheet.toString()).to.be('@font-face {\n' + ' font-family: MyWebFontFallback;\n' + ' font-family: MyWebFont;\n' + '}');
  99. });
  100. });
  101. describe('function values', function () {
  102. var sheet = void 0;
  103. beforeEach(function () {
  104. sheet = jss.createStyleSheet({
  105. a: {
  106. fontSize: function fontSize() {
  107. return 12;
  108. }
  109. }
  110. });
  111. });
  112. it('should generate correct CSS', function () {
  113. sheet.update();
  114. (0, _expect2['default'])(sheet.toString()).to.be((0, _commonTags.stripIndent)(_templateObject));
  115. });
  116. });
  117. });