@@ -11,6 +11,7 @@ import {
11
11
isOpenApi3_0Element ,
12
12
isServerElement ,
13
13
isServerVariableElement ,
14
+ isSecuritySchemeElement ,
14
15
isPathsElement ,
15
16
isPathItemElement ,
16
17
isOperationElement ,
@@ -23,6 +24,7 @@ import {
23
24
ContactElement ,
24
25
ServerElement ,
25
26
ServerVariableElement ,
27
+ SecuritySchemeElement ,
26
28
PathsElement ,
27
29
PathItemElement ,
28
30
OperationElement ,
@@ -515,6 +517,59 @@ describe('predicates', function () {
515
517
} ) ;
516
518
} ) ;
517
519
520
+ context ( 'isSecuritySchemeElement' , function ( ) {
521
+ context ( 'given SecuritySchemeElement instance value' , function ( ) {
522
+ specify ( 'should return true' , function ( ) {
523
+ const element = new SecuritySchemeElement ( ) ;
524
+
525
+ assert . isTrue ( isSecuritySchemeElement ( element ) ) ;
526
+ } ) ;
527
+ } ) ;
528
+
529
+ context ( 'given subtype instance value' , function ( ) {
530
+ specify ( 'should return true' , function ( ) {
531
+ class SecuritySchemeSubElement extends SecuritySchemeElement { }
532
+
533
+ assert . isTrue ( isSecuritySchemeElement ( new SecuritySchemeSubElement ( ) ) ) ;
534
+ } ) ;
535
+ } ) ;
536
+
537
+ context ( 'given non SecuritySchemeElement instance value' , function ( ) {
538
+ specify ( 'should return false' , function ( ) {
539
+ assert . isFalse ( isSecuritySchemeElement ( 1 ) ) ;
540
+ assert . isFalse ( isSecuritySchemeElement ( null ) ) ;
541
+ assert . isFalse ( isSecuritySchemeElement ( undefined ) ) ;
542
+ assert . isFalse ( isSecuritySchemeElement ( { } ) ) ;
543
+ assert . isFalse ( isSecuritySchemeElement ( [ ] ) ) ;
544
+ assert . isFalse ( isSecuritySchemeElement ( 'string' ) ) ;
545
+ } ) ;
546
+ } ) ;
547
+
548
+ specify ( 'should support duck-typing' , function ( ) {
549
+ const securitySchemeElementDuck = {
550
+ _storedElement : 'securityScheme' ,
551
+ _content : [ ] ,
552
+ primitive ( ) {
553
+ return 'object' ;
554
+ } ,
555
+ get element ( ) {
556
+ return this . _storedElement ;
557
+ } ,
558
+ } ;
559
+
560
+ const securitySchemeElementSwan = {
561
+ _storedElement : undefined ,
562
+ _content : undefined ,
563
+ primitive ( ) {
564
+ return 'swan' ;
565
+ } ,
566
+ } ;
567
+
568
+ assert . isTrue ( isSecuritySchemeElement ( securitySchemeElementDuck ) ) ;
569
+ assert . isFalse ( isSecuritySchemeElement ( securitySchemeElementSwan ) ) ;
570
+ } ) ;
571
+ } ) ;
572
+
518
573
context ( 'isPathsElement' , function ( ) {
519
574
context ( 'given PathsElement instance value' , function ( ) {
520
575
specify ( 'should return true' , function ( ) {
0 commit comments