alloy 3.0.1 → 3.1.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.
@@ -47,6 +47,16 @@ var KEYBOARD_PROPERTIES = ['keyboardType', 'returnKeyType', 'autocapitalization'
47
47
 
48
48
  // private variables
49
49
  var styleOrderCounter = 1;
50
+
51
+ // The style order counter feeds into the priority value written to every
52
+ // runtime style module. Priorities only order the styles of one component
53
+ // against each other, so the counter restarts for every component right
54
+ // after the global styles. That keeps each component's output independent of
55
+ // the components generated before it, which lets the compiler cache them.
56
+ var componentStyleOrderStart = 1;
57
+ exports.resetStyleOrder = function() {
58
+ styleOrderCounter = componentStyleOrderStart;
59
+ };
50
60
  var platform;
51
61
 
52
62
  exports.setPlatform = function(p) {
@@ -139,7 +149,7 @@ exports.loadGlobalStyles = function(appPath, opts) {
139
149
  // get rid of entries that don't exist
140
150
  var len = loadArray.length;
141
151
  for (var i = len - 1; i >= 0; i--) {
142
- if (!path.existsSync(loadArray[i].path)) {
152
+ if (!fs.existsSync(loadArray[i].path)) {
143
153
  loadArray.splice(i, 1);
144
154
  }
145
155
  }
@@ -148,21 +158,24 @@ exports.loadGlobalStyles = function(appPath, opts) {
148
158
  var hash = U.createHash(_.map(loadArray, 'path'));
149
159
 
150
160
  // see if we can use the cached global style
151
- if (buildlog.data.globalStyleCacheHash === hash && fs.existsSync(cacheFile)) {
161
+ if (buildlog.data.globalStyleCacheHash === hash && fs.existsSync(cacheFile) &&
162
+ _.isNumber(buildlog.data.globalStyleOrder)) {
152
163
  // load global style object from cache
153
164
  logger.info('[global style] loading from cache...');
154
165
  exports.globalStyle = JSON.parse(fs.readFileSync(cacheFile, 'utf8'));
155
166
  ret = true;
156
167
 
157
- // increment the style order counter with the number of rules in the global style
158
- styleOrderCounter += exports.globalStyle.length;
168
+ // advance the style order counter exactly as processing the files
169
+ // would have, so the priorities of all component styles stay stable
170
+ styleOrderCounter += buildlog.data.globalStyleOrder;
159
171
  } else {
160
172
  // add new hash to the buildlog
161
173
  buildlog.data.globalStyleCacheHash = hash;
174
+ var styleOrderStart = styleOrderCounter;
162
175
 
163
176
  // create the new global style object
164
177
  _.each(loadArray, function(g) {
165
- if (path.existsSync(g.path)) {
178
+ if (fs.existsSync(g.path)) {
166
179
  logger.info('[' + g.msg + '] global style processing...');
167
180
  exports.globalStyle = exports.loadAndSortStyle(g.path, _.extend(
168
181
  { existingStyle: exports.globalStyle },
@@ -177,7 +190,9 @@ exports.loadGlobalStyles = function(appPath, opts) {
177
190
 
178
191
  // simply increment the style order counter
179
192
  styleOrderCounter++;
193
+ buildlog.data.globalStyleOrder = styleOrderCounter - styleOrderStart;
180
194
  }
195
+ componentStyleOrderStart = styleOrderCounter;
181
196
 
182
197
  return ret;
183
198
  };
@@ -195,63 +210,91 @@ exports.sortStyles = function(style, opts) {
195
210
  var sortedStyles = [];
196
211
  opts = opts || {};
197
212
 
213
+ function splitSelectors(key) {
214
+ const result = [];
215
+ let current = '';
216
+ let depth = 0;
217
+
218
+ for (let i = 0, len = key.length; i < len; i++) {
219
+ const char = key[i];
220
+
221
+ if (char === '[') {
222
+ depth++;
223
+ } else if (char === ']') {
224
+ depth--;
225
+ } else if (char === ',' && depth === 0) {
226
+ if (current.trim()) { result.push(current.trim()); }
227
+ current = '';
228
+ continue;
229
+ }
230
+
231
+ current += char;
232
+ }
233
+
234
+ if (current.trim()) { result.push(current.trim()); }
235
+ return result;
236
+ }
237
+
198
238
  if (_.isObject(style) && !_.isEmpty(style)) {
199
239
  for (var key in style) {
200
- var obj = {};
201
- var priority = styleOrderCounter++ * VALUES.ORDER;
202
- var match = key.match(STYLE_REGEX);
203
- if (match === null) {
204
- U.die('Invalid style specifier "' + key + '"');
205
- }
206
- var newKey = match[2];
207
-
208
- // skip any invalid style entries
209
- if (newKey === 'undefined' && !match[1]) { continue; }
210
-
211
- // get the style key type
212
- switch (match[1]) {
213
- case '#':
214
- obj.isId = true;
215
- priority += VALUES.ID;
216
- break;
217
- case '.':
218
- obj.isClass = true;
219
- priority += VALUES.CLASS;
220
- break;
221
- default:
222
- if (match[2]) {
223
- obj.isApi = true;
224
- priority += VALUES.API;
225
- }
226
- break;
227
- }
240
+ var keys = splitSelectors(key);
241
+ _.each(keys, function(singleKey) {
242
+ var obj = {};
243
+ var priority = styleOrderCounter++ * VALUES.ORDER;
244
+ var match = singleKey.match(STYLE_REGEX);
245
+ if (match === null) {
246
+ U.die('Invalid style specifier "' + singleKey + '"');
247
+ }
248
+ var newKey = match[2];
249
+
250
+ if (newKey === 'undefined' && !match[1]) { return; }
251
+
252
+ switch (match[1]) {
253
+ case '#':
254
+ obj.isId = true;
255
+ priority += VALUES.ID;
256
+ break;
257
+ case '.':
258
+ obj.isClass = true;
259
+ priority += VALUES.CLASS;
260
+ break;
261
+ default:
262
+ if (match[2]) {
263
+ obj.isApi = true;
264
+ priority += VALUES.API;
265
+ }
266
+ break;
267
+ }
228
268
 
229
- if (match[3]) {
230
- obj.queries = {};
231
- _.each(match[3].replace(/\s*,\s*/g, ',').split(/\s+/), function(query) {
232
- var parts = query.split('=');
233
- var q = U.trim(parts[0]);
234
- var v = U.trim(parts[1]);
235
- if (q === 'platform') {
236
- priority += VALUES.PLATFORM + VALUES.SUM;
237
- v = v.split(',');
238
- } else if (q === 'formFactor') {
239
- priority += VALUES.FORMFACTOR + VALUES.SUM;
240
- } else if (q === 'if') {
241
- priority += VALUES.TSSIF + VALUES.SUM;
242
- } else {
243
- priority += VALUES.SUM;
244
- }
245
- obj.queries[q] = v;
246
- });
247
- }
269
+ if (match[3]) {
270
+ obj.queries = {};
271
+ _.each(match[3].replace(/\s*,\s*/g, ',').split(/\s+/), function(query) {
272
+ var parts = query.split('=');
273
+ var q = U.trim(parts[0]);
274
+ var v = U.trim(parts[1]);
275
+ if (q === 'platform') {
276
+ priority += VALUES.PLATFORM + VALUES.SUM;
277
+ v = v.split(',');
278
+ } else if (q === 'formFactor') {
279
+ priority += VALUES.FORMFACTOR + VALUES.SUM;
280
+ } else if (q === 'if') {
281
+ priority += VALUES.TSSIF + VALUES.SUM;
282
+ } else {
283
+ priority += VALUES.SUM;
284
+ }
285
+ obj.queries[q] = v;
286
+ });
287
+ }
248
288
 
249
- _.extend(obj, {
250
- priority: priority + (opts.platform ? VALUES.PLATFORM : 0) + (opts.theme ? VALUES.THEME : 0),
251
- key: newKey,
252
- style: style[key]
289
+ _.extend(obj, {
290
+ priority: priority + (opts.platform ? VALUES.PLATFORM : 0) + (opts.theme ? VALUES.THEME : 0),
291
+ key: newKey,
292
+ // clone so entries from one comma-separated key don't share
293
+ // (and mutate) the same style object
294
+ style: keys.length > 1 ? _.cloneDeep(style[key]) : style[key]
295
+ });
296
+ sortedStyles.push(obj);
253
297
  });
254
- sortedStyles.push(obj);
255
298
  }
256
299
  }
257
300
 
@@ -260,7 +303,7 @@ exports.sortStyles = function(style, opts) {
260
303
  };
261
304
 
262
305
  exports.loadStyle = function(tssFile) {
263
- if (path.existsSync(tssFile)) {
306
+ if (fs.existsSync(tssFile)) {
264
307
  // read the style file
265
308
  var contents;
266
309
  var originalContents;
@@ -0,0 +1,76 @@
1
+ const {
2
+ exec,
3
+ execSync
4
+ } = require('child_process');
5
+ const U = require('../../utils');
6
+ const tiapp = require('../../tiapp');
7
+ const fs = require('fs');
8
+ const os = require('os');
9
+ const path = require('path');
10
+
11
+ module.exports = async function(args, program) {
12
+ if (args.length === 0) {
13
+ U.die('Missing parameter "get"');
14
+ return;
15
+ }
16
+
17
+ if (!args.includes('get')) {
18
+ return;
19
+ }
20
+
21
+ try {
22
+ tiapp.init();
23
+ const bundleId = tiapp.getBundleId();
24
+ const adbPath = getAdbPath();
25
+
26
+ console.log('Downloading _alloy_ database to: ' + bundleId + '.db');
27
+ execCommand(adbPath + ' shell "run-as ' + bundleId + ' cat /data/data/' + bundleId + '/databases/_alloy_" > ' + bundleId + '.db');
28
+ } catch (error) {
29
+ console.error('Failed to get database: ' + error);
30
+ }
31
+ };
32
+
33
+ function getAdbPath() {
34
+ if (os.platform() !== 'darwin') {
35
+ return 'adb';
36
+ }
37
+
38
+ // try to get android.sdkPath from ti config
39
+ let sdkPath;
40
+ const output = execSync('ti config android.sdkPath --json');
41
+ const jsonObject = JSON.parse(output);
42
+ if (!Object.hasOwn(jsonObject, 'success')) {
43
+ // found string
44
+ sdkPath = jsonObject;
45
+ }
46
+
47
+ // fall back to the default location (the folder has been spelled "sdk" and "Sdk" over the years)
48
+ if (!sdkPath) {
49
+ sdkPath = ['sdk', 'Sdk']
50
+ .map(dir => path.join(os.homedir(), 'Library', 'Android', dir))
51
+ .find(dir => fs.existsSync(dir)) || path.join(os.homedir(), 'Library', 'Android', 'sdk');
52
+ }
53
+
54
+ // check if adb is in that folder
55
+ const adbPath = path.join(sdkPath, 'platform-tools', 'adb');
56
+ if (!fs.existsSync(adbPath)) {
57
+ U.die('adb not found at ' + adbPath + '. Please check "ti config android.sdkPath" and point to your SDK folder.');
58
+ }
59
+ return adbPath;
60
+ }
61
+
62
+ function execCommand(currentCommand) {
63
+ exec(currentCommand, (error, response) => {
64
+ if (error) {
65
+ if (error.message) {
66
+ console.error(error.message);
67
+ } else {
68
+ console.error("Couldn't fetch database");
69
+ }
70
+ }
71
+ if (response) {
72
+ console.log(response);
73
+ }
74
+ return true;
75
+ });
76
+ }
@@ -10,7 +10,7 @@ module.exports = function(name, args, program) {
10
10
  var templatePath = path.join(alloyRoot, 'template', filename);
11
11
 
12
12
  // only overwrite if using force option
13
- if (path.existsSync(filepath) && !program.force) {
13
+ if (fs.existsSync(filepath) && !program.force) {
14
14
  U.die('"alloy.jmk" file already exists. Use "-f,--force" to overwrite.');
15
15
  }
16
16
 
@@ -46,7 +46,7 @@ module.exports = function(name, args, program) {
46
46
 
47
47
  // make sure the target folder exists
48
48
  var fullDir = path.dirname(style_path);
49
- if (!path.existsSync(fullDir)) {
49
+ if (!fs.existsSync(fullDir)) {
50
50
  fs.mkdirpSync(fullDir);
51
51
  }
52
52
  targets.push({
@@ -15,7 +15,7 @@ module.exports = function(name, args, program) {
15
15
  var paths = getPaths(thePaths.app, widgetId);
16
16
 
17
17
  // don't overwrite an existing widget unless force is specified
18
- if (path.existsSync(paths.widget) && !program.force) {
18
+ if (fs.existsSync(paths.widget) && !program.force) {
19
19
  U.die('Widget already exists: ' + paths.widget);
20
20
  }
21
21
 
@@ -45,7 +45,7 @@ module.exports = function(name, args, program) {
45
45
  );
46
46
 
47
47
  // Add this widget as a dependency to our project
48
- var configReadPath = path.existsSync(paths.config) ? paths.config : paths.configTemplate;
48
+ var configReadPath = fs.existsSync(paths.config) ? paths.config : paths.configTemplate;
49
49
  var content = fs.readFileSync(configReadPath, 'utf8');
50
50
  try {
51
51
  var json = jsonlint.parse(content);
@@ -1,7 +1,12 @@
1
1
  const { exec } = require('child_process');
2
2
  const U = require('../../utils');
3
+ const logger = require('../../logger');
3
4
 
4
5
  module.exports = async function(args, program) {
6
+ logger.warn([
7
+ '`alloy purgetss` is deprecated. Run `purgetss` directly instead.',
8
+ 'Use `purgetss --help` for the current commands and options.'
9
+ ]);
5
10
  let options = '';
6
11
  try {
7
12
  if (args.length === 0) {
@@ -236,15 +236,18 @@ function Sync(method, model, opts) {
236
236
  }
237
237
 
238
238
  // iterate through all queried rows
239
- while (rs.isValidRow()) {
240
- var o = {};
241
- for (i = 0; i < fieldCount; i++) {
242
- o[fieldNames[i]] = rs.field(i);
239
+ try {
240
+ while (rs.isValidRow()) {
241
+ var o = {};
242
+ for (i = 0; i < fieldCount; i++) {
243
+ o[fieldNames[i]] = rs.field(i);
244
+ }
245
+ values.push(o);
246
+ rs.next();
243
247
  }
244
- values.push(o);
245
- rs.next();
248
+ } finally {
249
+ rs.close();
246
250
  }
247
- rs.close();
248
251
 
249
252
  // shape response based on whether it's a model or collection
250
253
  var len = values.length;
@@ -202,6 +202,12 @@ exports.C = function(name, modelDesc, model) {
202
202
  return Collection;
203
203
  };
204
204
 
205
+ function resolveNS(ns) {
206
+ var parts = ns.split('.'), obj = global, i = 0;
207
+ for (; i < parts.length; i++) { obj = obj[parts[i]]; }
208
+ return obj;
209
+ }
210
+
205
211
  exports.UI = {};
206
212
  exports.UI.create = function(controller, apiName, opts) {
207
213
  opts = opts || {};
@@ -225,7 +231,7 @@ exports.UI.create = function(controller, apiName, opts) {
225
231
  var style = exports.createStyle(controller, opts);
226
232
 
227
233
  // create the titanium proxy object
228
- return eval(ns)['create' + baseName](style);
234
+ return resolveNS(ns)['create' + baseName](style);
229
235
  };
230
236
 
231
237
  exports.createStyle = function(controller, opts, defaults) {
package/Alloy/tiapp.js CHANGED
@@ -39,6 +39,24 @@ tiapp.getSdkVersion = function() {
39
39
  }
40
40
  };
41
41
 
42
+ tiapp.getBundleId = function() {
43
+ var elems = doc.documentElement.getElementsByTagName('id');
44
+ if (elems && elems.length > 0) {
45
+ var bundleId = U.XML.getNodeText(elems.item(elems.length - 1));
46
+ var isForced = false;
47
+ for (var i = 0; i < elems.length; i++) {
48
+ if (elems.item(i).getAttribute('platform') === 'android') {
49
+ // platform specific ID
50
+ isForced = true;
51
+ bundleId = U.XML.getNodeText(elems.item(i));
52
+ } else if (elems.item(i).getAttribute('platform') === '' && !isForced) {
53
+ // normal ID - only if no platform specific was set already
54
+ bundleId = U.XML.getNodeText(elems.item(i));
55
+ }
56
+ }
57
+ return bundleId;
58
+ }
59
+ };
42
60
 
43
61
  // Get the value of a property from the tiapp.xml
44
62
  tiapp.getProperty = function(name) {
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## Unreleased
2
+
3
+ ### Deprecated
4
+
5
+ * Deprecate the `alloy purgetss` shortcut. Use the standalone `purgetss` CLI instead.
6
+
1
7
  # [2.1.0](https://github.com/tidev/alloy/compare/2.0.2...2.1.0) (2024-01-09)
2
8
 
3
9
 
package/README.md CHANGED
@@ -23,6 +23,10 @@ Alloy is an MVC application framework by [TiDev](https://tidev.io) for the [Tita
23
23
  [sudo] npm install -g git://github.com/tidev/alloy.git
24
24
  ```
25
25
 
26
+ ## PurgeTSS
27
+
28
+ The `alloy purgetss` shortcut is deprecated and remains available for compatibility. Install the standalone CLI with `npm install -g purgetss`, then run `purgetss` directly from your Alloy project directory. Use `purgetss --help` for the current commands and options.
29
+
26
30
  ## Running Sample Test Apps
27
31
 
28
32
  Alloy includes many sample and test apps in the **sample/apps** folder (see above). For example, [basics/simple](https://github.com/tidev/alloy/tree/master/samples/apps/basics/simple). You can run these in a few different ways:
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "html5",
12
12
  "appc-client"
13
13
  ],
14
- "version": "3.0.1",
14
+ "version": "3.1.0",
15
15
  "author": "TiDev, Inc. <npm@tidev.io>",
16
16
  "bugs": {
17
17
  "url": "https://github.com/tidev/alloy/issues"
@@ -0,0 +1,74 @@
1
+ var fs = require('fs'),
2
+ os = require('os'),
3
+ path = require('path'),
4
+ spawnSync = require('child_process').spawnSync;
5
+
6
+ describe('alloy purgetss deprecation', function() {
7
+ var directory, callsFile, outputFile;
8
+
9
+ beforeEach(function() {
10
+ directory = fs.mkdtempSync(path.join(os.tmpdir(), 'alloy-purgetss-'));
11
+ callsFile = path.join(directory, 'calls.jsonl');
12
+ outputFile = path.join(directory, 'output.txt');
13
+ var script = path.join(directory, 'fake-purgetss.js');
14
+ fs.writeFileSync(script, '#!' + process.execPath + '\n' +
15
+ 'const fs = require("fs");\n' +
16
+ 'fs.appendFileSync(process.env.PURGETSS_TEST_CALLS, JSON.stringify(process.argv.slice(2)) + "\\n");\n' +
17
+ 'console.log("PurgeTSS test executable ran");\n');
18
+ if (process.platform === 'win32') {
19
+ fs.writeFileSync(path.join(directory, 'purgetss.cmd'), '@"' + process.execPath + '" "' + script + '" %*\r\n');
20
+ } else {
21
+ fs.copyFileSync(script, path.join(directory, 'purgetss'));
22
+ fs.chmodSync(path.join(directory, 'purgetss'), 0o755);
23
+ }
24
+ });
25
+
26
+ afterEach(function() {
27
+ fs.rmSync(directory, { recursive: true, force: true });
28
+ });
29
+
30
+ function run(args) {
31
+ var descriptor = fs.openSync(outputFile, 'w');
32
+ var result;
33
+ try {
34
+ result = spawnSync(process.execPath, [path.resolve(__dirname, '../../bin/alloy'), '-n'].concat(args), {
35
+ cwd: directory,
36
+ env: Object.assign({}, process.env, { PATH: directory, PURGETSS_TEST_CALLS: callsFile }),
37
+ stdio: ['ignore', descriptor, descriptor],
38
+ timeout: 5000
39
+ });
40
+ } finally {
41
+ fs.closeSync(descriptor);
42
+ }
43
+ expect(result.error).toBeUndefined();
44
+ expect(result.status).toBe(0);
45
+ return fs.readFileSync(outputFile, 'utf8');
46
+ }
47
+
48
+ [
49
+ { args: [], forwarded: [] },
50
+ { args: ['build'], forwarded: ['build'] }
51
+ ].forEach(function(testCase) {
52
+ it('warns before forwarding ' + (testCase.args[0] || 'the default command'), function() {
53
+ var output = run(['purgetss'].concat(testCase.args));
54
+ expect(output).toMatch(/alloy purgetss.*deprecated/i);
55
+ expect(output).toMatch(/purgetss --help/);
56
+ expect(output.indexOf('deprecated')).toBeLessThan(output.indexOf('PurgeTSS test executable ran'));
57
+ var calls = fs.readFileSync(callsFile, 'utf8').trim().split('\n').map(JSON.parse);
58
+ expect(calls).toEqual([testCase.forwarded]);
59
+ });
60
+ });
61
+
62
+ it('marks the shortcut deprecated in the command list', function() {
63
+ var output = run(['--help']);
64
+ expect(output).toMatch(/purgetss[^\n]*[Dd]eprecated/);
65
+ expect(fs.existsSync(callsFile)).toBe(false);
66
+ });
67
+
68
+ it('directs command help to the standalone CLI without running it', function() {
69
+ var output = run(['purgetss', '--help']);
70
+ expect(output).toMatch(/deprecated/i);
71
+ expect(output).toMatch(/purgetss --help/);
72
+ expect(fs.existsSync(callsFile)).toBe(false);
73
+ });
74
+ });
@@ -0,0 +1,94 @@
1
+ var fs = require('fs'),
2
+ path = require('path'),
3
+ vm = require('vm'),
4
+ _ = require('lodash'),
5
+ TU = require('../lib/testUtils');
6
+
7
+ var TIMEOUT_COMPILE = 20000;
8
+ var TIMEOUT_PREP = 30000;
9
+ var APP = 'testing/require-conditional-children';
10
+
11
+ // Runs the generated index controller with just enough of Alloy and Titanium stubbed to see
12
+ // which children each <Require> receives.
13
+ function runIndexController(cfg) {
14
+ var file = path.join(TU.paths.harness, 'Resources', 'android', 'alloy', 'controllers', 'index.js');
15
+ var created = {};
16
+ var alloy = {
17
+ _: _,
18
+ Backbone: {},
19
+ CFG: cfg,
20
+ createController: function(name, args) {
21
+ if (args && args.id) {
22
+ created[args.id] = args;
23
+ }
24
+ return {
25
+ getViewEx: function() { return { controller: name }; },
26
+ setParent: function() {}
27
+ };
28
+ }
29
+ };
30
+ var baseController = function() {
31
+ this.__views = {};
32
+ this.addTopLevelView = function() {};
33
+ };
34
+ var sandbox = {
35
+ module: { exports: {} },
36
+ require: function(name) {
37
+ return /BaseController$/.test(name) ? baseController : alloy;
38
+ },
39
+ Ti: {
40
+ UI: {
41
+ createWindow: function() { return { open: function() {} }; },
42
+ createLabel: function(props) { return props; }
43
+ }
44
+ }
45
+ };
46
+ vm.runInNewContext(fs.readFileSync(file, 'utf8'), sandbox, file);
47
+ new sandbox.module.exports();
48
+
49
+ // name each child passed to a <Require>: a controller by its name, a label by its text
50
+ return _.mapValues(created, function(args) {
51
+ return args.children && _.map(args.children, function(child) {
52
+ return child.controller || child.text;
53
+ });
54
+ });
55
+ }
56
+
57
+ describe('<Require> children', function() {
58
+ it('preparing test app', function() {
59
+ TU.asyncExecTest('jake app:setup dir=' + APP + ' quiet=1', { timeout: TIMEOUT_PREP });
60
+ });
61
+
62
+ it('compiles without critical error', function() {
63
+ TU.asyncExecTest('alloy compile ' + TU.paths.harness + ' --config platform=android', {
64
+ test: function() {
65
+ if (this.output.error) {
66
+ console.error(this.output.stderr);
67
+ console.log(this.output.stdout);
68
+ }
69
+ expect(this.output.error).toBeFalsy();
70
+ },
71
+ timeout: TIMEOUT_COMPILE
72
+ });
73
+ });
74
+
75
+ it('does not reference a child whose condition is false', function() {
76
+ var created;
77
+ expect(function() {
78
+ created = runIndexController({ showBadge: false });
79
+ }).not.toThrow();
80
+ expect(created.cardWithoutChildren).toEqual([]);
81
+ expect(created.cardWithChild).toEqual(['badge']);
82
+ });
83
+
84
+ it('passes a child whose condition is true', function() {
85
+ var created = runIndexController({ showBadge: true });
86
+ expect(created.cardWithoutChildren).toEqual(['badge', 'label']);
87
+ expect(created.cardWithChild).toEqual([]);
88
+ });
89
+
90
+ it('passes unconditional children as before', function() {
91
+ var created = runIndexController({ showBadge: false });
92
+ expect(created.cardWithLabel).toEqual(['label']);
93
+ });
94
+ });