File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ class Glossary {
2525 add ( term , description ) {
2626 assert ( term && term . length , 'term is required' )
2727 assert ( description && description . length , 'description is required' )
28- assert ( ! ( term in this . _entries ) , `term ${ term } has already been added` )
28+ assert ( ! ( Object . keys ( this . entries ) . includes ( term ) ) , `term ${ term } has already been added` )
2929 this . _entries [ term ] = description
3030 }
3131
Original file line number Diff line number Diff line change @@ -56,6 +56,12 @@ describe('glossary.add()', () => {
5656 glossary . add ( 'IPC' , 'inter-process communication' )
5757 } ) . toThrow ( 'term IPC has already been added' )
5858 } )
59+
60+ test ( 'properly handles JS builtins like `constructor`' , ( ) => {
61+ glossary . add ( 'constructor' , 'a thing' )
62+ glossary . add ( 'toString' , 'a thing' )
63+ glossary . add ( 'hasOwnProperty' , 'a thing' )
64+ } )
5965} )
6066
6167describe ( 'glossary.webpage' , ( ) => {
You can’t perform that action at this time.
0 commit comments