1+ import Log from '../src/Log' ;
2+ import SignoutRequest from '../src/SignoutRequest' ;
3+
4+ import StubState from './StubState' ;
5+
6+ import chai from 'chai' ;
7+ chai . should ( ) ;
8+ let assert = chai . assert ;
9+
10+ describe ( "SignoutRequest" , function ( ) {
11+
12+ let stubState = new StubState ( "state" ) ;
13+ let StubStateCtor = ( ) => stubState ;
14+
15+
16+ describe ( "constructor" , function ( ) {
17+
18+ it ( "should require a url param" , function ( ) {
19+ try {
20+ new SignoutRequest ( ) ;
21+ }
22+ catch ( e ) {
23+ return ;
24+ }
25+ assert . fail ( ) ;
26+ } ) ;
27+
28+ } ) ;
29+
30+ describe ( "signoutUrl" , function ( ) {
31+
32+ it ( "should include url" , function ( ) {
33+ let subject = new SignoutRequest ( "http://sts/signout" ) ;
34+ subject . signoutUrl . indexOf ( "http://sts/signout" ) . should . equal ( 0 ) ;
35+ } ) ;
36+
37+ it ( "should include state" , function ( ) {
38+ let subject = new SignoutRequest ( "http://sts/signout" , { state :"test" } , StubStateCtor ) ;
39+ subject . signoutUrl . should . contain ( "state=state" ) ;
40+ } ) ;
41+
42+ it ( "should include id_token_hint" , function ( ) {
43+ let subject = new SignoutRequest ( "http://sts/signout" , { id_token_hint :"test" } ) ;
44+ subject . signoutUrl . should . contain ( "id_token_hint=test" ) ;
45+ } ) ;
46+
47+ it ( "should include post_logout_redirect_uri" , function ( ) {
48+ let subject = new SignoutRequest ( "http://sts/signout" , { post_logout_redirect_uri :"test" } ) ;
49+ subject . signoutUrl . should . contain ( "post_logout_redirect_uri=test" ) ;
50+ } ) ;
51+
52+ it ( "should include id_token_hint, post_logout_redirect_uri, and state" , function ( ) {
53+ let subject = new SignoutRequest ( "http://sts/signout" , {
54+ id_token_hint : 'token' ,
55+ post_logout_redirect_uri :"uri" ,
56+ state :"xoxo"
57+ } , StubStateCtor ) ;
58+
59+ var url = subject . signoutUrl ;
60+ url . indexOf ( 'http://sts/signout?' ) . should . equal ( 0 ) ;
61+ url . should . contain ( "id_token_hint=token" ) ;
62+ url . should . contain ( "post_logout_redirect_uri=uri" ) ;
63+ url . should . contain ( "state=state" ) ;
64+ } ) ;
65+
66+ } ) ;
67+
68+ } ) ;
0 commit comments