How to use logout method in ng-mocks

Best JavaScript code snippet using ng-mocks

test_logout.py

Source:test_logout.py Github

copy

Full Screen

...84 expected = {85 'target': '/',86 }87 self.assertDictContainsSubset(expected, response.context_data)88 def test_client_logout(self):89 """ Verify the context includes a list of the logout URIs of the authenticated OpenID Connect clients.90 The list should only include URIs of the clients for which the user has been authenticated.91 """92 client = self._create_oauth_client()93 response = self._assert_session_logged_out(client)94 expected = {95 'logout_uris': [],96 'target': '/',97 }98 self.assertDictContainsSubset(expected, response.context_data)99 @mock.patch(100 'django.conf.settings.IDA_LOGOUT_URI_LIST',101 ['http://fake.ida1/logout', 'http://fake.ida2/accounts/logout', ]102 )...

Full Screen

Full Screen

logout.py

Source:logout.py Github

copy

Full Screen

...57 # We do not log here, because we have a handler registered to perform logging on successful logouts.58 request.is_from_logout = True59 # Get third party auth provider's logout url60 self.tpa_logout_url = tpa_pipeline.get_idp_logout_url_from_running_pipeline(request)61 logout(request)62 response = super().dispatch(request, *args, **kwargs)63 # Clear the cookie used by the edx.org marketing site64 delete_logged_in_cookies(response)65 return response66 def _build_logout_url(self, url):67 """68 Builds a logout URL with the `no_redirect` query string parameter.69 Args:70 url (str): IDA logout URL71 Returns:72 str73 """74 scheme, netloc, path, query_string, fragment = urlsplit(url)75 query_params = parse_qs(query_string)...

Full Screen

Full Screen

LogoutComponent.js

Source:LogoutComponent.js Github

copy

Full Screen

