type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
---|---|---|---|---|
MethodDeclaration | /**
* @override
*/
public applyTest(object: T) {
return this.test(object);
} | zorkow/speech-rule-engine | ts/indexing/abstract_trie_node.ts | TypeScript |
MethodDeclaration | /**
* @override
*/
public addChild(node: TrieNode) {
let constraint = node.getConstraint();
let child = this.children_[constraint];
this.children_[constraint] = node;
return child;
} | zorkow/speech-rule-engine | ts/indexing/abstract_trie_node.ts | TypeScript |
MethodDeclaration | /**
* @override
*/
public getChild(constraint: string) {
return this.children_[constraint];
} | zorkow/speech-rule-engine | ts/indexing/abstract_trie_node.ts | TypeScript |
MethodDeclaration | /**
* @override
*/
public getChildren() {
let children = [];
for (let key in this.children_) {
children.push(this.children_[key]);
}
return children;
} | zorkow/speech-rule-engine | ts/indexing/abstract_trie_node.ts | TypeScript |
MethodDeclaration | /**
* @override
*/
public findChildren(object: T) {
let children = [];
for (let key in this.children_) {
let child = this.children_[key];
if (child.applyTest(object)) {
children.push(child);
}
}
return children;
} | zorkow/speech-rule-engine | ts/indexing/abstract_trie_node.ts | TypeScript |
MethodDeclaration | /**
* @override
*/
public removeChild(constraint: string) {
delete this.children_[constraint];
} | zorkow/speech-rule-engine | ts/indexing/abstract_trie_node.ts | TypeScript |
MethodDeclaration | /**
* @override
*/
public toString() {
return this.constraint;
} | zorkow/speech-rule-engine | ts/indexing/abstract_trie_node.ts | TypeScript |
MethodDeclaration | /**
* @return The speech rule of the node.
*/
public getRule(): SpeechRule|null {
return this.rule_;
} | zorkow/speech-rule-engine | ts/indexing/abstract_trie_node.ts | TypeScript |
MethodDeclaration | /**
* @param rule speech rule of the node.
*/
public setRule(rule: SpeechRule) {
if (this.rule_) {
Debugger.getInstance().output(
'Replacing rule ' + this.rule_ + ' with ' + rule);
}
this.rule_ = rule;
} | zorkow/speech-rule-engine | ts/indexing/abstract_trie_node.ts | TypeScript |
MethodDeclaration | /**
* @override
*/
public toString() {
let rule = this.getRule();
return rule ? this.constraint + '\n' +
'==> ' + this.getRule().action :
this.constraint;
} | zorkow/speech-rule-engine | ts/indexing/abstract_trie_node.ts | TypeScript |
ClassDeclaration | /**
* <p>Gets the network settings.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { WorkSpacesWebClient, GetNetworkSettingsCommand } from "@aws-sdk/client-workspaces-web"; // ES Modules import
* // const { WorkSpacesWebClient, GetNetworkSettingsCommand } = require("@aws-sdk/client-workspaces-web"); // CommonJS import
* const client = new WorkSpacesWebClient(config);
* const command = new GetNetworkSettingsCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link GetNetworkSettingsCommandInput} for command's `input` shape.
* @see {@link GetNetworkSettingsCommandOutput} for command's `response` shape.
* @see {@link WorkSpacesWebClientResolvedConfig | config} for WorkSpacesWebClient's `config` shape.
*
*/
export class GetNetworkSettingsCommand extends $Command<
GetNetworkSettingsCommandInput,
GetNetworkSettingsCommandOutput,
WorkSpacesWebClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties
constructor(readonly input: GetNetworkSettingsCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}
/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: WorkSpacesWebClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<GetNetworkSettingsCommandInput, GetNetworkSettingsCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
const stack = clientStack.concat(this.middlewareStack);
const { logger } = configuration;
const clientName = "WorkSpacesWebClient";
const commandName = "GetNetworkSettingsCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: GetNetworkSettingsRequest.filterSensitiveLog,
outputFilterSensitiveLog: GetNetworkSettingsResponse.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}
private serialize(input: GetNetworkSettingsCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_restJson1GetNetworkSettingsCommand(input, context);
}
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<GetNetworkSettingsCommandOutput> {
return deserializeAws_restJson1GetNetworkSettingsCommand(output, context);
}
// Start section: command_body_extra
// End section: command_body_extra
} | AllanFly120/aws-sdk-js-v3 | clients/client-workspaces-web/src/commands/GetNetworkSettingsCommand.ts | TypeScript |
InterfaceDeclaration |
export interface GetNetworkSettingsCommandInput extends GetNetworkSettingsRequest {} | AllanFly120/aws-sdk-js-v3 | clients/client-workspaces-web/src/commands/GetNetworkSettingsCommand.ts | TypeScript |
InterfaceDeclaration |
export interface GetNetworkSettingsCommandOutput extends GetNetworkSettingsResponse, __MetadataBearer {} | AllanFly120/aws-sdk-js-v3 | clients/client-workspaces-web/src/commands/GetNetworkSettingsCommand.ts | TypeScript |
MethodDeclaration | /**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: WorkSpacesWebClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<GetNetworkSettingsCommandInput, GetNetworkSettingsCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
const stack = clientStack.concat(this.middlewareStack);
const { logger } = configuration;
const clientName = "WorkSpacesWebClient";
const commandName = "GetNetworkSettingsCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: GetNetworkSettingsRequest.filterSensitiveLog,
outputFilterSensitiveLog: GetNetworkSettingsResponse.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
} | AllanFly120/aws-sdk-js-v3 | clients/client-workspaces-web/src/commands/GetNetworkSettingsCommand.ts | TypeScript |
MethodDeclaration |
private serialize(input: GetNetworkSettingsCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_restJson1GetNetworkSettingsCommand(input, context);
} | AllanFly120/aws-sdk-js-v3 | clients/client-workspaces-web/src/commands/GetNetworkSettingsCommand.ts | TypeScript |
MethodDeclaration |
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<GetNetworkSettingsCommandOutput> {
return deserializeAws_restJson1GetNetworkSettingsCommand(output, context);
} | AllanFly120/aws-sdk-js-v3 | clients/client-workspaces-web/src/commands/GetNetworkSettingsCommand.ts | TypeScript |
InterfaceDeclaration |
export interface OCPPConfigurationKey {
key: string | StandardParametersKey;
readonly: boolean;
value?: string;
} | DevangMstryls/ev-simulator | src/types/ocpp/Configuration.ts | TypeScript |
EnumDeclaration |
export enum ConnectorPhaseRotation {
NotApplicable = 'NotApplicable',
Unknown = 'Unknown',
RST = 'RST',
RTS = 'RTS',
SRT = 'SRT',
STR = 'STR',
TRS = 'TRS',
TSR = 'TSR'
} | DevangMstryls/ev-simulator | src/types/ocpp/Configuration.ts | TypeScript |
TypeAliasDeclaration |
export type StandardParametersKey = OCPP16StandardParametersKey; | DevangMstryls/ev-simulator | src/types/ocpp/Configuration.ts | TypeScript |
TypeAliasDeclaration |
export type SupportedFeatureProfiles = OCPP16SupportedFeatureProfiles; | DevangMstryls/ev-simulator | src/types/ocpp/Configuration.ts | TypeScript |
ClassDeclaration |
@Component({
selector: 'fr-navbar-menu',
template: ''
})
export class FrNavbarMenuComponent {
@Input() link: string;
@Input() title: string;
} | chloe463/francette | projects/francette/src/lib/navbar/navbar-menu/navbar-menu.component.ts | TypeScript |
ClassDeclaration |
@Controller('patients/:id/investigations')
@ApiUseTags('Investigations')
export class PatientInvestigationController {
constructor(private readonly patientInvestigationService: PatientInvestigationService) {
}
@Get()
findManyByPatientId(@Param('id') patientId: number) {
return this.patientInvestigationService.findMany({
where: {Patient: patientId},
relations: ['Investigation'],
});
}
} | maddoctor1905/CVD-CARE-API | src/modules/patient/patientInvestigation/patientInvestigation.controller.ts | TypeScript |
MethodDeclaration |
@Get()
findManyByPatientId(@Param('id') patientId: number) {
return this.patientInvestigationService.findMany({
where: {Patient: patientId},
relations: ['Investigation'],
});
} | maddoctor1905/CVD-CARE-API | src/modules/patient/patientInvestigation/patientInvestigation.controller.ts | TypeScript |
ClassDeclaration |
@NgModule({
imports: [
CollapseModule,
CommonModule,
IterationModule,
ModalModule,
RouterModule
],
declarations: [
SidepanelComponent
],
exports: [SidepanelComponent]
})
export class SidepanelModule { } | mayuba/fabric8-planner | src/app/side-panel/side-panel.module.ts | TypeScript |
ClassDeclaration |
export class WeightWidget extends AbstractWidget {
getName(): string {
return 'Weight';
}
getUnits(): string {
return 'kg';
}
isAggregated(): boolean {
return false;
}
createTimeWindow(): TimeWindow {
return {
type: 'years',
length: 1
};
}
getType(): GraphType {
return GraphType.Line;
}
getDataTypeName(): string {
return 'derived:com.google.weight:com.google.android.gms:merge_weight';
// return 'com.google.weight';
}
} | CSymes/gFitDashboard | src/app/widgets/definitions/weight.widget.ts | TypeScript |
MethodDeclaration |
getName(): string {
return 'Weight';
} | CSymes/gFitDashboard | src/app/widgets/definitions/weight.widget.ts | TypeScript |
MethodDeclaration |
getUnits(): string {
return 'kg';
} | CSymes/gFitDashboard | src/app/widgets/definitions/weight.widget.ts | TypeScript |
MethodDeclaration |
isAggregated(): boolean {
return false;
} | CSymes/gFitDashboard | src/app/widgets/definitions/weight.widget.ts | TypeScript |
MethodDeclaration |
createTimeWindow(): TimeWindow {
return {
type: 'years',
length: 1
};
} | CSymes/gFitDashboard | src/app/widgets/definitions/weight.widget.ts | TypeScript |
MethodDeclaration |
getType(): GraphType {
return GraphType.Line;
} | CSymes/gFitDashboard | src/app/widgets/definitions/weight.widget.ts | TypeScript |
MethodDeclaration |
getDataTypeName(): string {
return 'derived:com.google.weight:com.google.android.gms:merge_weight';
// return 'com.google.weight';
} | CSymes/gFitDashboard | src/app/widgets/definitions/weight.widget.ts | TypeScript |
ClassDeclaration |
export default abstract class AbstractDepartment extends AbstractFunction {
public departmentId: string;
public departmentName: string;
public parentDepartmentId: string;
public managerEmployeeId: string;
public departmentTitle: string;
public active: boolean;
public customFields: Array<[string, any]> = [];
} | awana/IntacctTimeout | src/Functions/Company/AbstractDepartment.ts | TypeScript |
ArrowFunction |
({ placeholder: label, style, ...props }) => {
const [focused, setFocused] = useState(false)
const handleFocus = useCallback(() => {
setFocused(true)
}, [])
const handleBlur = useCallback(() => {
setFocused(false)
}, [])
return (
<Container style={style}>
<Input2 {...props} onFocus={handleFocus} onBlur={handleBlur} className="input-text" />
<InputBorder data-focused={focused} />
<Label
aria-hidden={true}
style={{
color: focused ? 'var(--focused-border-color)' : '',
}} | smartest-dev/telos-keycat | src/design/atoms/Input.tsx | TypeScript |
ArrowFunction |
() => {
setFocused(true)
} | smartest-dev/telos-keycat | src/design/atoms/Input.tsx | TypeScript |
ArrowFunction |
() => {
setFocused(false)
} | smartest-dev/telos-keycat | src/design/atoms/Input.tsx | TypeScript |
InterfaceDeclaration |
interface Props extends HTMLProps<HTMLInputElement> {} | smartest-dev/telos-keycat | src/design/atoms/Input.tsx | TypeScript |
ArrowFunction |
({ $stateParams: { provider, instanceId } }) => {
this.setState({ provider, instanceId, loading: true, accountId: null, moniker: null, environment: null });
} | Young-ook/deck | app/scripts/modules/core/src/instance/details/InstanceDetails.tsx | TypeScript |
ArrowFunction |
({ app, $stateParams }) => {
const { provider, instanceId } = $stateParams;
const accountId = Observable.fromPromise(SkinService.getAccountForInstance(provider, instanceId, app));
const moniker = Observable.fromPromise(SkinService.getMonikerForInstance(provider, instanceId, app));
const accountDetails = accountId.mergeMap(id => AccountService.getAccountDetails(id));
return Observable.forkJoin(accountId, moniker, accountDetails);
} | Young-ook/deck | app/scripts/modules/core/src/instance/details/InstanceDetails.tsx | TypeScript |
ArrowFunction |
id => AccountService.getAccountDetails(id) | Young-ook/deck | app/scripts/modules/core/src/instance/details/InstanceDetails.tsx | TypeScript |
ArrowFunction |
([accountId, moniker, accountDetails]) => {
const environment = accountDetails && accountDetails.environment;
this.setState({ accountId, moniker, environment, loading: false });
} | Young-ook/deck | app/scripts/modules/core/src/instance/details/InstanceDetails.tsx | TypeScript |
ClassDeclaration |
export class InstanceDetails extends React.Component<IInstanceDetailsProps, IInstanceDetailsState> {
public state: IInstanceDetailsState = {
accountId: null,
environment: null,
instanceId: null,
loading: false,
moniker: null,
provider: null,
};
private destroy$ = new Subject();
private props$ = new Subject<IInstanceDetailsProps>();
public componentDidMount() {
this.props$
.do(({ $stateParams: { provider, instanceId } }) => {
this.setState({ provider, instanceId, loading: true, accountId: null, moniker: null, environment: null });
})
.switchMap(({ app, $stateParams }) => {
const { provider, instanceId } = $stateParams;
const accountId = Observable.fromPromise(SkinService.getAccountForInstance(provider, instanceId, app));
const moniker = Observable.fromPromise(SkinService.getMonikerForInstance(provider, instanceId, app));
const accountDetails = accountId.mergeMap(id => AccountService.getAccountDetails(id));
return Observable.forkJoin(accountId, moniker, accountDetails);
})
.takeUntil(this.destroy$)
.subscribe(([accountId, moniker, accountDetails]) => {
const environment = accountDetails && accountDetails.environment;
this.setState({ accountId, moniker, environment, loading: false });
});
this.props$.next(this.props);
}
public componentWillReceiveProps(nextProps: IInstanceDetailsProps) {
this.props$.next(nextProps);
}
public componentWillUnmount() {
this.destroy$.next();
}
public render() {
const { accountId, instanceId, moniker, environment, loading, provider } = this.state;
if (loading) {
return (
<InstanceDetailsPane>
<Spinner size="medium" message=" " />
</InstanceDetailsPane>
);
} else if (!accountId || !moniker || !environment) {
return (
<InstanceDetailsPane>
<h4>
Could not find {provider} instance {instanceId}.
</h4>
</InstanceDetailsPane>
);
}
return <InstanceDetailsCmp {...this.props} accountId={accountId} moniker={moniker} environment={environment} />;
}
} | Young-ook/deck | app/scripts/modules/core/src/instance/details/InstanceDetails.tsx | TypeScript |
ClassDeclaration |
@Overridable('instance.details')
export class InstanceDetailsCmp extends React.Component<IInstanceDetailsProps> {
public render() {
return <h3>Instance Details</h3>;
}
} | Young-ook/deck | app/scripts/modules/core/src/instance/details/InstanceDetails.tsx | TypeScript |
InterfaceDeclaration |
export interface IInstanceDetailsProps extends IOverridableProps {
$stateParams: {
provider: string;
instanceId: string;
};
app: Application;
moniker: IMoniker;
environment: string;
} | Young-ook/deck | app/scripts/modules/core/src/instance/details/InstanceDetails.tsx | TypeScript |
InterfaceDeclaration |
export interface IInstanceDetailsState {
accountId: string;
environment: string;
instanceId: string;
loading: boolean;
moniker: IMoniker;
provider: string;
} | Young-ook/deck | app/scripts/modules/core/src/instance/details/InstanceDetails.tsx | TypeScript |
MethodDeclaration |
public componentDidMount() {
this.props$
.do(({ $stateParams: { provider, instanceId } }) => {
this.setState({ provider, instanceId, loading: true, accountId: null, moniker: null, environment: null });
})
.switchMap(({ app, $stateParams }) => {
const { provider, instanceId } = $stateParams;
const accountId = Observable.fromPromise(SkinService.getAccountForInstance(provider, instanceId, app));
const moniker = Observable.fromPromise(SkinService.getMonikerForInstance(provider, instanceId, app));
const accountDetails = accountId.mergeMap(id => AccountService.getAccountDetails(id));
return Observable.forkJoin(accountId, moniker, accountDetails);
})
.takeUntil(this.destroy$)
.subscribe(([accountId, moniker, accountDetails]) => {
const environment = accountDetails && accountDetails.environment;
this.setState({ accountId, moniker, environment, loading: false });
});
this.props$.next(this.props);
} | Young-ook/deck | app/scripts/modules/core/src/instance/details/InstanceDetails.tsx | TypeScript |
MethodDeclaration |
public componentWillReceiveProps(nextProps: IInstanceDetailsProps) {
this.props$.next(nextProps);
} | Young-ook/deck | app/scripts/modules/core/src/instance/details/InstanceDetails.tsx | TypeScript |
MethodDeclaration |
public componentWillUnmount() {
this.destroy$.next();
} | Young-ook/deck | app/scripts/modules/core/src/instance/details/InstanceDetails.tsx | TypeScript |
MethodDeclaration |
public render() {
const { accountId, instanceId, moniker, environment, loading, provider } = this.state;
if (loading) {
return (
<InstanceDetailsPane>
<Spinner size="medium" message=" " />
</InstanceDetailsPane>
);
} else if (!accountId || !moniker || !environment) {
return (
<InstanceDetailsPane>
<h4>
Could not find {provider} instance {instanceId}.
</h4>
</InstanceDetailsPane>
);
}
return <InstanceDetailsCmp {...this.props} accountId={accountId} moniker={moniker} environment={environment} />;
} | Young-ook/deck | app/scripts/modules/core/src/instance/details/InstanceDetails.tsx | TypeScript |
MethodDeclaration |
public render() {
return <h3>Instance Details</h3>;
} | Young-ook/deck | app/scripts/modules/core/src/instance/details/InstanceDetails.tsx | TypeScript |
ClassDeclaration |
export declare class ButtonCommandBarExample extends React.Component<IButtonProps, {}> {
render(): JSX.Element;
} | AvinaLakshmi/sp-dev-fx-controls-react | node_modules/@microsoft/office-ui-fabric-react-bundle/node_modules/office-ui-fabric-react/lib-amd/components/Button/examples/Button.CommandBar.Example.d.ts | TypeScript |
MethodDeclaration |
render(): JSX.Element; | AvinaLakshmi/sp-dev-fx-controls-react | node_modules/@microsoft/office-ui-fabric-react-bundle/node_modules/office-ui-fabric-react/lib-amd/components/Button/examples/Button.CommandBar.Example.d.ts | TypeScript |
ArrowFunction |
() => {
Log.logger = console;
Log.level = Log.NONE;
localStorage.clear();
userStoreMock = new WebStorageStateStore();
subject = new UserManager({
authority: "http://sts/oidc",
client_id: "client",
redirect_uri: "http://app/cb",
monitorSession : false,
userStore: userStoreMock,
metadata: {
authorization_endpoint: "http://sts/oidc/authorize",
token_endpoint: "http://sts/oidc/token",
revocation_endpoint: "http://sts/oidc/revoke",
},
});
const location = Object.defineProperties({}, {
...Object.getOwnPropertyDescriptors(window.location),
assign: {
enumerable: true,
value: jest.fn(),
},
replace: {
enumerable: true,
value: jest.fn(),
},
});
Object.defineProperty(window, "location", {
enumerable: true,
get: () => location,
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => location | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should accept settings", () => {
// act
expect(subject.settings.client_id).toEqual("client");
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
// act
expect(subject.settings.client_id).toEqual("client");
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should be UserManagerSettings", () => {
// act
expect(subject.settings).toBeInstanceOf(UserManagerSettingsStore);
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
// act
expect(subject.settings).toBeInstanceOf(UserManagerSettingsStore);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should be able to call getUser without recursion", () => {
// arrange
subject.events.addUserLoaded(async () => {
await subject.getUser();
});
// act
subject.events.load({} as User);
});
it("should return user if there is a user stored", async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
subject["_loadUser"] = jest.fn().mockReturnValue(user);
const loadMock = jest.spyOn(subject["_events"], "load");
// act
const result = await subject.getUser();
// assert
expect(result).toEqual(user);
expect(loadMock).toBeCalledWith(user, false);
});
it("should return null if there is no user stored", async () => {
// arrange
subject["_loadUser"] = jest.fn().mockReturnValue(null);
const loadMock = jest.spyOn(subject["_events"], "load");
// act
const result = await subject.getUser();
// assert
expect(result).toBeNull();
expect(loadMock).not.toBeCalled();
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
// arrange
subject.events.addUserLoaded(async () => {
await subject.getUser();
});
// act
subject.events.load({} as User);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
await subject.getUser();
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
subject["_loadUser"] = jest.fn().mockReturnValue(user);
const loadMock = jest.spyOn(subject["_events"], "load");
// act
const result = await subject.getUser();
// assert
expect(result).toEqual(user);
expect(loadMock).toBeCalledWith(user, false);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
subject["_loadUser"] = jest.fn().mockReturnValue(null);
const loadMock = jest.spyOn(subject["_events"], "load");
// act
const result = await subject.getUser();
// assert
expect(result).toBeNull();
expect(loadMock).not.toBeCalled();
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should remove user from store and event unload", async () => {
// arrange
const storeUserMock = jest.spyOn(subject, "storeUser");
const unloadMock = jest.spyOn(subject["_events"], "unload");
// act
await subject.removeUser();
// assert
expect(storeUserMock).toBeCalledWith(null);
expect(unloadMock).toBeCalled();
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const storeUserMock = jest.spyOn(subject, "storeUser");
const unloadMock = jest.spyOn(subject["_events"], "unload");
// act
await subject.removeUser();
// assert
expect(storeUserMock).toBeCalledWith(null);
expect(unloadMock).toBeCalled();
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should revoke the token types specified", async () => {
// arrange
const user = {
access_token: "foo",
refresh_token: "bar",
};
subject["_loadUser"] = jest.fn().mockReturnValue(user);
const revokeSpy = jest.spyOn(subject["_client"], "revokeToken").mockResolvedValue(undefined);
const storeUserSpy = jest.spyOn(subject, "storeUser").mockResolvedValue(undefined);
// act
await subject.revokeTokens(["access_token", "refresh_token"]);
// assert
expect(revokeSpy).toHaveBeenNthCalledWith(1, "foo", "access_token");
expect(revokeSpy).toHaveBeenNthCalledWith(2, "bar", "refresh_token");
expect(user).toMatchObject({
access_token: "foo",
refresh_token: null,
});
expect(storeUserSpy).toHaveBeenCalled();
});
it("should skip revoking absent token types", async () => {
// arrange
subject["_loadUser"] = jest.fn().mockReturnValue({
access_token: "foo",
});
const revokeSpy = jest.spyOn(subject["_client"], "revokeToken").mockResolvedValue(undefined);
jest.spyOn(subject, "storeUser").mockResolvedValue(undefined);
// act
await subject.revokeTokens(["access_token", "refresh_token"]);
// assert
expect(revokeSpy).toHaveBeenCalledTimes(1);
expect(revokeSpy).not.toHaveBeenCalledWith(expect.anything(), "refresh_token");
});
it("should succeed with no user session", async () => {
// act
await expect(subject.revokeTokens())
// assert
.resolves.toBe(undefined);
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const user = {
access_token: "foo",
refresh_token: "bar",
};
subject["_loadUser"] = jest.fn().mockReturnValue(user);
const revokeSpy = jest.spyOn(subject["_client"], "revokeToken").mockResolvedValue(undefined);
const storeUserSpy = jest.spyOn(subject, "storeUser").mockResolvedValue(undefined);
// act
await subject.revokeTokens(["access_token", "refresh_token"]);
// assert
expect(revokeSpy).toHaveBeenNthCalledWith(1, "foo", "access_token");
expect(revokeSpy).toHaveBeenNthCalledWith(2, "bar", "refresh_token");
expect(user).toMatchObject({
access_token: "foo",
refresh_token: null,
});
expect(storeUserSpy).toHaveBeenCalled();
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
subject["_loadUser"] = jest.fn().mockReturnValue({
access_token: "foo",
});
const revokeSpy = jest.spyOn(subject["_client"], "revokeToken").mockResolvedValue(undefined);
jest.spyOn(subject, "storeUser").mockResolvedValue(undefined);
// act
await subject.revokeTokens(["access_token", "refresh_token"]);
// assert
expect(revokeSpy).toHaveBeenCalledTimes(1);
expect(revokeSpy).not.toHaveBeenCalledWith(expect.anything(), "refresh_token");
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// act
await expect(subject.revokeTokens())
// assert
.resolves.toBe(undefined);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should redirect the browser to the authorize url", async () => {
// act
await subject.signinRedirect();
// assert
expect(window.location.assign).toHaveBeenCalledWith(
expect.stringContaining(subject.settings.metadata!.authorization_endpoint!),
);
const [location] = mocked(window.location.assign).mock.calls[0];
const state = new URL(location).searchParams.get("state");
const item = await userStoreMock.get(state!);
expect(JSON.parse(item!)).toHaveProperty("request_type", "si:r");
});
it("should pass navigator params to navigator", async () => {
// arrange
const prepareMock = jest.spyOn(subject["_redirectNavigator"], "prepare");
subject["_signinStart"] = jest.fn();
const navParams: SigninRedirectArgs = {
redirectMethod: "assign",
};
// act
await subject.signinRedirect(navParams);
// assert
expect(prepareMock).toBeCalledWith(navParams);
});
it("should pass extra args to _signinStart", async () => {
// arrange
jest.spyOn(subject["_redirectNavigator"], "prepare");
subject["_signinStart"] = jest.fn();
const extraArgs: SigninRedirectArgs = {
extraQueryParams: { q : "q" },
extraTokenParams: { t: "t" },
state: "state",
};
// act
await subject.signinRedirect(extraArgs);
// assert
expect(subject["_signinStart"]).toBeCalledWith(
{
request_type: "si:r",
...extraArgs,
},
expect.objectContaining({
close: expect.any(Function),
navigate: expect.any(Function),
}),
);
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// act
await subject.signinRedirect();
// assert
expect(window.location.assign).toHaveBeenCalledWith(
expect.stringContaining(subject.settings.metadata!.authorization_endpoint!),
);
const [location] = mocked(window.location.assign).mock.calls[0];
const state = new URL(location).searchParams.get("state");
const item = await userStoreMock.get(state!);
expect(JSON.parse(item!)).toHaveProperty("request_type", "si:r");
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const prepareMock = jest.spyOn(subject["_redirectNavigator"], "prepare");
subject["_signinStart"] = jest.fn();
const navParams: SigninRedirectArgs = {
redirectMethod: "assign",
};
// act
await subject.signinRedirect(navParams);
// assert
expect(prepareMock).toBeCalledWith(navParams);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
jest.spyOn(subject["_redirectNavigator"], "prepare");
subject["_signinStart"] = jest.fn();
const extraArgs: SigninRedirectArgs = {
extraQueryParams: { q : "q" },
extraTokenParams: { t: "t" },
state: "state",
};
// act
await subject.signinRedirect(extraArgs);
// assert
expect(subject["_signinStart"]).toBeCalledWith(
{
request_type: "si:r",
...extraArgs,
},
expect.objectContaining({
close: expect.any(Function),
navigate: expect.any(Function),
}),
);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should return a user", async () => {
// arrange
const spy = jest.spyOn(subject["_client"], "processSigninResponse")
.mockResolvedValue({} as SigninResponse);
await userStoreMock.set("test", JSON.stringify({
id: "test",
request_type: "si:r",
...subject.settings,
}));
// act
const user = await subject.signinRedirectCallback("http://app/cb?state=test&code=code");
// assert
expect(user).toBeInstanceOf(User);
spy.mockRestore();
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const spy = jest.spyOn(subject["_client"], "processSigninResponse")
.mockResolvedValue({} as SigninResponse);
await userStoreMock.set("test", JSON.stringify({
id: "test",
request_type: "si:r",
...subject.settings,
}));
// act
const user = await subject.signinRedirectCallback("http://app/cb?state=test&code=code");
// assert
expect(user).toBeInstanceOf(User);
spy.mockRestore();
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should pass navigator params to navigator", async () => {
// arrange
const handle = { } as PopupWindow;
const prepareMock = jest.spyOn(subject["_popupNavigator"], "prepare")
.mockImplementation(() => Promise.resolve(handle));
subject["_signin"] = jest.fn();
const navParams: SigninPopupArgs = {
popupWindowFeatures: {
location: false,
toolbar: false,
height: 100,
},
popupWindowTarget: "popupWindowTarget",
};
// act
await subject.signinPopup(navParams);
// assert
expect(prepareMock).toBeCalledWith(navParams);
});
it("should pass extra args to _signinStart", async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
const handle = { } as PopupWindow;
jest.spyOn(subject["_popupNavigator"], "prepare")
.mockImplementation(() => Promise.resolve(handle));
subject["_signin"] = jest.fn().mockResolvedValue(user);
const extraArgs: SigninPopupArgs = {
extraQueryParams: { q : "q" },
extraTokenParams: { t: "t" },
state: "state",
};
// act
await subject.signinPopup(extraArgs);
// assert
expect(subject["_signin"]).toBeCalledWith(
{
request_type: "si:p",
redirect_uri: subject.settings.redirect_uri,
display: "popup",
...extraArgs,
},
handle,
);
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const handle = { } as PopupWindow;
const prepareMock = jest.spyOn(subject["_popupNavigator"], "prepare")
.mockImplementation(() => Promise.resolve(handle));
subject["_signin"] = jest.fn();
const navParams: SigninPopupArgs = {
popupWindowFeatures: {
location: false,
toolbar: false,
height: 100,
},
popupWindowTarget: "popupWindowTarget",
};
// act
await subject.signinPopup(navParams);
// assert
expect(prepareMock).toBeCalledWith(navParams);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => Promise.resolve(handle) | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
const handle = { } as PopupWindow;
jest.spyOn(subject["_popupNavigator"], "prepare")
.mockImplementation(() => Promise.resolve(handle));
subject["_signin"] = jest.fn().mockResolvedValue(user);
const extraArgs: SigninPopupArgs = {
extraQueryParams: { q : "q" },
extraTokenParams: { t: "t" },
state: "state",
};
// act
await subject.signinPopup(extraArgs);
// assert
expect(subject["_signin"]).toBeCalledWith(
{
request_type: "si:p",
redirect_uri: subject.settings.redirect_uri,
display: "popup",
...extraArgs,
},
handle,
);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should call navigator callback", async () => {
// arrange
const callbackMock = jest.spyOn(subject["_popupNavigator"], "callback");
const url = "http://app/cb?state=test&code=code";
const keepOpen = true;
// act
await subject.signinPopupCallback(url, keepOpen);
// assert
expect(callbackMock).toBeCalledWith(url, keepOpen);
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const callbackMock = jest.spyOn(subject["_popupNavigator"], "callback");
const url = "http://app/cb?state=test&code=code";
const keepOpen = true;
// act
await subject.signinPopupCallback(url, keepOpen);
// assert
expect(callbackMock).toBeCalledWith(url, keepOpen);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should pass silentRequestTimeout from settings", async () => {
// arrange
const user = new User({
id_token: "id_token",
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
Object.assign(subject.settings, {
silentRequestTimeoutInSeconds: 123,
silent_redirect_uri: "http://client/silent_callback",
});
subject["_signin"] = jest.fn().mockResolvedValue(user);
// act
await subject.signinSilent();
const [, navInstance] = mocked(subject["_signin"]).mock.calls[0];
// assert
expect(navInstance).toHaveProperty("_timeoutInSeconds", 123);
});
it("should pass navigator params to navigator", async () => {
// arrange
const prepareMock = jest.spyOn(subject["_iframeNavigator"], "prepare");
subject["_signin"] = jest.fn();
const navParams: SigninSilentArgs = {
silentRequestTimeoutInSeconds: 234,
};
// act
await subject.signinSilent(navParams);
// assert
expect(prepareMock).toBeCalledWith(navParams);
});
it("should pass extra args to _signinStart", async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
jest.spyOn(subject["_popupNavigator"], "prepare");
subject["_signin"] = jest.fn().mockResolvedValue(user);
const extraArgs: SigninSilentArgs = {
extraQueryParams: { q : "q" },
extraTokenParams: { t: "t" },
state: "state",
};
// act
await subject.signinSilent(extraArgs);
// assert
expect(subject["_signin"]).toBeCalledWith(
{
request_type: "si:s",
redirect_uri: subject.settings.redirect_uri,
prompt: "none",
id_token_hint: undefined,
...extraArgs,
},
expect.objectContaining({
close: expect.any(Function),
navigate: expect.any(Function),
}),
undefined,
);
});
it("should work when having no user present", async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
Object.assign(subject.settings, {
silent_redirect_uri: "http://client/silent_callback",
});
subject["_signin"] = jest.fn().mockResolvedValue(user);
// act
await subject.signinSilent();
});
it("should use the refresh_token grant when a refresh token is present", async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
refresh_token: "refresh_token",
profile: {
sub: "sub",
nickname: "Nick",
} as UserProfile,
});
const useRefreshTokenSpy = jest.spyOn(subject["_client"], "useRefreshToken").mockResolvedValue({
access_token: "new_access_token",
profile: {
sub: "sub",
nickname: "Nicholas",
},
} as unknown as SigninResponse);
subject["_loadUser"] = jest.fn().mockResolvedValue(user);
// act
const refreshedUser = await subject.signinSilent();
expect(refreshedUser).toHaveProperty("access_token", "new_access_token");
expect(refreshedUser!.profile).toHaveProperty("nickname", "Nicholas");
expect(useRefreshTokenSpy).toBeCalledWith(expect.objectContaining({ refresh_token: user.refresh_token }));
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const user = new User({
id_token: "id_token",
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
Object.assign(subject.settings, {
silentRequestTimeoutInSeconds: 123,
silent_redirect_uri: "http://client/silent_callback",
});
subject["_signin"] = jest.fn().mockResolvedValue(user);
// act
await subject.signinSilent();
const [, navInstance] = mocked(subject["_signin"]).mock.calls[0];
// assert
expect(navInstance).toHaveProperty("_timeoutInSeconds", 123);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const prepareMock = jest.spyOn(subject["_iframeNavigator"], "prepare");
subject["_signin"] = jest.fn();
const navParams: SigninSilentArgs = {
silentRequestTimeoutInSeconds: 234,
};
// act
await subject.signinSilent(navParams);
// assert
expect(prepareMock).toBeCalledWith(navParams);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
jest.spyOn(subject["_popupNavigator"], "prepare");
subject["_signin"] = jest.fn().mockResolvedValue(user);
const extraArgs: SigninSilentArgs = {
extraQueryParams: { q : "q" },
extraTokenParams: { t: "t" },
state: "state",
};
// act
await subject.signinSilent(extraArgs);
// assert
expect(subject["_signin"]).toBeCalledWith(
{
request_type: "si:s",
redirect_uri: subject.settings.redirect_uri,
prompt: "none",
id_token_hint: undefined,
...extraArgs,
},
expect.objectContaining({
close: expect.any(Function),
navigate: expect.any(Function),
}),
undefined,
);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
Object.assign(subject.settings, {
silent_redirect_uri: "http://client/silent_callback",
});
subject["_signin"] = jest.fn().mockResolvedValue(user);
// act
await subject.signinSilent();
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
refresh_token: "refresh_token",
profile: {
sub: "sub",
nickname: "Nick",
} as UserProfile,
});
const useRefreshTokenSpy = jest.spyOn(subject["_client"], "useRefreshToken").mockResolvedValue({
access_token: "new_access_token",
profile: {
sub: "sub",
nickname: "Nicholas",
},
} as unknown as SigninResponse);
subject["_loadUser"] = jest.fn().mockResolvedValue(user);
// act
const refreshedUser = await subject.signinSilent();
expect(refreshedUser).toHaveProperty("access_token", "new_access_token");
expect(refreshedUser!.profile).toHaveProperty("nickname", "Nicholas");
expect(useRefreshTokenSpy).toBeCalledWith(expect.objectContaining({ refresh_token: user.refresh_token }));
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should call navigator callback", async () => {
// arrange
const callbackMock = jest.spyOn(subject["_iframeNavigator"], "callback");
const url = "http://app/cb?state=test&code=code";
// act
await subject.signinSilentCallback(url);
// assert
expect(callbackMock).toBeCalledWith(url);
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const callbackMock = jest.spyOn(subject["_iframeNavigator"], "callback");
const url = "http://app/cb?state=test&code=code";
// act
await subject.signinSilentCallback(url);
// assert
expect(callbackMock).toBeCalledWith(url);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should signin redirect callback for request type si:r", async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
const responseState = {
state: { request_type: "si:r" } as SigninState,
response: { } as SigninResponse,
};
jest.spyOn(subject["_client"], "readSigninResponseState")
.mockImplementation(() => Promise.resolve(responseState));
const signinRedirectCallbackMock = jest.spyOn(subject, "signinRedirectCallback")
.mockImplementation(() => Promise.resolve(user));
const url = "http://app/cb?state=test&code=code";
// act
const result = await subject.signinCallback(url);
// assert
expect(signinRedirectCallbackMock).toBeCalledWith(url);
expect(result).toEqual(user);
});
it("should signin popup callback for request type si:p", async () => {
// arrange
const responseState = {
state: { request_type: "si:p" } as SigninState,
response: { } as SigninResponse,
};
jest.spyOn(subject["_client"], "readSigninResponseState")
.mockImplementation(() => Promise.resolve(responseState));
const signinPopupCallbackMock = jest.spyOn(subject, "signinPopupCallback");
const url = "http://app/cb?state=test&code=code";
// act
const result = await subject.signinCallback(url);
// assert
expect(signinPopupCallbackMock).toBeCalledWith(url);
expect(result).toBe(undefined);
});
it("should signin silent callback for request type si:s", async () => {
// arrange
const responseState = {
state: { request_type: "si:s" } as SigninState,
response: { } as SigninResponse,
};
jest.spyOn(subject["_client"], "readSigninResponseState")
.mockImplementation(() => Promise.resolve(responseState));
const signinRedirectCallbackMock = jest.spyOn(subject, "signinSilentCallback");
const url = "http://app/cb?state=test&code=code";
// act
const result = await subject.signinCallback(url);
// assert
expect(signinRedirectCallbackMock).toBeCalledWith(url);
expect(result).toBe(undefined);
});
it("should have valid request type", async () => {
// arrange
const responseState = {
state: { request_type: "dummy" } as SigninState,
response: { } as SigninResponse,
};
jest.spyOn(subject["_client"], "readSigninResponseState")
.mockImplementation(() => Promise.resolve(responseState));
// act
await expect(subject.signinCallback())
// assert
.rejects.toThrow(Error);
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
const responseState = {
state: { request_type: "si:r" } as SigninState,
response: { } as SigninResponse,
};
jest.spyOn(subject["_client"], "readSigninResponseState")
.mockImplementation(() => Promise.resolve(responseState));
const signinRedirectCallbackMock = jest.spyOn(subject, "signinRedirectCallback")
.mockImplementation(() => Promise.resolve(user));
const url = "http://app/cb?state=test&code=code";
// act
const result = await subject.signinCallback(url);
// assert
expect(signinRedirectCallbackMock).toBeCalledWith(url);
expect(result).toEqual(user);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => Promise.resolve(responseState) | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => Promise.resolve(user) | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const responseState = {
state: { request_type: "si:p" } as SigninState,
response: { } as SigninResponse,
};
jest.spyOn(subject["_client"], "readSigninResponseState")
.mockImplementation(() => Promise.resolve(responseState));
const signinPopupCallbackMock = jest.spyOn(subject, "signinPopupCallback");
const url = "http://app/cb?state=test&code=code";
// act
const result = await subject.signinCallback(url);
// assert
expect(signinPopupCallbackMock).toBeCalledWith(url);
expect(result).toBe(undefined);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const responseState = {
state: { request_type: "si:s" } as SigninState,
response: { } as SigninResponse,
};
jest.spyOn(subject["_client"], "readSigninResponseState")
.mockImplementation(() => Promise.resolve(responseState));
const signinRedirectCallbackMock = jest.spyOn(subject, "signinSilentCallback");
const url = "http://app/cb?state=test&code=code";
// act
const result = await subject.signinCallback(url);
// assert
expect(signinRedirectCallbackMock).toBeCalledWith(url);
expect(result).toBe(undefined);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const responseState = {
state: { request_type: "dummy" } as SigninState,
response: { } as SigninResponse,
};
jest.spyOn(subject["_client"], "readSigninResponseState")
.mockImplementation(() => Promise.resolve(responseState));
// act
await expect(subject.signinCallback())
// assert
.rejects.toThrow(Error);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should signout redirect callback for request type so:r", async () => {
// arrange
const responseState = {
state: { request_type: "so:r" } as State,
response: { } as SignoutResponse,
};
jest.spyOn(subject["_client"], "readSignoutResponseState")
.mockImplementation(() => Promise.resolve(responseState));
const signoutRedirectCallbackMock = jest.spyOn(subject, "signoutRedirectCallback")
.mockImplementation();
const url = "http://app/cb?state=test&code=code";
// act
await subject.signoutCallback(url, true);
// assert
expect(signoutRedirectCallbackMock).toBeCalledWith(url);
});
it("should signout popup callback for request type so:p", async () => {
// arrange
const responseState = {
state: { request_type: "so:p" } as State,
response: { } as SignoutResponse,
};
jest.spyOn(subject["_client"], "readSignoutResponseState")
.mockImplementation(() => Promise.resolve(responseState));
const signoutPopupCallbackMock = jest.spyOn(subject, "signoutPopupCallback")
.mockImplementation();
const url = "http://app/cb?state=test&code=code";
const keepOpen = true;
// act
await subject.signoutCallback(url, keepOpen);
// assert
expect(signoutPopupCallbackMock).toBeCalledWith(url, keepOpen);
});
it("should have valid request type", async () => {
// arrange
const responseState = {
state: { request_type: "dummy" } as State,
response: { } as SignoutResponse,
};
jest.spyOn(subject["_client"], "readSignoutResponseState")
.mockImplementation(() => Promise.resolve(responseState));
// act
await expect(subject.signoutCallback())
// assert
.rejects.toThrow(Error);
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const responseState = {
state: { request_type: "so:r" } as State,
response: { } as SignoutResponse,
};
jest.spyOn(subject["_client"], "readSignoutResponseState")
.mockImplementation(() => Promise.resolve(responseState));
const signoutRedirectCallbackMock = jest.spyOn(subject, "signoutRedirectCallback")
.mockImplementation();
const url = "http://app/cb?state=test&code=code";
// act
await subject.signoutCallback(url, true);
// assert
expect(signoutRedirectCallbackMock).toBeCalledWith(url);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const responseState = {
state: { request_type: "so:p" } as State,
response: { } as SignoutResponse,
};
jest.spyOn(subject["_client"], "readSignoutResponseState")
.mockImplementation(() => Promise.resolve(responseState));
const signoutPopupCallbackMock = jest.spyOn(subject, "signoutPopupCallback")
.mockImplementation();
const url = "http://app/cb?state=test&code=code";
const keepOpen = true;
// act
await subject.signoutCallback(url, keepOpen);
// assert
expect(signoutPopupCallbackMock).toBeCalledWith(url, keepOpen);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
async () => {
// arrange
const responseState = {
state: { request_type: "dummy" } as State,
response: { } as SignoutResponse,
};
jest.spyOn(subject["_client"], "readSignoutResponseState")
.mockImplementation(() => Promise.resolve(responseState));
// act
await expect(subject.signoutCallback())
// assert
.rejects.toThrow(Error);
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
ArrowFunction |
() => {
it("should add user to store", async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
// act
await subject.storeUser(user);
// assert
const storageString = await subject.settings.userStore.get(subject["_userStoreKey"]);
expect(storageString).not.toBeNull();
});
it("should remove user from store", async () => {
// arrange
const user = new User({
access_token: "access_token",
token_type: "token_type",
profile: {} as UserProfile,
});
await subject.storeUser(user);
// act
await subject.storeUser(null);
// assert
const storageString = await subject.settings.userStore.get(subject["_userStoreKey"]);
expect(storageString).toBeNull();
});
} | pbklink/oidc-client-ts | src/UserManager.test.ts | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.