Skip to content

Commit

Permalink
make tests independant of the year
Browse files Browse the repository at this point in the history
  • Loading branch information
deniak committed Jan 6, 2025
1 parent dcfaf13 commit bcc29dd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
3 changes: 1 addition & 2 deletions test/doc-views/TR/Recommendation/REC.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ export default {
...good.sotd.rec,
showProposedAdd: true,
},
processHTML:
'2 November 2024, 3 November 2024 <abbr title="World Wide Web Consortium">W3C</abbr> Process Document',
processHTML: `2 November ${currentYear}, 3 November ${currentYear} <abbr title="World Wide Web Consortium">W3C</abbr> Process Document`,
},
},
notFound: {
Expand Down
6 changes: 3 additions & 3 deletions test/doc-views/TR/Registry/CRY.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { config } from '../../../../lib/profiles/TR/Registry/CRY.js';
import registryBase from './registryBase.js';

const { buildCommonViewData, data } = registryBase;
const currentYear = new Date().getFullYear();

const profile = 'CRY';
const customData = {
Expand All @@ -28,15 +29,14 @@ export default {
...good,
header: {
...good.header,
defaultDate: '04 November 2025',
defaultDate: `04 November ${currentYear}`,
},
},
multipleDateFound: {
...good,
sotd: {
...good.sotd,
processHTML:
'04 October 2024. 05 October 2024.<abbr title="World Wide Web Consortium">W3C</abbr> Process Document',
processHTML: `04 October ${currentYear}. 05 October ${currentYear}.<abbr title="World Wide Web Consortium">W3C</abbr> Process Document`,
},
},
invalidDate: {
Expand Down
12 changes: 6 additions & 6 deletions test/doc-views/TR/TRBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {

export { data };

const currentYear = new Date().getFullYear();

export function buildCommonViewData(base) {
const common = _buildCommonViewData(base);
return {
Expand Down Expand Up @@ -75,8 +77,7 @@ export function buildCommonViewData(base) {
copyright: {
...base.copyright,
showDefault: false,
exceptionHtml:
'<a href="https://www.w3.org/policies/#copyright">Copyright</a> © 1999-2024 <a href="https://www.idpf.org">International Digital Publishing Forum</a> and <a href="https://www.w3.org/">World Wide Web Consortium</a>. <abbr title="World Wide Web Consortium">W3C</abbr><sup>®</sup> <a href="https://www.w3.org/policies/#Legal_Disclaimer">liability</a>, <a href="https://www.w3.org/policies/#W3C_Trademarks">trademark</a> and <a rel="license" href="https://www.w3.org/copyright/software-license-2023/" title="W3C Software and Document Notice and License">permissive document license</a> rules apply.',
exceptionHtml: `<a href="https://www.w3.org/policies/#copyright">Copyright</a> © 1999-${currentYear} <a href="https://www.idpf.org">International Digital Publishing Forum</a> and <a href="https://www.w3.org/">World Wide Web Consortium</a>. <abbr title="World Wide Web Consortium">W3C</abbr><sup>®</sup> <a href="https://www.w3.org/policies/#Legal_Disclaimer">liability</a>, <a href="https://www.w3.org/policies/#W3C_Trademarks">trademark</a> and <a rel="license" href="https://www.w3.org/copyright/software-license-2023/" title="W3C Software and Document Notice and License">permissive document license</a> rules apply.`,
},
},
copyrightExceptionNotFound: {
Expand All @@ -93,8 +94,7 @@ export function buildCommonViewData(base) {
copyright: {
...base.copyright,
showDefault: false,
exceptionHtml:
'<a href="https://www.w3.org/policies/#copyright">Copyright Exception Not Found</a> © 1999-2024 <a href="https://www.idpf.org">International Digital Publishing Forum</a> and <a href="https://www.w3.org/">World Wide Web Consortium</a>. <abbr title="World Wide Web Consortium">W3C</abbr><sup>®</sup> <a href="https://www.w3.org/policies/#Legal_Disclaimer">liability</a>, <a href="https://www.w3.org/policies/#W3C_Trademarks">trademark</a> and <a rel="license" href="https://www.w3.org/copyright/software-license-2023/" title="W3C Software and Document Notice and License">permissive document license</a> rules apply.',
exceptionHtml: `<a href="https://www.w3.org/policies/#copyright">Copyright Exception Not Found</a> © 1999-${currentYear} <a href="https://www.idpf.org">International Digital Publishing Forum</a> and <a href="https://www.w3.org/">World Wide Web Consortium</a>. <abbr title="World Wide Web Consortium">W3C</abbr><sup>®</sup> <a href="https://www.w3.org/policies/#Legal_Disclaimer">liability</a>, <a href="https://www.w3.org/policies/#W3C_Trademarks">trademark</a> and <a rel="license" href="https://www.w3.org/copyright/software-license-2023/" title="W3C Software and Document Notice and License">permissive document license</a> rules apply.`,
},
},
},
Expand Down Expand Up @@ -255,14 +255,14 @@ export function buildCandidateReviewEnd(base) {
...base,
sotd: {
...base.sotd,
defaultCRDate: '04 October 2024. 05 October 2024.',
defaultCRDate: `04 November ${currentYear}. 05 November ${currentYear}.`,
},
},
invalidDate: {
...base,
sotd: {
...base.sotd,
defaultCRDate: '02 October 2025',
defaultCRDate: '02 October 2030',
},
},
};
Expand Down
8 changes: 4 additions & 4 deletions test/doc-views/layout/spec.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
{{/if}}

<p id='w3c-state'>
<a href='https://www.w3.org/standards/types/#{{#if config.isFPWD}}FPWD{{else}}{{config.status}}{{/if}}'>W3C <span class="handlebars-data">{{config.longStatus}} {{config.crType}} {{config.cryType}}</span></a>
{{! if document is Echidna, use current date. else, use default date}}
<a href='https://www.w3.org/standards/types/#{{#if config.isFPWD}}FPWD{{else}}{{config.status}}{{/if}}'>W3C <span class="handlebars-data">{{config.longStatus}} {{config.crType}} {{config.cryType}}</span></a>
<time class="dt-published" datetime="2021-11-04">
{{#if config.isEchidna}}
{{#if header.showDefaultDate}}
Expand Down Expand Up @@ -66,8 +66,8 @@
{{#if dl.thisVersion.show}}
<dt>{{dl.thisVersion.text}}</dt>
<dd>
<a class="u-url" {{#if dl.thisVersion.showHref}}href="https://www.w3.org/{{dl.topLevel}}/{{#if config.isEchidna}}{{nowYear}}{{else}}2024{{/if}}/{{config.status}}-{{dl.shortName}}-{{! if document is Echidna, use current date. else, use default date}}{{#if config.isEchidna}}{{nowDigit8}}{{else}}20240804{{/if}}/"{{/if}}>
https://www.w3.org/{{dl.topLevel}}/{{#if config.isEchidna}}<span class="handlebars-data">{{nowYear}}</span>{{else}}2024{{/if}}/<span class="handlebars-data">{{config.status}}</span>-<span class="handlebars-data">{{dl.shortName}}</span>-{{! if document is Echidna, use current date. else, use default date}}{{#if config.isEchidna}}<span class="handlebars-data">{{nowDigit8}}</span>{{else}}20240804{{/if}}/
<a class="u-url" {{#if dl.thisVersion.showHref}}href="https://www.w3.org/{{dl.topLevel}}/{{nowYear}}/{{config.status}}-{{dl.shortName}}-{{! if document is Echidna, use current date. else, use default date}}{{#if config.isEchidna}}{{nowDigit8}}{{else}}{{nowYear}}0804{{/if}}/"{{/if}}>
https://www.w3.org/{{dl.topLevel}}/<span class="handlebars-data">{{nowYear}}</span>/<span class="handlebars-data">{{config.status}}</span>-<span class="handlebars-data">{{dl.shortName}}</span>-{{! if document is Echidna, use current date. else, use default date}}{{#if config.isEchidna}}<span class="handlebars-data">{{nowDigit8}}</span>{{else}}{{nowYear}}0804{{/if}}/
</a>
</dd>
{{/if}}
Expand Down Expand Up @@ -226,7 +226,7 @@

{{#config.isCRY}}
<p>
This Candidate Registry is not expected to advance to Registry any earlier than 6 June 2025.
This Candidate Registry is not expected to advance to Registry any earlier than 6 September 2025.
</p>
{{/config.isCRY}}

Expand Down
6 changes: 4 additions & 2 deletions test/doc-views/specBase.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const currentYear = new Date().getFullYear();

export const data = {
bodyClassNames: 'h-entry',
scripts: ['https://www.w3.org/scripts/TR/2021/fixup.js'],
Expand Down Expand Up @@ -38,7 +40,7 @@ export const data = {
show: true,
text: 'More details about this document',
},
defaultDate: '04 August 2024',
defaultDate: `04 August ${currentYear}`,
showDefaultDate: false,
},
secno: 'secno',
Expand Down Expand Up @@ -192,7 +194,7 @@ export const data = {
show: false,
text: 'Future updates to this Recommendation may incorporate new features.',
},
defaultCRDate: '04 October 2024',
defaultCRDate: `04 October ${currentYear}`,
rec: {
showProposedAdd: false,
showAddition: false,
Expand Down

0 comments on commit bcc29dd

Please sign in to comment.