-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support author parsing in d2.config.js [LIBS-347] (#747)
- Loading branch information
Showing
3 changed files
with
135 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
const { parseConfigObjects } = require('./parseConfig.js') | ||
|
||
describe('parseConfig', () => { | ||
it('should correctly parse author fields', () => { | ||
expect( | ||
parseConfigObjects({ author: { name: 'Test Author' } }).author | ||
).toMatchObject({ name: 'Test Author' }) | ||
expect( | ||
parseConfigObjects({ | ||
author: { | ||
name: 'Test Author', | ||
email: '[email protected]', | ||
url: 'https://author.com/test', | ||
}, | ||
}).author | ||
).toMatchObject({ | ||
name: 'Test Author', | ||
email: '[email protected]', | ||
url: 'https://author.com/test', | ||
}) | ||
expect( | ||
parseConfigObjects({ | ||
author: { name: 'Test Author', email: '[email protected]' }, | ||
}).author | ||
).toMatchObject({ name: 'Test Author', email: '[email protected]' }) | ||
expect( | ||
parseConfigObjects({ | ||
author: { name: 'Test Author', url: 'https://author.com/test' }, | ||
}).author | ||
).toMatchObject({ name: 'Test Author', url: 'https://author.com/test' }) | ||
|
||
expect( | ||
parseConfigObjects({ author: 'Test Author' }).author | ||
).toMatchObject({ name: 'Test Author' }) | ||
expect( | ||
parseConfigObjects({ author: 'Test Author <[email protected]>' }) | ||
.author | ||
).toMatchObject({ name: 'Test Author', email: '[email protected]' }) | ||
expect( | ||
parseConfigObjects({ | ||
author: 'Test Author <[email protected]> (https://author.com/test)', | ||
}).author | ||
).toMatchObject({ | ||
name: 'Test Author', | ||
email: '[email protected]', | ||
url: 'https://author.com/test', | ||
}) | ||
expect( | ||
parseConfigObjects({ | ||
author: 'Test Author (https://author.com/test)', | ||
}).author | ||
).toMatchObject({ name: 'Test Author', url: 'https://author.com/test' }) | ||
|
||
// missing name | ||
expect(() => | ||
parseConfigObjects({ | ||
author: { | ||
email: '[email protected]', | ||
url: 'https://author.com/test', | ||
}, | ||
}) | ||
).toThrow() | ||
expect( | ||
() => | ||
parseConfigObjects({ author: { email: '[email protected]' } }) | ||
.author | ||
).toThrow() | ||
expect(() => | ||
parseConfigObjects({ author: { url: 'https://author.com/test' } }) | ||
).toThrow() | ||
expect(() => | ||
parseConfigObjects({ author: '(https://author.com/test)' }) | ||
).toThrow() | ||
expect(() => | ||
parseConfigObjects({ | ||
author: '<[email protected]> (https://author.com/test)', | ||
}) | ||
).toThrow() | ||
expect(() => | ||
parseConfigObjects({ author: '<[email protected]>' }) | ||
).toThrow() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters