11import assert from 'node:assert/strict' ;
22import test from 'node:test' ;
33
4- import { hasInvalidPingCopyrightHeader , updateCopyrightYears } from './sync-header-years.mjs' ;
4+ import {
5+ hasInvalidPingCopyrightHeader ,
6+ isExcluded ,
7+ updateCopyrightYears ,
8+ } from './sync-header-years.mjs' ;
59
610test ( 'updates stale range end year and keeps start year' , ( ) => {
7- const input = '/* Copyright 2020 - 2026 Ping Identity. All Rights Reserved */' ;
11+ const input = '/* Copyright 2020-2024 Ping Identity. All Rights Reserved */' ;
812 const actual = updateCopyrightYears ( input , 2026 ) ;
913 assert . equal ( actual , '/* Copyright 2020 - 2026 Ping Identity. All Rights Reserved */' ) ;
1014} ) ;
1115
1216test ( 'normalizes separator on an already-current range' , ( ) => {
13- const input = '/* Copyright 2020 - 2026 Ping Identity. All Rights Reserved */' ;
17+ const input = '/* Copyright 2020- 2026 Ping Identity. All Rights Reserved */' ;
1418 const actual = updateCopyrightYears ( input , 2026 ) ;
1519 assert . equal ( actual , '/* Copyright 2020 - 2026 Ping Identity. All Rights Reserved */' ) ;
1620} ) ;
1721
1822test ( 'expands stale single year to a range preserving start year' , ( ) => {
19- const input = '/* Copyright 2020 - 2026 Ping Identity. All Rights Reserved */' ;
23+ const input = '/* Copyright 2020 Ping Identity. All Rights Reserved */' ;
2024 const actual = updateCopyrightYears ( input , 2026 ) ;
2125 assert . equal ( actual , '/* Copyright 2020 - 2026 Ping Identity. All Rights Reserved */' ) ;
2226} ) ;
@@ -29,8 +33,8 @@ test('does not change an already-current spaced range', () => {
2933
3034test ( 'supports © and © variants' , ( ) => {
3135 const input = [
32- '/* © Copyright 2020 - 2026 Ping Identity. */' ,
33- '<!-- © Copyright 2020 - 2026 Ping Identity. -->' ,
36+ '/* © Copyright 2020-2024 Ping Identity. */' ,
37+ '<!-- © Copyright 2020-2024 Ping Identity. -->' ,
3438 ] . join ( '\n' ) ;
3539 const actual = updateCopyrightYears ( input , 2026 ) ;
3640 assert . equal (
@@ -49,7 +53,7 @@ test('does not update non-Ping headers', () => {
4953} ) ;
5054
5155test ( 'updates Ping Identity Corporation ranges with spaces and (c)' , ( ) => {
52- const input = '/* Copyright (c) 2023 - 2026 Ping Identity Corporation. All right reserved. */' ;
56+ const input = '/* Copyright (c) 2023 - 2024 Ping Identity Corporation. All right reserved. */' ;
5357 const actual = updateCopyrightYears ( input , 2026 ) ;
5458 assert . equal (
5559 actual ,
@@ -58,7 +62,7 @@ test('updates Ping Identity Corporation ranges with spaces and (c)', () => {
5862} ) ;
5963
6064test ( 'expands stale single year with (c) to a range for Ping Identity Corporation' , ( ) => {
61- const input = '/* Copyright (c) 2023 - 2026 Ping Identity Corporation. All right reserved. */' ;
65+ const input = '/* Copyright (c) 2023 Ping Identity Corporation. All right reserved. */' ;
6266 const actual = updateCopyrightYears ( input , 2026 ) ;
6367 assert . equal (
6468 actual ,
@@ -80,3 +84,19 @@ test('does not flag non-header Ping copyright text', () => {
8084 const input = 'This document is Copyright Ping Identity Corporation.' ;
8185 assert . equal ( hasInvalidPingCopyrightHeader ( input ) , false ) ;
8286} ) ;
87+
88+ test ( 'excludes test files from processing' , ( ) => {
89+ assert . equal ( isExcluded ( 'src/foo.test.ts' ) , true ) ;
90+ assert . equal ( isExcluded ( 'src/foo.test.mjs' ) , true ) ;
91+ assert . equal ( isExcluded ( 'src/foo.spec.js' ) , true ) ;
92+ } ) ;
93+
94+ test ( 'excludes dist and vendor paths from processing' , ( ) => {
95+ assert . equal ( isExcluded ( 'dist/foo.js' ) , true ) ;
96+ assert . equal ( isExcluded ( 'vendor/lib.js' ) , true ) ;
97+ } ) ;
98+
99+ test ( 'does not exclude regular source files' , ( ) => {
100+ assert . equal ( isExcluded ( 'src/foo.ts' ) , false ) ;
101+ assert . equal ( isExcluded ( 'packages/sdk/src/index.ts' ) , false ) ;
102+ } ) ;
0 commit comments