1/**2 * Created by Andy Likuski on 2020.09.113 * Copyright (c) 2020 Andy Likuski4 *5 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:6 *7 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.8 *9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.10 */11import * as R from 'ramda';12import * as ReactRouterDom from "react-router-dom";13import {14 componentAndPropsFor,15 composeViews,16 e,17 nameLookup,18 propsFor,19 renderChoicepoint,20 renderErrorDefault,21 renderLoadingDefault22} from '@rescapes/helpers-component';23import PropTypes from 'prop-types';24import * as RR from '@rescapes/ramda';25import {defaultNode} from '@rescapes/ramda';26import LogoutButtonComponent from './LogoutButtonComponent.js';27import {AuthenticationBox} from '../themeComponents/authenticationBox';28const {strPathOr, reqStrPathThrowing, strPathOrNullOk} = RR;29const {Redirect, useHistory, useLocation} = defaultNode(ReactRouterDom)30export const c = nameLookup({31 logout: true,32 logoutHeader: true,33 logoutBody: true,34 logoutButton: true,35 logoutLoading: true,36 logoutError: true37});38export default function LogoutComponent(props) {39 // Browser history hook40 const history = useHistory();41 // Browser location hook42 const location = useLocation();43 const allProps = LogoutComponent.views(R.mergeRight(props, {history, location}));44 const propsOf = propsFor(allProps.views);45 return e('div', propsOf(c.logout),46 LogoutComponent.choicepoint(allProps)47 );48}49/**50 *51 * @param {Object} history History object from the useHistory hook52 * @param {Object} location Location object from the useLocation hook53 * @param {Object} queryAuthenticatedUserLocalContainer Apollo query result about state of the user54 * @param views55 * @returns {Object}56 */57LogoutComponent.renderData = ({history, location, mutateDeleteTokenCookie, views}) => {58 const styledComponentAndProps = componentAndPropsFor(views);59 const propsOf = propsFor(views);60 // TODO Since refetchQueries doesn't work well (https://github.com/apollographql/apollo-client/issues/3633)61 // just listen to the result of the mutation and redirect to the referring page or /62 // Ideally we shouldn't have to redirect because the AppContainer's queries should rerun when the token goes63 // is the cache, but I don't know how to get a cache write to trigger dependent queries.64 if (strPathOr(false, 'result.data.deleteTokenCookie', mutateDeleteTokenCookie)) {65 return e(Redirect, {to: '/login'});66 }67 return e(AuthenticationBox, propsOf(c.logoutBody), [68 e('h2', propsOf(c.logoutHeader)),69 e(LogoutButtonComponent, propsOf(c.logoutButton))70 ]);71};72/**73 * Merges parent and state styles into component styles74 * @param style75 */76LogoutComponent.viewStyles = ({style}) => {77 return {78 [c.logout]: {},79 [c.logoutButton]: {},80 [c.logoutBody]: {}81 };82};83LogoutComponent.viewProps = props => {84 return {85 [c.logout]: {},86 [c.logoutBody]: {87 },88 [c.logoutButton]: {89 children: 'Logout'90 }91 };92};93LogoutComponent.viewEventHandlers = props => {94 return {95 [c.logoutButton]: {96 onClick: () => {97 reqStrPathThrowing('mutateDeleteTokenCookie.mutation', props)({98 variables: {}99 });100 }101 }102 };103};104/**105 * Adds to props.views for each component configured in viewEventHandlers, viewProps, and viewStyles106 * @param {Object} props this.props or equivalent for testing107 * @returns {Object} modified props108 */109LogoutComponent.views = composeViews(110 LogoutComponent.viewEventHandlers,111 LogoutComponent.viewProps,112 LogoutComponent.viewStyles113);114/**115 * Loading, Error, or Data based on the props.116 */117LogoutComponent.choicepoint = p => {118 return renderChoicepoint(119 {120 onError: renderErrorDefault(c.logoutError),121 onLoading: renderLoadingDefault(c.logoutLoading),122 onData: LogoutComponent.renderData123 },124 {}125 )(p);126};127LogoutComponent.propTypes = {128 style: PropTypes.shape().isRequired...

Full Screen

Full Screen

saveJS.js

Source:saveJS.js Github

copy

Full Screen

1// $(document).ready(function () {2$('#savetoDB').on('click', function () {3 let name = localStorage.getItem('charName');4 let race = localStorage.getItem('charRace');5 let charClass = localStorage.getItem('charClass');6 let charGender = localStorage.getItem('charGender');7 let charID = localStorage.getItem('charID');8 console.log(charID);9 if (charID === null) {10 createUserChar(name, race, charClass, charGender);11 } else {12 updateUserChar(name, race, charClass, charGender, charID);13 }14});15$(document).foundation();16//Logout button clears localstorage so a new user can login17$('#logout').on('click', function () {18 event.preventDefault();19 // $(document).foundation();20 //CREATES MODAL21 // create a div for the modal22 var logoutModal = $('<div>');23 // add class and ID for modal24 $(logoutModal).addClass('reveal revealStyle');25 $(logoutModal).attr('id', 'logoutModal');26 $(logoutModal).attr('data-reveal', '');27 // append the modal div to mainbody28 $('#mainBody').append(logoutModal);29 //LOGOUT MODAL TITLE30 var logoutTitle = $('<h1>');31 $(logoutTitle).text('Wait!');32 $(logoutModal).append(logoutTitle);33 //LOGOUT EXPLAINED34 var logoutDesc1 = $('<p>');35 $(logoutDesc1).text('Have you saved your character?');36 var logoutDesc2 = $('<p>');37 $(logoutDesc2).text(38 'If you would like to save your character for the next time you use DnD Buddy you will need to click on Save and Logout; otherwise click on Logout without Saving or Cancel.'39 );40 $(logoutModal).append(logoutDesc1);41 $(logoutModal).append(logoutDesc2);42 // LOGOUT BUTTONS43 let logoutBtn1 = $('<a>', {44 text: 'Save and Logout',45 class: 'btn btn-primary logout-button',46 id: 'logout1',47 href: '/logout',48 click: function () {49 let name = localStorage.getItem('charName');50 let race = localStorage.getItem('charRace');51 let charClass = localStorage.getItem('charClass');52 let charGender = localStorage.getItem('charGender');53 let charID = localStorage.getItem('charID');54 console.log(charID);55 if (charID === null) {56 createUserChar(name, race, charClass, charGender);57 } else {58 updateUserChar(name, race, charClass, charGender, charID);59 }60 localStorage.clear();61 // $('logout1').attr('href', '/logout');62 // $('logout1').click();63 $('#logoutModal').foundation('close');64 },65 });66 let logoutBtn2 = $('<a>', {67 text: 'Logout without Saving',68 class: 'btn btn-primary logout-button',69 id: 'logout2',70 href: '/logout',71 click: function () {72 localStorage.clear();73 $('#logoutModal').foundation('close');74 },75 });76 let logoutBtn3 = $('<a>', {77 text: 'Cancel',78 class: 'btn btn-primary logout-button',79 id: 'logout3',80 click: function () {81 $('#logoutModal').foundation('close');82 },83 });84 $(logoutModal).append(logoutBtn1);85 $(logoutModal).append(logoutBtn2);86 $(logoutModal).append(logoutBtn3);87 $(document).foundation();88 $('#logoutModal').foundation('open');89});90// update the user data with the existing character91function updateUserChar(name, race, charClass, charGender, charID) {92 $.ajax({93 url: '/api/save',94 type: 'PUT',95 data: {96 char_name: name,97 race: race,98 char_class: charClass,99 char_gender: charGender,100 char_id: charID,101 },102 });103}104// save the data to the database for a new character105function createUserChar(name, race, charClass, charGender, charID) {106 $.ajax({107 url: '/api/saveANewChar',108 type: 'POST',109 data: {110 char_name: name,111 race: race,112 char_class: charClass,113 char_gender: charGender,114 },115 });116}...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1'use strict';2const Code = require('code');3const Constants = require('../../../../../client/pages/login/constants');4const Lab = require('lab');5const Proxyquire = require('proxyquire');6const React = require('react');7const ReactDOM = require('react-dom');8const ReactTestUtils = require('react-addons-test-utils');9const Store = require('../../../../../client/pages/login/logout/store');10const lab = exports.lab = Lab.script();11const stub = {12 Actions: {13 logout: function () {}14 }15};16const Logout = Proxyquire('../../../../../client/pages/login/logout/index.jsx', {17 '../actions': stub.Actions18});19lab.experiment('Login Logout Form', () => {20 lab.test('it renders', (done) => {21 const LogoutEl = React.createElement(Logout, {});22 const logout = ReactTestUtils.renderIntoDocument(LogoutEl);23 Code.expect(logout).to.exist();24 done();25 });26 lab.test('it handles unmounting', (done) => {27 const container = global.document.createElement('div');28 const LogoutEl = React.createElement(Logout, {});29 ReactDOM.render(LogoutEl, container);30 ReactDOM.unmountComponentAtNode(container);31 done();32 });33 lab.test('it handles a store change', (done) => {34 const LogoutEl = React.createElement(Logout, {});35 const logout = ReactTestUtils.renderIntoDocument(LogoutEl);36 Store.dispatch({37 type: Constants.LOGOUT38 });39 Code.expect(logout.state.loading).to.be.true();40 done();41 });42 lab.test('it renders with success state', (done) => {43 const LogoutEl = React.createElement(Logout, {});44 const logout = ReactTestUtils.renderIntoDocument(LogoutEl);45 Store.dispatch({46 type: Constants.LOGOUT_RESPONSE,47 err: null48 });49 const alerts = ReactTestUtils.scryRenderedDOMComponentsWithClass(logout, 'alert-success');50 Code.expect(alerts).to.have.length(1);51 done();52 });53 lab.test('it renders with error state', (done) => {54 const LogoutEl = React.createElement(Logout, {});55 const logout = ReactTestUtils.renderIntoDocument(LogoutEl);56 Store.dispatch({57 type: Constants.LOGOUT_RESPONSE,58 err: new Error('sorry pal'),59 response: {60 message: 'major fail'61 }62 });63 const alerts = ReactTestUtils.scryRenderedDOMComponentsWithClass(logout, 'alert-warning');64 Code.expect(alerts).to.have.length(1);65 done();66 });...

Full Screen

Full Screen

urls.py

Source:urls.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2"""3Provides basic set of auth urls.4"""5from django.conf.urls.defaults import *6from django.conf import settings7urlpatterns = patterns('')8LOGIN = '^%s$' % settings.LOGIN_URL.lstrip('/')9LOGOUT = '^%s$' % settings.LOGOUT_URL.lstrip('/')10# If user set a LOGOUT_REDIRECT_URL we do a redirect.11# Otherwise we display the default template.12LOGOUT_DATA = {'next_page': getattr(settings, 'LOGOUT_REDIRECT_URL', None)}13# register auth urls depending on whether we use google or hybrid auth14if 'ragendja.auth.middleware.GoogleAuthenticationMiddleware' in \15 settings.MIDDLEWARE_CLASSES:16 urlpatterns += patterns('',17 url(LOGIN, 'ragendja.auth.views.google_login',18 name='django.contrib.auth.views.login'),19 url(LOGOUT, 'ragendja.auth.views.google_logout', LOGOUT_DATA,20 name='django.contrib.auth.views.logout'),21 )22elif 'ragendja.auth.middleware.HybridAuthenticationMiddleware' in \23 settings.MIDDLEWARE_CLASSES:24 urlpatterns += patterns('',25 url(LOGIN, 'ragendja.auth.views.hybrid_login',26 name='django.contrib.auth.views.login'),27 url(LOGOUT, 'ragendja.auth.views.hybrid_logout', LOGOUT_DATA,28 name='django.contrib.auth.views.logout'),29 )30# When faking a real function we always have to add the real function, too.31urlpatterns += patterns('',32 url(LOGIN, 'django.contrib.auth.views.login'),33 url(LOGOUT, 'django.contrib.auth.views.logout', LOGOUT_DATA,),...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { logout } from 'ng-mocks';2import { logout } from 'ng-mocks';3import { logout } from 'ng-mocks';4import { logout } from 'ng-mocks';5import { logout } from 'ng-mocks';6import { logout } from 'ng-mocks';7import { logout } from 'ng-mocks';8import { logout } from 'ng-mocks';9import { logout } from 'ng-mocks';10import { logout } from 'ng-mocks';11import { logout } from 'ng-mocks';12import { logout } from 'ng-mocks';13import { logout } from 'ng-mocks';14import { logout } from

Full Screen

Using AI Code Generation

copy

Full Screen

1import { logout } from 'ng-mocks';2import { AuthService } from './auth.service';3import { TestBed } from '@angular/core/testing';4import { AppComponent } from './app.component';5describe('AppComponent', () => {6 beforeEach(() => {7 TestBed.configureTestingModule({8 });9 });10 it('should logout', () => {11 const fixture = TestBed.createComponent(AppComponent);12 const app = fixture.debugElement.componentInstance;13 const auth = TestBed.get(AuthService);14 logout(auth);15 expect(app.isLoggedIn).toEqual(false);16 });17});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { logout } from 'ng-mocks';2describe('Test', () => {3 it('should logout', () => {4 logout();5 });6});7import 'ng-mocks';8export * from 'ng-mocks';9### `logout()`10### `MockBuilder(fixture, declarations, imports, providers, schemas, entryComponents)`11| imports | `Array<Type>` | The list of imports. |12import { MockBuilder } from 'ng-mocks';13describe('Test', () => {14 beforeEach(() => MockBuilder(MyComponent).keep(MyService));15});16### `MockRender(template, context, declarations, imports, providers, schemas, entryComponents)`17| imports | `Array<Type>` | The list of imports

Full Screen

Using AI Code Generation

copy

Full Screen

1import { logout } from 'ng-mocks';2describe('Test', () => {3 it('should logout', () => {4 logout();5 expect(true).toBeTruthy();6 });7});8export class Service {9 public async doSomething() {10 }11}12The service that imports the class:13@Injectable()14export class MyService {15 constructor(private service: Service) {}16 public async doSomething() {17 await this.service.doSomething();18 }19}20describe('MyService', () => {21 let service: MyService;22 beforeEach(() => {23 TestBed.configureTestingModule({24 mockProvider(Service, {25 doSomething: () => {26 },27 }),28 });29 service = TestBed.inject(MyService);30 });31 it('should do something', async () => {32 await service.doSomething();33 });34});35Error: StaticInjectorError(AppModule)[MyService -> Service]: 36 StaticInjectorError(Platform: core)[MyService -> Service]: 37@Injectable()38export class MyService {39 public async doSomething() {40 }41}42describe('

Full Screen

Using AI Code Generation

copy

Full Screen

1var ngMocks = require('ng-mocks');2var ngModule = require('ng-mocks/dist/ng-module');3describe('test', function() {4 it('test', function() {5 ngMocks.logout();6 });7});8var ngMocks = require('ng-mocks/dist/ng-module');

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ng-mocks automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful