@bottlebooks/valid-values 10.49.0 → 10.50.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,21 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [10.50.0](https://github.com/bottlebooks/bottlebooks/compare/@bottlebooks/valid-values@10.49.0...@bottlebooks/valid-values@10.50.0) (2025-04-14)
7
+
8
+ ### Bug Fixes
9
+
10
+ - add carbohydrateSugarsIsNegligible flag ([ec15b6a](https://github.com/bottlebooks/bottlebooks/commit/ec15b6a15a27d5cf2a9f89d4f7c3360a2477028b))
11
+ - error building valid values because of missing id ([70c018a](https://github.com/bottlebooks/bottlebooks/commit/70c018a7ab9bd3493968874f889bcc79e17fc144))
12
+ - import and load translations ([d8591ae](https://github.com/bottlebooks/bottlebooks/commit/d8591ae25b44847601062d025d840b4f96d60288))
13
+ - vitest error - expect cannot be wrapped ([747915a](https://github.com/bottlebooks/bottlebooks/commit/747915ab883b8fede0c778d667f266973694494f))
14
+
15
+ ### Features
16
+
17
+ - add coverage to carbs is negligible and sugar not ([0334823](https://github.com/bottlebooks/bottlebooks/commit/0334823c865b5835137f5e19043de9abb59aad3f))
18
+ - add coverage to negligible sugars ([31c5cfd](https://github.com/bottlebooks/bottlebooks/commit/31c5cfd8fc5c0f0cc811208af53980523a0a01f5))
19
+ - handle carbohydrateSugarsIsNegligible to build simplified declaration ([d926e8b](https://github.com/bottlebooks/bottlebooks/commit/d926e8b9252bf8be4048e510f25e22169ddbfdb3))
20
+
6
21
  # [10.49.0](https://github.com/bottlebooks/bottlebooks/compare/@bottlebooks/valid-values@10.48.1...@bottlebooks/valid-values@10.49.0) (2025-03-18)
7
22
 
8
23
  ### Features
@@ -1 +1 @@
1
- {"version":3,"file":"ingredient.d.ts","sourceRoot":"","sources":["../../../src/validValues/ingredient/ingredient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAM1E,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,mBAAmB,CAAC;AAUhF,UAAU,UACR,SAAQ,oBAAoB,EAC1B,sCAAsC;CAAG;AA4B7C,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAssDV,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,cAAc,CAAC;AAExD,eAAO,MAAM,aAAa,ovDAUzB,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"ingredient.d.ts","sourceRoot":"","sources":["../../../src/validValues/ingredient/ingredient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAM1E,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,mBAAmB,CAAC;AAUhF,UAAU,UACR,SAAQ,oBAAoB,EAC1B,sCAAsC;CAAG;AA4B7C,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwsDV,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,cAAc,CAAC;AAExD,eAAO,MAAM,aAAa,ovDAUzB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1328,7 +1328,8 @@ var allIngredients = _objectSpread(_objectSpread({}, _deprecatedIngredient["defa
1328
1328
  synonymDescription:
1329
1329
  /*i18n*/
1330
1330
  {
1331
- id: 'Bolding the entire term many not be accepted in all countries. Bottlebooks recommends only bolding the allergen.'
1331
+ id: 'Bolding the entire term many not be accepted in all countries. Bottlebooks recommends only bolding the allergen.',
1332
+ message: 'Bolding the entire term many not be accepted in all countries. Bottlebooks recommends only bolding the allergen.'
1332
1333
  }
1333
1334
  }
1334
1335
  }),
@@ -1375,7 +1376,8 @@ var allIngredients = _objectSpread(_objectSpread({}, _deprecatedIngredient["defa
1375
1376
  synonymDescription:
1376
1377
  /*i18n*/
1377
1378
  {
1378
- id: 'Bolding the entire term many not be accepted in all countries. Bottlebooks recommends only bolding the allergen.'
1379
+ id: 'Bolding the entire term many not be accepted in all countries. Bottlebooks recommends only bolding the allergen.',
1380
+ message: 'Bolding the entire term many not be accepted in all countries. Bottlebooks recommends only bolding the allergen.'
1379
1381
  }
1380
1382
  }
1381
1383
  }),
@@ -1,9 +1,10 @@
1
- export declare function simplifiedDeclarationStatement({ fatIsNegligible, proteinIsNegligible, saltIsNegligible, carbohydratesIsNegligible, showSimplifiedTable, }: {
1
+ export declare function simplifiedDeclarationStatement({ fatIsNegligible, proteinIsNegligible, saltIsNegligible, carbohydratesIsNegligible, carbohydrateSugarsIsNegligible, showSimplifiedTable, }: {
2
2
  fatIsNegligible?: boolean;
3
3
  proteinIsNegligible?: boolean;
4
4
  saltIsNegligible?: boolean;
5
5
  saturatedFatIsNegligible?: boolean;
6
6
  carbohydratesIsNegligible?: boolean;
7
+ carbohydrateSugarsIsNegligible?: boolean;
7
8
  showSimplifiedTable?: boolean;
8
9
  }, { language }: {
9
10
  language: string;
@@ -1 +1 @@
1
- {"version":3,"file":"simplifiedDeclarationStatement.d.ts","sourceRoot":"","sources":["../../../src/validValues/otherTranslations/simplifiedDeclarationStatement.ts"],"names":[],"mappings":"AAEA,wBAAgB,8BAA8B,CAC5C,EACE,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,GACpB,EAAE;IACD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,EACD,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,UAsBnC"}
1
+ {"version":3,"file":"simplifiedDeclarationStatement.d.ts","sourceRoot":"","sources":["../../../src/validValues/otherTranslations/simplifiedDeclarationStatement.ts"],"names":[],"mappings":"AAEA,wBAAgB,8BAA8B,CAC5C,EACE,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,yBAAyB,EACzB,8BAA8B,EAC9B,mBAAmB,GACpB,EAAE;IACD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,8BAA8B,CAAC,EAAE,OAAO,CAAC;IACzC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,EACD,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,UAuBnC"}
@@ -12,6 +12,7 @@ function simplifiedDeclarationStatement(_ref, _ref2) {
12
12
  proteinIsNegligible = _ref.proteinIsNegligible,
13
13
  saltIsNegligible = _ref.saltIsNegligible,
14
14
  carbohydratesIsNegligible = _ref.carbohydratesIsNegligible,
15
+ carbohydrateSugarsIsNegligible = _ref.carbohydrateSugarsIsNegligible,
15
16
  showSimplifiedTable = _ref.showSimplifiedTable;
16
17
  var language = _ref2.language;
17
18
  if (!language) throw new Error('required_param:language');
@@ -20,6 +21,7 @@ function simplifiedDeclarationStatement(_ref, _ref2) {
20
21
  language: language,
21
22
  fatIsNegligible: fatIsNegligible,
22
23
  carbohydratesIsNegligible: carbohydratesIsNegligible,
24
+ carbohydrateSugarsIsNegligible: carbohydrateSugarsIsNegligible,
23
25
  proteinIsNegligible: proteinIsNegligible,
24
26
  saltIsNegligible: saltIsNegligible
25
27
  });
@@ -40,13 +42,14 @@ function getSimplifiedDeclarationItemsText(_ref3) {
40
42
  fatIsNegligible = _ref3.fatIsNegligible,
41
43
  proteinIsNegligible = _ref3.proteinIsNegligible,
42
44
  saltIsNegligible = _ref3.saltIsNegligible,
43
- carbohydratesIsNegligible = _ref3.carbohydratesIsNegligible;
45
+ carbohydratesIsNegligible = _ref3.carbohydratesIsNegligible,
46
+ carbohydrateSugarsIsNegligible = _ref3.carbohydrateSugarsIsNegligible;
44
47
  // fat and saturates
45
48
  var fatTranslation = fatIsNegligible ? (0, _translate.translate)('simplifiedDeclaration.fat', language) : null;
46
49
  var saturatedFatTranslation = fatIsNegligible ? (0, _translate.translate)('simplifiedDeclaration.saturatedFat', language) : null; // Carbohydrate and sugar
47
50
 
48
51
  var carbohidratesTranslation = carbohydratesIsNegligible ? (0, _translate.translate)('simplifiedDeclaration.carbohydrates', language) : null;
49
- var carbohidrateSugarsTranslation = carbohydratesIsNegligible ? (0, _translate.translate)('simplifiedDeclaration.carbohydrateSugars', language) : null;
52
+ var carbohidrateSugarsTranslation = carbohydrateSugarsIsNegligible ? (0, _translate.translate)('simplifiedDeclaration.carbohydrateSugars', language) : null;
50
53
  var proteinTranslation = proteinIsNegligible ? (0, _translate.translate)('simplifiedDeclaration.protein', language) : null;
51
54
  var saltTranslation = saltIsNegligible ? (0, _translate.translate)('simplifiedDeclaration.salt', language) : null;
52
55
  var simplifiedDeclarationItems = [fatTranslation, saturatedFatTranslation, carbohidratesTranslation, carbohidrateSugarsTranslation, proteinTranslation, saltTranslation].filter(Boolean); // Use "en-GB" instead of "en" as language, because of the 'Oxford comma, Ex:
@@ -6,11 +6,15 @@ var _simplifiedDeclarationStatement = require("./simplifiedDeclarationStatement"
6
6
 
7
7
  var _plurals = require("make-plural/plurals");
8
8
 
9
- var _core = require("@lingui/core");
9
+ var _de = require("./locales/de");
10
10
 
11
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
11
+ var _sk = require("./locales/sk");
12
12
 
13
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13
+ var _fr = require("./locales/fr");
14
+
15
+ var _en = require("./locales/en");
16
+
17
+ var _core = require("@lingui/core");
14
18
 
15
19
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
20
 
@@ -18,15 +22,19 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
18
22
 
19
23
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
24
 
25
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
26
+
27
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
28
+
21
29
  var falsy = {
22
30
  fatIsNegligible: false,
23
31
  saltIsNegligible: false,
24
32
  proteinIsNegligible: false,
25
33
  carbohydratesIsNegligible: false,
34
+ carbohydrateSugarsIsNegligible: false,
26
35
  showSimplifiedTable: true
27
36
  };
28
-
29
- var loadLocales = function loadLocales() {
37
+ (0, _vitest.beforeEach)(function () {
30
38
  _core.i18n.loadLocaleData('de', {
31
39
  plurals: _plurals.de
32
40
  });
@@ -43,34 +51,52 @@ var loadLocales = function loadLocales() {
43
51
  plurals: _plurals.en
44
52
  });
45
53
 
46
- console.log('messages loaded for en,de');
47
- };
54
+ _core.i18n.load('de', _de.messages);
48
55
 
49
- (0, _vitest.beforeEach)(function () {
50
- loadLocales();
56
+ _core.i18n.load('sk', _sk.messages);
57
+
58
+ _core.i18n.load('fr', _fr.messages);
59
+
60
+ _core.i18n.load('en', _en.messages);
51
61
  });
52
62
  (0, _vitest.afterEach)(function () {
53
- loadLocales();
63
+ _core.i18n.loadLocaleData('de', {
64
+ plurals: undefined
65
+ });
66
+
67
+ _core.i18n.loadLocaleData('sk', {
68
+ plurals: undefined
69
+ });
70
+
71
+ _core.i18n.loadLocaleData('fr', {
72
+ plurals: undefined
73
+ });
74
+
75
+ _core.i18n.loadLocaleData('en', {
76
+ plurals: undefined
77
+ });
78
+
79
+ _core.i18n.load('de', {});
80
+
81
+ _core.i18n.load('sk', {});
82
+
83
+ _core.i18n.load('fr', {});
84
+
85
+ _core.i18n.load('en', {});
54
86
  });
55
87
  (0, _vitest.describe)('simplifiedDeclarationStatement', function () {
56
- function _expect(o, opt, s) {
57
- var statement = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread(_objectSpread({}, falsy), o), _objectSpread({
58
- language: 'en'
59
- }, opt));
60
- console.log('simplifiedDeclarationStatement:', statement);
61
- return (0, _vitest.expect)(statement).toMatchInlineSnapshot(s);
62
- }
63
-
64
88
  (0, _vitest.test)('simplifiedDeclaration.empty', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
89
+ var statement;
65
90
  return regeneratorRuntime.wrap(function _callee$(_context) {
66
91
  while (1) {
67
92
  switch (_context.prev = _context.next) {
68
93
  case 0:
69
- _expect({}, {
94
+ statement = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread({}, falsy), {
70
95
  language: 'en'
71
- }, '""');
96
+ });
97
+ (0, _vitest.expect)(statement).toMatchInlineSnapshot('""');
72
98
 
73
- case 1:
99
+ case 2:
74
100
  case "end":
75
101
  return _context.stop();
76
102
  }
@@ -78,17 +104,19 @@ var loadLocales = function loadLocales() {
78
104
  }, _callee);
79
105
  })));
80
106
  (0, _vitest.test)('simplifiedDeclaration.fat', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
107
+ var statement;
81
108
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
82
109
  while (1) {
83
110
  switch (_context2.prev = _context2.next) {
84
111
  case 0:
85
- _expect({
112
+ statement = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread(_objectSpread({}, falsy), {}, {
86
113
  fatIsNegligible: true
87
- }, {
114
+ }), {
88
115
  language: 'en'
89
- }, '"<span>Contains negligible amounts of fat and saturates.</span>"');
116
+ });
117
+ (0, _vitest.expect)(statement).toMatchInlineSnapshot('"<span>Contains negligible amounts of fat and saturates.</span>"');
90
118
 
91
- case 1:
119
+ case 2:
92
120
  case "end":
93
121
  return _context2.stop();
94
122
  }
@@ -96,18 +124,20 @@ var loadLocales = function loadLocales() {
96
124
  }, _callee2);
97
125
  })));
98
126
  (0, _vitest.test)('simplifiedDeclaration.fat.protein', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
127
+ var statement;
99
128
  return regeneratorRuntime.wrap(function _callee3$(_context3) {
100
129
  while (1) {
101
130
  switch (_context3.prev = _context3.next) {
102
131
  case 0:
103
- _expect({
132
+ statement = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread(_objectSpread({}, falsy), {}, {
104
133
  fatIsNegligible: true,
105
134
  proteinIsNegligible: true
106
- }, {
135
+ }), {
107
136
  language: 'en'
108
- }, '"<span>Contains negligible amounts of fat, saturates and protein.</span>"');
137
+ });
138
+ (0, _vitest.expect)(statement).toMatchInlineSnapshot('"<span>Contains negligible amounts of fat, saturates and protein.</span>"');
109
139
 
110
- case 1:
140
+ case 2:
111
141
  case "end":
112
142
  return _context3.stop();
113
143
  }
@@ -115,82 +145,164 @@ var loadLocales = function loadLocales() {
115
145
  }, _callee3);
116
146
  })));
117
147
  (0, _vitest.test)('simplifiedDeclaration.fat.salt', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
148
+ var statement;
118
149
  return regeneratorRuntime.wrap(function _callee4$(_context4) {
119
150
  while (1) {
120
151
  switch (_context4.prev = _context4.next) {
121
152
  case 0:
122
- _expect({
153
+ statement = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread(_objectSpread({}, falsy), {}, {
123
154
  fatIsNegligible: true,
124
155
  saltIsNegligible: true
125
- }, {
156
+ }), {
126
157
  language: 'en'
127
- }, '"<span>Contains negligible amounts of fat, saturates and salt.</span>"');
158
+ });
159
+ (0, _vitest.expect)(statement).toMatchInlineSnapshot('"<span>Contains negligible amounts of fat, saturates and salt.</span>"');
128
160
 
129
- case 1:
161
+ case 2:
130
162
  case "end":
131
163
  return _context4.stop();
132
164
  }
133
165
  }
134
166
  }, _callee4);
135
167
  })));
136
- (0, _vitest.test)('simplifiedDeclaration.fat.protein.carbohydrates', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
168
+ (0, _vitest.test)('simplifiedDeclaration.fat.protein.carbohydrates.sugars', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
169
+ var enStatement, frStatement;
137
170
  return regeneratorRuntime.wrap(function _callee5$(_context5) {
138
171
  while (1) {
139
172
  switch (_context5.prev = _context5.next) {
140
173
  case 0:
141
- _expect({
174
+ enStatement = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread(_objectSpread({}, falsy), {}, {
142
175
  fatIsNegligible: true,
143
176
  proteinIsNegligible: true,
144
- carbohydratesIsNegligible: true
145
- }, {
177
+ carbohydratesIsNegligible: true,
178
+ carbohydrateSugarsIsNegligible: true
179
+ }), {
146
180
  language: 'en'
147
- }, '"<span>Contains negligible amounts of fat, saturates, carbohydrate, sugars and protein.</span>"');
148
-
149
- _expect({
181
+ });
182
+ (0, _vitest.expect)(enStatement).toMatchInlineSnapshot('"<span>Contains negligible amounts of fat, saturates, carbohydrate, sugars and protein.</span>"');
183
+ frStatement = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread(_objectSpread({}, falsy), {}, {
150
184
  fatIsNegligible: true,
151
185
  proteinIsNegligible: true,
152
- carbohydratesIsNegligible: true
153
- }, {
186
+ carbohydratesIsNegligible: true,
187
+ carbohydrateSugarsIsNegligible: true
188
+ }), {
154
189
  language: 'fr'
155
- }, '"<span>Contient des quantités négligeables de matières grasses, acides gras saturés, glucides, sucres et protéines.</span>"');
190
+ });
191
+ (0, _vitest.expect)(frStatement).toMatchInlineSnapshot('"<span>Contient des quantités négligeables de matières grasses, acides gras saturés, glucides, sucres et protéines.</span>"');
156
192
 
157
- case 2:
193
+ case 4:
158
194
  case "end":
159
195
  return _context5.stop();
160
196
  }
161
197
  }
162
198
  }, _callee5);
163
199
  })));
164
- (0, _vitest.test)('simplifiedDeclaration.protein', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
200
+ (0, _vitest.test)('simplifiedDeclaration.fat.protein.carbohydrates', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
201
+ var enStatement, frStatement;
165
202
  return regeneratorRuntime.wrap(function _callee6$(_context6) {
166
203
  while (1) {
167
204
  switch (_context6.prev = _context6.next) {
168
205
  case 0:
169
- _expect({
206
+ enStatement = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread(_objectSpread({}, falsy), {}, {
207
+ fatIsNegligible: true,
208
+ proteinIsNegligible: true,
209
+ carbohydratesIsNegligible: true
210
+ }), {
211
+ language: 'en'
212
+ });
213
+ (0, _vitest.expect)(enStatement).toMatchInlineSnapshot('"<span>Contains negligible amounts of fat, saturates, carbohydrate and protein.</span>"');
214
+ frStatement = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread(_objectSpread({}, falsy), {}, {
215
+ fatIsNegligible: true,
216
+ proteinIsNegligible: true,
217
+ carbohydratesIsNegligible: true
218
+ }), {
219
+ language: 'fr'
220
+ });
221
+ (0, _vitest.expect)(frStatement).toMatchInlineSnapshot('"<span>Contient des quantités négligeables de matières grasses, acides gras saturés, glucides et protéines.</span>"');
222
+
223
+ case 4:
224
+ case "end":
225
+ return _context6.stop();
226
+ }
227
+ }
228
+ }, _callee6);
229
+ })));
230
+ (0, _vitest.test)('simplifiedDeclaration.fat.protein.sugars', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
231
+ var statement;
232
+ return regeneratorRuntime.wrap(function _callee7$(_context7) {
233
+ while (1) {
234
+ switch (_context7.prev = _context7.next) {
235
+ case 0:
236
+ statement = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread(_objectSpread({}, falsy), {}, {
237
+ fatIsNegligible: true,
238
+ proteinIsNegligible: true,
239
+ carbohydrateSugarsIsNegligible: true
240
+ }), {
241
+ language: 'en'
242
+ });
243
+ (0, _vitest.expect)(statement).toMatchInlineSnapshot('"<span>Contains negligible amounts of fat, saturates, sugars and protein.</span>"');
244
+
245
+ case 2:
246
+ case "end":
247
+ return _context7.stop();
248
+ }
249
+ }
250
+ }, _callee7);
251
+ })));
252
+ (0, _vitest.test)('simplifiedDeclaration.sugars', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {
253
+ var statement;
254
+ return regeneratorRuntime.wrap(function _callee8$(_context8) {
255
+ while (1) {
256
+ switch (_context8.prev = _context8.next) {
257
+ case 0:
258
+ statement = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread(_objectSpread({}, falsy), {}, {
259
+ carbohydrateSugarsIsNegligible: true
260
+ }), {
261
+ language: 'en'
262
+ });
263
+ (0, _vitest.expect)(statement).toMatchInlineSnapshot('"<span>Contains negligible amounts of sugars.</span>"');
264
+
265
+ case 2:
266
+ case "end":
267
+ return _context8.stop();
268
+ }
269
+ }
270
+ }, _callee8);
271
+ })));
272
+ (0, _vitest.test)('simplifiedDeclaration.protein', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {
273
+ var statement1, statement2, statement3;
274
+ return regeneratorRuntime.wrap(function _callee9$(_context9) {
275
+ while (1) {
276
+ switch (_context9.prev = _context9.next) {
277
+ case 0:
278
+ statement1 = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread(_objectSpread({}, falsy), {}, {
170
279
  proteinIsNegligible: true
171
- }, {
280
+ }), {
172
281
  language: 'sk'
173
- }, '"<span>Obsahuje zanedbateľné množstvá bielkovín.</span>"');
174
-
175
- _expect({
282
+ });
283
+ (0, _vitest.expect)(statement1).toMatchInlineSnapshot('"<span>Obsahuje zanedbateľné množstvá bielkovín.</span>"');
284
+ statement2 = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread(_objectSpread({}, falsy), {}, {
176
285
  carbohydratesIsNegligible: true,
286
+ carbohydrateSugarsIsNegligible: true,
177
287
  proteinIsNegligible: true,
178
288
  saltIsNegligible: true
179
- }, {
289
+ }), {
180
290
  language: 'sk'
181
- }, '"<span>Obsahuje zanedbateľné množstvá sacharidov, cukrov, bielkovín a soli.</span>"');
182
-
183
- _expect({
184
- carbohydratesIsNegligible: true
185
- }, {
291
+ });
292
+ (0, _vitest.expect)(statement2).toMatchInlineSnapshot('"<span>Obsahuje zanedbateľné množstvá sacharidov, cukrov, bielkovín a soli.</span>"');
293
+ statement3 = (0, _simplifiedDeclarationStatement.simplifiedDeclarationStatement)(_objectSpread(_objectSpread({}, falsy), {}, {
294
+ carbohydratesIsNegligible: true,
295
+ carbohydrateSugarsIsNegligible: true
296
+ }), {
186
297
  language: 'en'
187
- }, '"<span>Contains negligible amounts of carbohydrate and sugars.</span>"');
298
+ });
299
+ (0, _vitest.expect)(statement3).toMatchInlineSnapshot('"<span>Contains negligible amounts of carbohydrate and sugars.</span>"');
188
300
 
189
- case 3:
301
+ case 6:
190
302
  case "end":
191
- return _context6.stop();
303
+ return _context9.stop();
192
304
  }
193
305
  }
