From 003f594f6348b55109dd66416e75fcc2a88faade Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 26 Nov 2022 23:44:08 -0400 Subject: finish up cosmetic style changes --- test/cacheable-object.js | 416 +++++++++++++++++++++++------------------------ test/data-validators.js | 376 +++++++++++++++++++++--------------------- test/things.js | 82 +++++----- 3 files changed, 437 insertions(+), 437 deletions(-) (limited to 'test') diff --git a/test/cacheable-object.js b/test/cacheable-object.js index dd93343f..664a648b 100644 --- a/test/cacheable-object.js +++ b/test/cacheable-object.js @@ -5,270 +5,270 @@ import CacheableObject from '../src/data/cacheable-object.js'; // Utility function newCacheableObject(PD) { - return new (class extends CacheableObject { - static propertyDescriptors = PD; - }); + return new (class extends CacheableObject { + static propertyDescriptors = PD; + }); } // Tests test(`CacheableObject simple separate update & expose`, t => { - const obj = newCacheableObject({ - number: { - flags: { - update: true - } - }, - - timesTwo: { - flags: { - expose: true - }, - - expose: { - dependencies: ['number'], - compute: ({ number }) => number * 2 - } - } - }); + const obj = newCacheableObject({ + number: { + flags: { + update: true + } + }, + + timesTwo: { + flags: { + expose: true + }, + + expose: { + dependencies: ['number'], + compute: ({ number }) => number * 2 + } + } + }); - t.plan(1); - obj.number = 5; - t.equal(obj.timesTwo, 10); + t.plan(1); + obj.number = 5; + t.equal(obj.timesTwo, 10); }); test(`CacheableObject basic cache behavior`, t => { - let computeCount = 0; - - const obj = newCacheableObject({ - string: { - flags: { - update: true - } - }, - - karkat: { - flags: { - expose: true - }, - - expose: { - dependencies: ['string'], - compute: ({ string }) => { - computeCount++; - return string.toUpperCase(); - } - } + let computeCount = 0; + + const obj = newCacheableObject({ + string: { + flags: { + update: true + } + }, + + karkat: { + flags: { + expose: true + }, + + expose: { + dependencies: ['string'], + compute: ({ string }) => { + computeCount++; + return string.toUpperCase(); } - }); + } + } + }); - t.plan(8); + t.plan(8); - t.is(computeCount, 0); + t.is(computeCount, 0); - obj.string = 'hello world'; - t.is(computeCount, 0); + obj.string = 'hello world'; + t.is(computeCount, 0); - obj.karkat; - t.is(computeCount, 1); + obj.karkat; + t.is(computeCount, 1); - obj.karkat; - t.is(computeCount, 1); + obj.karkat; + t.is(computeCount, 1); - obj.string = 'testing once again'; - t.is(computeCount, 1); + obj.string = 'testing once again'; + t.is(computeCount, 1); - obj.karkat; - t.is(computeCount, 2); + obj.karkat; + t.is(computeCount, 2); - obj.string = 'testing once again'; - t.is(computeCount, 2); + obj.string = 'testing once again'; + t.is(computeCount, 2); - obj.karkat; - t.is(computeCount, 2); + obj.karkat; + t.is(computeCount, 2); }); test(`CacheableObject combined update & expose (no transform)`, t => { - const obj = newCacheableObject({ - directory: { - flags: { - update: true, - expose: true - } - } - }); + const obj = newCacheableObject({ + directory: { + flags: { + update: true, + expose: true + } + } + }); - t.plan(2); + t.plan(2); - t.directory = 'the-world-revolving'; - t.is(t.directory, 'the-world-revolving'); + t.directory = 'the-world-revolving'; + t.is(t.directory, 'the-world-revolving'); - t.directory = 'chaos-king'; - t.is(t.directory, 'chaos-king'); + t.directory = 'chaos-king'; + t.is(t.directory, 'chaos-king'); }); test(`CacheableObject combined update & expose (basic transform)`, t => { - const obj = newCacheableObject({ - getsRepeated: { - flags: { - update: true, - expose: true - }, - - expose: { - transform: value => value.repeat(2) - } - } - }); + const obj = newCacheableObject({ + getsRepeated: { + flags: { + update: true, + expose: true + }, + + expose: { + transform: value => value.repeat(2) + } + } + }); - t.plan(1); + t.plan(1); - obj.getsRepeated = 'dog'; - t.is(obj.getsRepeated, 'dogdog'); + obj.getsRepeated = 'dog'; + t.is(obj.getsRepeated, 'dogdog'); }); test(`CacheableObject combined update & expose (transform with dependency)`, t => { - const obj = newCacheableObject({ - customRepeat: { - flags: { - update: true, - expose: true - }, - - expose: { - dependencies: ['times'], - transform: (value, { times }) => value.repeat(times) - } - }, - - times: { - flags: { - update: true - } - } - }); + const obj = newCacheableObject({ + customRepeat: { + flags: { + update: true, + expose: true + }, + + expose: { + dependencies: ['times'], + transform: (value, { times }) => value.repeat(times) + } + }, + + times: { + flags: { + update: true + } + } + }); - t.plan(3); + t.plan(3); - obj.customRepeat = 'dog'; - obj.times = 1; - t.is(obj.customRepeat, 'dog'); + obj.customRepeat = 'dog'; + obj.times = 1; + t.is(obj.customRepeat, 'dog'); - obj.times = 5; - t.is(obj.customRepeat, 'dogdogdogdogdog'); + obj.times = 5; + t.is(obj.customRepeat, 'dogdogdogdogdog'); - obj.customRepeat = 'cat'; - t.is(obj.customRepeat, 'catcatcatcatcat'); + obj.customRepeat = 'cat'; + t.is(obj.customRepeat, 'catcatcatcatcat'); }); test(`CacheableObject validate on update`, t => { - const mockError = new TypeError(`Expected a string, not ${typeof value}`); - - const obj = newCacheableObject({ - directory: { - flags: { - update: true, - expose: true - }, - - update: { - validate: value => { - if (typeof value !== 'string') { - throw mockError; - } - return true; - } - } - }, - - date: { - flags: { - update: true, - expose: true - }, - - update: { - validate: value => (value instanceof Date) - } + const mockError = new TypeError(`Expected a string, not ${typeof value}`); + + const obj = newCacheableObject({ + directory: { + flags: { + update: true, + expose: true + }, + + update: { + validate: value => { + if (typeof value !== 'string') { + throw mockError; + } + return true; } - }); + } + }, + + date: { + flags: { + update: true, + expose: true + }, + + update: { + validate: value => (value instanceof Date) + } + } + }); - let thrownError; - t.plan(6); + let thrownError; + t.plan(6); - obj.directory = 'megalovania'; - t.is(obj.directory, 'megalovania'); + obj.directory = 'megalovania'; + t.is(obj.directory, 'megalovania'); - try { - obj.directory = 25; - } catch (err) { - thrownError = err; - } + try { + obj.directory = 25; + } catch (err) { + thrownError = err; + } - t.is(thrownError, mockError); - t.is(obj.directory, 'megalovania'); + t.is(thrownError, mockError); + t.is(obj.directory, 'megalovania'); - const date = new Date(`25 December 2009`); + const date = new Date(`25 December 2009`); - obj.date = date; - t.is(obj.date, date); + obj.date = date; + t.is(obj.date, date); - try { - obj.date = `TWELFTH PERIGEE'S EVE`; - } catch (err) { - thrownError = err; - } + try { + obj.date = `TWELFTH PERIGEE'S EVE`; + } catch (err) { + thrownError = err; + } - t.is(thrownError?.constructor, TypeError); - t.is(obj.date, date); + t.is(thrownError?.constructor, TypeError); + t.is(obj.date, date); }); test(`CacheableObject default update property value`, t => { - const obj = newCacheableObject({ - fruit: { - flags: { - update: true, - expose: true - }, - - update: { - default: 'potassium' - } - } - }); + const obj = newCacheableObject({ + fruit: { + flags: { + update: true, + expose: true + }, + + update: { + default: 'potassium' + } + } + }); - t.plan(1); - t.is(obj.fruit, 'potassium'); + t.plan(1); + t.is(obj.fruit, 'potassium'); }); test(`CacheableObject default property throws if invalid`, t => { - const mockError = new TypeError(`Expected a string, not ${typeof value}`); - - t.plan(1); - - let thrownError; - - try { - newCacheableObject({ - string: { - flags: { - update: true - }, - - update: { - default: 123, - validate: value => { - if (typeof value !== 'string') { - throw mockError; - } - return true; - } - } + const mockError = new TypeError(`Expected a string, not ${typeof value}`); + + t.plan(1); + + let thrownError; + + try { + newCacheableObject({ + string: { + flags: { + update: true + }, + + update: { + default: 123, + validate: value => { + if (typeof value !== 'string') { + throw mockError; } - }); - } catch (err) { - thrownError = err; - } + return true; + } + } + } + }); + } catch (err) { + thrownError = err; + } - t.is(thrownError, mockError); + t.is(thrownError, mockError); }); diff --git a/test/data-validators.js b/test/data-validators.js index a7b9b48d..f13f3f0f 100644 --- a/test/data-validators.js +++ b/test/data-validators.js @@ -2,41 +2,41 @@ import _test from 'tape'; import { showAggregate } from '../src/util/sugar.js'; import { - // Basic types - isBoolean, - isCountingNumber, - isNumber, - isString, - isStringNonEmpty, - - // Complex types - isArray, - isObject, - validateArrayItems, - - // Wiki data - isDimensions, - isDirectory, - isDuration, - isFileExtension, - validateReference, - validateReferenceList, - - // Compositional utilities - oneOf, + // Basic types + isBoolean, + isCountingNumber, + isNumber, + isString, + isStringNonEmpty, + + // Complex types + isArray, + isObject, + validateArrayItems, + + // Wiki data + isDimensions, + isDirectory, + isDuration, + isFileExtension, + validateReference, + validateReferenceList, + + // Compositional utilities + oneOf, } from '../src/data/validators.js'; function test(msg, fn) { - _test(msg, t => { - try { - fn(t); - } catch (error) { - if (error instanceof AggregateError) { - showAggregate(error); - } - throw error; - } - }); + _test(msg, t => { + try { + fn(t); + } catch (error) { + if (error instanceof AggregateError) { + showAggregate(error); + } + throw error; + } + }); } test.skip = _test.skip; @@ -44,234 +44,234 @@ test.skip = _test.skip; // Basic types test('isBoolean', t => { - t.plan(4); - t.ok(isBoolean(true)); - t.ok(isBoolean(false)); - t.throws(() => isBoolean(1), TypeError); - t.throws(() => isBoolean('yes'), TypeError); + t.plan(4); + t.ok(isBoolean(true)); + t.ok(isBoolean(false)); + t.throws(() => isBoolean(1), TypeError); + t.throws(() => isBoolean('yes'), TypeError); }); test('isNumber', t => { - t.plan(6); - t.ok(isNumber(123)); - t.ok(isNumber(0.05)); - t.ok(isNumber(0)); - t.ok(isNumber(-10)); - t.throws(() => isNumber('413'), TypeError); - t.throws(() => isNumber(true), TypeError); + t.plan(6); + t.ok(isNumber(123)); + t.ok(isNumber(0.05)); + t.ok(isNumber(0)); + t.ok(isNumber(-10)); + t.throws(() => isNumber('413'), TypeError); + t.throws(() => isNumber(true), TypeError); }); test('isCountingNumber', t => { - t.plan(6); - t.ok(isCountingNumber(3)); - t.ok(isCountingNumber(1)); - t.throws(() => isCountingNumber(1.75), TypeError); - t.throws(() => isCountingNumber(0), TypeError); - t.throws(() => isCountingNumber(-1), TypeError); - t.throws(() => isCountingNumber('612'), TypeError); + t.plan(6); + t.ok(isCountingNumber(3)); + t.ok(isCountingNumber(1)); + t.throws(() => isCountingNumber(1.75), TypeError); + t.throws(() => isCountingNumber(0), TypeError); + t.throws(() => isCountingNumber(-1), TypeError); + t.throws(() => isCountingNumber('612'), TypeError); }); test('isString', t => { - t.plan(3); - t.ok(isString('hello!')); - t.ok(isString('')); - t.throws(() => isString(100), TypeError); + t.plan(3); + t.ok(isString('hello!')); + t.ok(isString('')); + t.throws(() => isString(100), TypeError); }); test('isStringNonEmpty', t => { - t.plan(4); - t.ok(isStringNonEmpty('hello!')); - t.throws(() => isStringNonEmpty(''), TypeError); - t.throws(() => isStringNonEmpty(' '), TypeError); - t.throws(() => isStringNonEmpty(100), TypeError); + t.plan(4); + t.ok(isStringNonEmpty('hello!')); + t.throws(() => isStringNonEmpty(''), TypeError); + t.throws(() => isStringNonEmpty(' '), TypeError); + t.throws(() => isStringNonEmpty(100), TypeError); }); // Complex types test('isArray', t => { - t.plan(3); - t.ok(isArray([])); - t.throws(() => isArray({}), TypeError); - t.throws(() => isArray('1, 2, 3'), TypeError); + t.plan(3); + t.ok(isArray([])); + t.throws(() => isArray({}), TypeError); + t.throws(() => isArray('1, 2, 3'), TypeError); }); test.skip('isDate', t => { - // TODO + // TODO }); test('isObject', t => { - t.plan(3); - t.ok(isObject({})); - t.ok(isObject([])); - t.throws(() => isObject(null), TypeError); + t.plan(3); + t.ok(isObject({})); + t.ok(isObject([])); + t.throws(() => isObject(null), TypeError); }); test('validateArrayItems', t => { - t.plan(6); - - t.ok(validateArrayItems(isNumber)([3, 4, 5])); - t.ok(validateArrayItems(validateArrayItems(isNumber))([[3, 4], [4, 5], [6, 7]])); - - let caughtError = null; - try { - validateArrayItems(isNumber)([10, 20, 'one hundred million consorts', 30]); - } catch (err) { - caughtError = err; - } - - t.isNot(caughtError, null); - t.true(caughtError instanceof AggregateError); - t.is(caughtError.errors.length, 1); - t.true(caughtError.errors[0] instanceof TypeError); + t.plan(6); + + t.ok(validateArrayItems(isNumber)([3, 4, 5])); + t.ok(validateArrayItems(validateArrayItems(isNumber))([[3, 4], [4, 5], [6, 7]])); + + let caughtError = null; + try { + validateArrayItems(isNumber)([10, 20, 'one hundred million consorts', 30]); + } catch (err) { + caughtError = err; + } + + t.isNot(caughtError, null); + t.true(caughtError instanceof AggregateError); + t.is(caughtError.errors.length, 1); + t.true(caughtError.errors[0] instanceof TypeError); }); // Wiki data test.skip('isColor', t => { - // TODO + // TODO }); test.skip('isCommentary', t => { - // TODO + // TODO }); test.skip('isContribution', t => { - // TODO + // TODO }); test.skip('isContributionList', t => { - // TODO + // TODO }); test('isDimensions', t => { - t.plan(6); - t.ok(isDimensions([1, 1])); - t.ok(isDimensions([50, 50])); - t.ok(isDimensions([5000, 1])); - t.throws(() => isDimensions([1]), TypeError); - t.throws(() => isDimensions([413, 612, 1025]), TypeError); - t.throws(() => isDimensions('800x200'), TypeError); + t.plan(6); + t.ok(isDimensions([1, 1])); + t.ok(isDimensions([50, 50])); + t.ok(isDimensions([5000, 1])); + t.throws(() => isDimensions([1]), TypeError); + t.throws(() => isDimensions([413, 612, 1025]), TypeError); + t.throws(() => isDimensions('800x200'), TypeError); }); test('isDirectory', t => { - t.plan(6); - t.ok(isDirectory('savior-of-the-waking-world')); - t.ok(isDirectory('MeGaLoVania')); - t.ok(isDirectory('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_')); - t.throws(() => isDirectory(123), TypeError); - t.throws(() => isDirectory(''), TypeError); - t.throws(() => isDirectory('troll saint nicholas and the quest for the holy pail'), TypeError); + t.plan(6); + t.ok(isDirectory('savior-of-the-waking-world')); + t.ok(isDirectory('MeGaLoVania')); + t.ok(isDirectory('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_')); + t.throws(() => isDirectory(123), TypeError); + t.throws(() => isDirectory(''), TypeError); + t.throws(() => isDirectory('troll saint nicholas and the quest for the holy pail'), TypeError); }); test('isDuration', t => { - t.plan(5); - t.ok(isDuration(60)); - t.ok(isDuration(0.02)); - t.ok(isDuration(0)); - t.throws(() => isDuration(-1), TypeError); - t.throws(() => isDuration('10:25'), TypeError); + t.plan(5); + t.ok(isDuration(60)); + t.ok(isDuration(0.02)); + t.ok(isDuration(0)); + t.throws(() => isDuration(-1), TypeError); + t.throws(() => isDuration('10:25'), TypeError); }); test('isFileExtension', t => { - t.plan(6); - t.ok(isFileExtension('png')); - t.ok(isFileExtension('jpg')); - t.ok(isFileExtension('sub_loc')); - t.throws(() => isFileExtension(''), TypeError); - t.throws(() => isFileExtension('.jpg'), TypeError); - t.throws(() => isFileExtension('just an image bro!!!!'), TypeError); + t.plan(6); + t.ok(isFileExtension('png')); + t.ok(isFileExtension('jpg')); + t.ok(isFileExtension('sub_loc')); + t.throws(() => isFileExtension(''), TypeError); + t.throws(() => isFileExtension('.jpg'), TypeError); + t.throws(() => isFileExtension('just an image bro!!!!'), TypeError); }); test.skip('isName', t => { - // TODO + // TODO }); test.skip('isURL', t => { - // TODO + // TODO }); test('validateReference', t => { - t.plan(16); - - const typeless = validateReference(); - const track = validateReference('track'); - const album = validateReference('album'); - - t.ok(track('track:doctor')); - t.ok(track('track:MeGaLoVania')); - t.ok(track('Showtime (Imp Strife Mix)')); - t.throws(() => track('track:troll saint nic'), TypeError); - t.throws(() => track('track:'), TypeError); - t.throws(() => track('album:homestuck-vol-1'), TypeError); - - t.ok(album('album:sburb')); - t.ok(album('album:the-wanderers')); - t.ok(album('Homestuck Vol. 8')); - t.throws(() => album('album:Hiveswap Friendsim'), TypeError); - t.throws(() => album('album:'), TypeError); - t.throws(() => album('track:showtime-piano-refrain'), TypeError); - - t.ok(typeless('Hopes and Dreams')); - t.ok(typeless('track:snowdin-town')); - t.throws(() => typeless(''), TypeError); - t.throws(() => typeless('album:undertale-soundtrack')); + t.plan(16); + + const typeless = validateReference(); + const track = validateReference('track'); + const album = validateReference('album'); + + t.ok(track('track:doctor')); + t.ok(track('track:MeGaLoVania')); + t.ok(track('Showtime (Imp Strife Mix)')); + t.throws(() => track('track:troll saint nic'), TypeError); + t.throws(() => track('track:'), TypeError); + t.throws(() => track('album:homestuck-vol-1'), TypeError); + + t.ok(album('album:sburb')); + t.ok(album('album:the-wanderers')); + t.ok(album('Homestuck Vol. 8')); + t.throws(() => album('album:Hiveswap Friendsim'), TypeError); + t.throws(() => album('album:'), TypeError); + t.throws(() => album('track:showtime-piano-refrain'), TypeError); + + t.ok(typeless('Hopes and Dreams')); + t.ok(typeless('track:snowdin-town')); + t.throws(() => typeless(''), TypeError); + t.throws(() => typeless('album:undertale-soundtrack')); }); test('validateReferenceList', t => { - const track = validateReferenceList('track'); - const artist = validateReferenceList('artist'); - - t.plan(9); - - t.ok(track(['track:fallen-down', 'Once Upon a Time'])); - t.ok(artist(['artist:toby-fox', 'Mark Hadley'])); - t.ok(track(['track:amalgam'])); - t.ok(track([])); - - let caughtError = null; - try { - track(['Dog', 'album:vaporwave-2016', 'Cat', 'artist:john-madden']); - } catch (err) { - caughtError = err; - } - - t.isNot(caughtError, null); - t.true(caughtError instanceof AggregateError); - t.is(caughtError.errors.length, 2); - t.true(caughtError.errors[0] instanceof TypeError); - t.true(caughtError.errors[1] instanceof TypeError); + const track = validateReferenceList('track'); + const artist = validateReferenceList('artist'); + + t.plan(9); + + t.ok(track(['track:fallen-down', 'Once Upon a Time'])); + t.ok(artist(['artist:toby-fox', 'Mark Hadley'])); + t.ok(track(['track:amalgam'])); + t.ok(track([])); + + let caughtError = null; + try { + track(['Dog', 'album:vaporwave-2016', 'Cat', 'artist:john-madden']); + } catch (err) { + caughtError = err; + } + + t.isNot(caughtError, null); + t.true(caughtError instanceof AggregateError); + t.is(caughtError.errors.length, 2); + t.true(caughtError.errors[0] instanceof TypeError); + t.true(caughtError.errors[1] instanceof TypeError); }); test('oneOf', t => { - t.plan(11); + t.plan(11); - const isStringOrNumber = oneOf(isString, isNumber); + const isStringOrNumber = oneOf(isString, isNumber); - t.ok(isStringOrNumber('hello world')); - t.ok(isStringOrNumber(42)); - t.throws(() => isStringOrNumber(false)); + t.ok(isStringOrNumber('hello world')); + t.ok(isStringOrNumber(42)); + t.throws(() => isStringOrNumber(false)); - const mockError = new Error(); - const neverSucceeds = () => { - throw mockError; - }; + const mockError = new Error(); + const neverSucceeds = () => { + throw mockError; + }; - const isStringOrGetRekt = oneOf(isString, neverSucceeds); + const isStringOrGetRekt = oneOf(isString, neverSucceeds); - t.ok(isStringOrGetRekt('phew!')); + t.ok(isStringOrGetRekt('phew!')); - let caughtError = null; - try { - isStringOrGetRekt(0xdeadbeef); - } catch (err) { - caughtError = err; - } + let caughtError = null; + try { + isStringOrGetRekt(0xdeadbeef); + } catch (err) { + caughtError = err; + } - t.isNot(caughtError, null); - t.true(caughtError instanceof AggregateError); - t.is(caughtError.errors.length, 2); - t.true(caughtError.errors[0] instanceof TypeError); - t.is(caughtError.errors[0].check, isString); - t.is(caughtError.errors[1], mockError); - t.is(caughtError.errors[1].check, neverSucceeds); + t.isNot(caughtError, null); + t.true(caughtError instanceof AggregateError); + t.is(caughtError.errors.length, 2); + t.true(caughtError.errors[0] instanceof TypeError); + t.is(caughtError.errors[0].check, isString); + t.is(caughtError.errors[1], mockError); + t.is(caughtError.errors[1].check, neverSucceeds); }); diff --git a/test/things.js b/test/things.js index 7274515c..f36a4995 100644 --- a/test/things.js +++ b/test/things.js @@ -1,71 +1,71 @@ import test from 'tape'; import { - Album, - Thing, - Track, - TrackGroup, + Album, + Thing, + Track, + TrackGroup, } from '../src/data/things.js'; function stubAlbum(tracks) { - const album = new Album(); - const trackGroup = new TrackGroup(); - trackGroup.tracksByRef = tracks.map(t => Thing.getReference(t)); - album.trackGroups = [trackGroup]; - album.trackData = tracks; - return album; + const album = new Album(); + const trackGroup = new TrackGroup(); + trackGroup.tracksByRef = tracks.map(t => Thing.getReference(t)); + album.trackGroups = [trackGroup]; + album.trackData = tracks; + return album; } test(`Track.coverArtDate`, t => { - t.plan(5); + t.plan(5); - // Priority order is as follows, with the last (trackCoverArtDate) being - // greatest priority. - const albumDate = new Date('2010-10-10'); - const albumTrackArtDate = new Date('2012-12-12'); - const trackDateFirstReleased = new Date('2008-08-08'); - const trackCoverArtDate = new Date('2009-09-09'); + // Priority order is as follows, with the last (trackCoverArtDate) being + // greatest priority. + const albumDate = new Date('2010-10-10'); + const albumTrackArtDate = new Date('2012-12-12'); + const trackDateFirstReleased = new Date('2008-08-08'); + const trackCoverArtDate = new Date('2009-09-09'); - const track = new Track(); - track.directory = 'foo'; + const track = new Track(); + track.directory = 'foo'; - const album = stubAlbum([track]); + const album = stubAlbum([track]); - track.albumData = [album]; + track.albumData = [album]; - // 1. coverArtDate defaults to null + // 1. coverArtDate defaults to null - t.is(track.coverArtDate, null); + t.is(track.coverArtDate, null); - // 2. coverArtDate inherits album release date + // 2. coverArtDate inherits album release date - album.date = albumDate; + album.date = albumDate; - // XXX clear cache so change in album's property is reflected - track.albumData = []; - track.albumData = [album]; + // XXX clear cache so change in album's property is reflected + track.albumData = []; + track.albumData = [album]; - t.is(track.coverArtDate, albumDate); + t.is(track.coverArtDate, albumDate); - // 3. coverArtDate inherits album trackArtDate + // 3. coverArtDate inherits album trackArtDate - album.trackArtDate = albumTrackArtDate; + album.trackArtDate = albumTrackArtDate; - // XXX clear cache again - track.albumData = []; - track.albumData = [album]; + // XXX clear cache again + track.albumData = []; + track.albumData = [album]; - t.is(track.coverArtDate, albumTrackArtDate); + t.is(track.coverArtDate, albumTrackArtDate); - // 4. coverArtDate is overridden dateFirstReleased + // 4. coverArtDate is overridden dateFirstReleased - track.dateFirstReleased = trackDateFirstReleased; + track.dateFirstReleased = trackDateFirstReleased; - t.is(track.coverArtDate, trackDateFirstReleased); + t.is(track.coverArtDate, trackDateFirstReleased); - // 5. coverArtDate is overridden coverArtDate + // 5. coverArtDate is overridden coverArtDate - track.coverArtDate = trackCoverArtDate; + track.coverArtDate = trackCoverArtDate; - t.is(track.coverArtDate, trackCoverArtDate); + t.is(track.coverArtDate, trackCoverArtDate); }); -- cgit 1.3.0-6-gf8a5