194
- }, _callee6);
306
+ }, _callee9);
195
307
  })));
196
308
  });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@bottlebooks/valid-values",
3
3
  "description": "The Bottlebooks lookup values, defined globally.",
4
4
  "private": false,
5
- "version": "10.49.0",
5
+ "version": "10.50.0",
6
6
  "type": "commonjs",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
@@ -37,5 +37,5 @@
37
37
  "dependencies": {
38
38
  "@lingui/core": "3.14.0"
39
39
  },
40
- "gitHead": "b29a9f07ab8b1dcc1a3aef3f7a4381fde5edface"
40
+ "gitHead": "7c9df2824e0f9620c84f049fbf6d549325d8b9b5"
41
41
  }
@@ -1426,6 +1426,7 @@ const allIngredients = {
1426
1426
  ],
1427
1427
  isHiddenInMainList: true,
1428
1428
  synonymDescription: defineMessage({
1429
+ id: 'Bolding the entire term many not be accepted in all countries. Bottlebooks recommends only bolding the allergen.',
1429
1430
  message:
1430
1431
  'Bolding the entire term many not be accepted in all countries. Bottlebooks recommends only bolding the allergen.',
1431
1432
  }),
@@ -1483,6 +1484,7 @@ const allIngredients = {
1483
1484
  ],
1484
1485
  isHiddenInMainList: true,
1485
1486
  synonymDescription: defineMessage({
1487
+ id: 'Bolding the entire term many not be accepted in all countries. Bottlebooks recommends only bolding the allergen.',
1486
1488
  message:
1487
1489
  'Bolding the entire term many not be accepted in all countries. Bottlebooks recommends only bolding the allergen.',
1488
1490
  }),
@@ -1,125 +1,206 @@
1
1
  import { describe, expect, test, beforeEach, afterEach } from 'vitest';
2
2
  import { simplifiedDeclarationStatement } from './simplifiedDeclarationStatement';
3
3
  import { de, en, sk, fr } from 'make-plural/plurals';
4
+ import { messages as messagesDe } from './locales/de';
5
+ import { messages as messagesSk } from './locales/sk';
6
+ import { messages as messagesFr } from './locales/fr';
7
+ import { messages as messagesEn } from './locales/en';
4
8
  import { i18n } from '@lingui/core';
5
9
  const falsy = {
6
10
  fatIsNegligible: false,
7
11
  saltIsNegligible: false,
8
12
  proteinIsNegligible: false,
9
13
  carbohydratesIsNegligible: false,
14
+ carbohydrateSugarsIsNegligible: false,
10
15
  showSimplifiedTable: true,
11
16
  };
12
- const loadLocales = () => {
17
+
18
+ beforeEach(() => {
13
19
  i18n.loadLocaleData('de', { plurals: de });
14
20
  i18n.loadLocaleData('sk', { plurals: sk });
15
21
  i18n.loadLocaleData('fr', { plurals: fr });
16
22
  i18n.loadLocaleData('en', { plurals: en });
17
- console.log('messages loaded for en,de');
18
- };
19
- beforeEach(() => {
20
- loadLocales();
23
+ i18n.load('de', messagesDe);
24
+ i18n.load('sk', messagesSk);
25
+ i18n.load('fr', messagesFr);
26
+ i18n.load('en', messagesEn);
21
27
  });
22
28
 
23
29
  afterEach(() => {
24
- loadLocales();
30
+ i18n.loadLocaleData('de', { plurals: undefined });
31
+ i18n.loadLocaleData('sk', { plurals: undefined });
32
+ i18n.loadLocaleData('fr', { plurals: undefined });
33
+ i18n.loadLocaleData('en', { plurals: undefined });
34
+ i18n.load('de', {});
35
+ i18n.load('sk', {});
36
+ i18n.load('fr', {});
37
+ i18n.load('en', {});
25
38
  });
39
+
26
40
  describe('simplifiedDeclarationStatement', () => {
27
- function _expect(
28
- o: {
29
- fatIsNegligible?: boolean | undefined;
30
- proteinIsNegligible?: boolean | undefined;
31
- saltIsNegligible?: boolean | undefined;
32
- carbohydratesIsNegligible?: boolean | undefined;
33
- saturatedFatIsNegligible?: boolean | undefined;
34
- showSimplifiedTable?: boolean | undefined;
35
- },
36
- opt: { language?: string },
37
- s: string
38
- ) {
41
+ test('simplifiedDeclaration.empty', async () => {
39
42
  const statement = simplifiedDeclarationStatement(
40
- { ...falsy, ...o },
41
- { language: 'en', ...opt }
43
+ { ...falsy },
44
+ { language: 'en' }
42
45
  );
43
- console.log('simplifiedDeclarationStatement:', statement);
44
- return expect(statement).toMatchInlineSnapshot(s);
45
- }
46
-
47
- test('simplifiedDeclaration.empty', async () => {
48
- _expect({}, { language: 'en' }, '""');
46
+ expect(statement).toMatchInlineSnapshot('""');
49
47
  });
50
48
 
51
49
  test('simplifiedDeclaration.fat', async () => {
52
- _expect(
50
+ const statement = simplifiedDeclarationStatement(
53
51
  {
52
+ ...falsy,
54
53
  fatIsNegligible: true,
55
54
  },
56
- { language: 'en' },
55
+ { language: 'en' }
56
+ );
57
+ expect(statement).toMatchInlineSnapshot(
57
58
  '"<span>Contains negligible amounts of fat and saturates.</span>"'
58
59
  );
59
60
  });
60
61
  test('simplifiedDeclaration.fat.protein', async () => {
61
- _expect(
62
+ const statement = simplifiedDeclarationStatement(
62
63
  {
64
+ ...falsy,
63
65
  fatIsNegligible: true,
64
66
  proteinIsNegligible: true,
65
67
  },
66
- { language: 'en' },
68
+ { language: 'en' }
69
+ );
70
+ expect(statement).toMatchInlineSnapshot(
67
71
  '"<span>Contains negligible amounts of fat, saturates and protein.</span>"'
68
72
  );
69
73
  });
70
74
  test('simplifiedDeclaration.fat.salt', async () => {
71
- _expect(
75
+ const statement = simplifiedDeclarationStatement(
72
76
  {
77
+ ...falsy,
73
78
  fatIsNegligible: true,
74
79
  saltIsNegligible: true,
75
80
  },
76
- { language: 'en' },
81
+ { language: 'en' }
82
+ );
83
+ expect(statement).toMatchInlineSnapshot(
77
84
  '"<span>Contains negligible amounts of fat, saturates and salt.</span>"'
78
85
  );
79
86
  });
80
- test('simplifiedDeclaration.fat.protein.carbohydrates', async () => {
81
- _expect(
87
+ test('simplifiedDeclaration.fat.protein.carbohydrates.sugars', async () => {
88
+ const enStatement = simplifiedDeclarationStatement(
82
89
  {
90
+ ...falsy,
83
91
  fatIsNegligible: true,
84
92
  proteinIsNegligible: true,
85
93
  carbohydratesIsNegligible: true,
94
+ carbohydrateSugarsIsNegligible: true,
86
95
  },
87
- { language: 'en' },
96
+ { language: 'en' }
97
+ );
98
+ expect(enStatement).toMatchInlineSnapshot(
88
99
  '"<span>Contains negligible amounts of fat, saturates, carbohydrate, sugars and protein.</span>"'
89
100
  );
90
- _expect(
101
+
102
+ const frStatement = simplifiedDeclarationStatement(
91
103
  {
104
+ ...falsy,
92
105
  fatIsNegligible: true,
93
106
  proteinIsNegligible: true,
94
107
  carbohydratesIsNegligible: true,
108
+ carbohydrateSugarsIsNegligible: true,
95
109
  },
96
- { language: 'fr' },
110
+ { language: 'fr' }
111
+ );
112
+ expect(frStatement).toMatchInlineSnapshot(
97
113
  '"<span>Contient des quantités négligeables de matières grasses, acides gras saturés, glucides, sucres et protéines.</span>"'
98
114
  );
99
115
  });
116
+ test('simplifiedDeclaration.fat.protein.carbohydrates', async () => {
117
+ const enStatement = simplifiedDeclarationStatement(
118
+ {
119
+ ...falsy,
120
+ fatIsNegligible: true,
121
+ proteinIsNegligible: true,
122
+ carbohydratesIsNegligible: true,
123
+ },
124
+ { language: 'en' }
125
+ );
126
+ expect(enStatement).toMatchInlineSnapshot(
127
+ '"<span>Contains negligible amounts of fat, saturates, carbohydrate and protein.</span>"'
128
+ );
129
+
130
+ const frStatement = simplifiedDeclarationStatement(
131
+ {
132
+ ...falsy,
133
+ fatIsNegligible: true,
134
+ proteinIsNegligible: true,
135
+ carbohydratesIsNegligible: true,
136
+ },
137
+ { language: 'fr' }
138
+ );
139
+ expect(frStatement).toMatchInlineSnapshot(
140
+ '"<span>Contient des quantités négligeables de matières grasses, acides gras saturés, glucides et protéines.</span>"'
141
+ );
142
+ });
143
+ test('simplifiedDeclaration.fat.protein.sugars', async () => {
144
+ const statement = simplifiedDeclarationStatement(
145
+ {
146
+ ...falsy,
147
+ fatIsNegligible: true,
148
+ proteinIsNegligible: true,
149
+ carbohydrateSugarsIsNegligible: true,
150
+ },
151
+ { language: 'en' }
152
+ );
153
+ expect(statement).toMatchInlineSnapshot(
154
+ '"<span>Contains negligible amounts of fat, saturates, sugars and protein.</span>"'
155
+ );
156
+ });
157
+ test('simplifiedDeclaration.sugars', async () => {
158
+ const statement = simplifiedDeclarationStatement(
159
+ {
160
+ ...falsy,
161
+ carbohydrateSugarsIsNegligible: true,
162
+ },
163
+ { language: 'en' }
164
+ );
165
+ expect(statement).toMatchInlineSnapshot(
166
+ '"<span>Contains negligible amounts of sugars.</span>"'
167
+ );
168
+ });
100
169
 
101
170
  test('simplifiedDeclaration.protein', async () => {
102
- _expect(
171
+ const statement1 = simplifiedDeclarationStatement(
103
172
  {
173
+ ...falsy,
104
174
  proteinIsNegligible: true,
105
175
  },
106
- { language: 'sk' },
176
+ { language: 'sk' }
177
+ );
178
+ expect(statement1).toMatchInlineSnapshot(
107
179
  '"<span>Obsahuje zanedbateľné množstvá bielkovín.</span>"'
108
180
  );
109
- _expect(
181
+
182
+ const statement2 = simplifiedDeclarationStatement(
110
183
  {
184
+ ...falsy,
111
185
  carbohydratesIsNegligible: true,
186
+ carbohydrateSugarsIsNegligible: true,
112
187
  proteinIsNegligible: true,
113
188
  saltIsNegligible: true,
114
189
  },
115
- { language: 'sk' },
190
+ { language: 'sk' }
191
+ );
192
+ expect(statement2).toMatchInlineSnapshot(
116
193
  '"<span>Obsahuje zanedbateľné množstvá sacharidov, cukrov, bielkovín a soli.</span>"'
117
194
  );
118
- _expect(
195
+ const statement3 = simplifiedDeclarationStatement(
119
196
  {
197
+ ...falsy,
120
198
  carbohydratesIsNegligible: true,
199
+ carbohydrateSugarsIsNegligible: true,
121
200
  },
122
- { language: 'en' },
201
+ { language: 'en' }
202
+ );
203
+ expect(statement3).toMatchInlineSnapshot(
123
204
  '"<span>Contains negligible amounts of carbohydrate and sugars.</span>"'
124
205
  );
125
206
  });
@@ -6,6 +6,7 @@ export function simplifiedDeclarationStatement(
6
6
  proteinIsNegligible,
7
7
  saltIsNegligible,
8
8
  carbohydratesIsNegligible,
9
+ carbohydrateSugarsIsNegligible,
9
10
  showSimplifiedTable,
10
11
  }: {
11
12
  fatIsNegligible?: boolean;
@@ -13,6 +14,7 @@ export function simplifiedDeclarationStatement(
13
14
  saltIsNegligible?: boolean;
14
15
  saturatedFatIsNegligible?: boolean;
15
16
  carbohydratesIsNegligible?: boolean;
17
+ carbohydrateSugarsIsNegligible?: boolean;
16
18
  showSimplifiedTable?: boolean;
17
19
  },
18
20
  { language }: { language: string }
@@ -24,6 +26,7 @@ export function simplifiedDeclarationStatement(
24
26
  language,
25
27
  fatIsNegligible,
26
28
  carbohydratesIsNegligible,
29
+ carbohydrateSugarsIsNegligible,
27
30
  proteinIsNegligible,
28
31
  saltIsNegligible,
29
32
  });
@@ -49,12 +52,14 @@ function getSimplifiedDeclarationItemsText({
49
52
  proteinIsNegligible,
50
53
  saltIsNegligible,
51
54
  carbohydratesIsNegligible,
55
+ carbohydrateSugarsIsNegligible,
52
56
  }: {
53
57
  language: string;
54
58
  fatIsNegligible?: boolean;
55
59
  proteinIsNegligible?: boolean;
56
60
  saltIsNegligible?: boolean;
57
61
  carbohydratesIsNegligible?: boolean;
62
+ carbohydrateSugarsIsNegligible?: boolean;
58
63
  showSimplifiedTable?: boolean;
59
64
  }): string {
60
65
  // fat and saturates
@@ -69,7 +74,7 @@ function getSimplifiedDeclarationItemsText({
69
74
  const carbohidratesTranslation = carbohydratesIsNegligible
70
75
  ? translate('simplifiedDeclaration.carbohydrates', language)
71
76
  : null;
72
- const carbohidrateSugarsTranslation = carbohydratesIsNegligible
77
+ const carbohidrateSugarsTranslation = carbohydrateSugarsIsNegligible
73
78
  ? translate('simplifiedDeclaration.carbohydrateSugars', language)
74
79
  : null;
75
80