How to use Landing method in Mocha

Best JavaScript code snippet using mocha

Landing.js

Source:Landing.js Github

copy

Full Screen

1import React from "react";2import { Redirect, NavLink } from 'react-router-dom';3import Slider from "react-slick";4import PlacesAutocomplete from 'react-places-autocomplete';5import {6 geocodeByAddress,7 getLatLng8} from 'react-places-autocomplete';9import Modal from './../components/Modal';10import "./../css/Landing.css";11import 'slick-carousel/slick/slick.css';12import 'slick-carousel/slick/slick-theme.css';13import navLogo from './../images/logocolor.png';14import box from './../images/pack.png';15import boat from './../images/boat.png';16import unpack from './../images/unpack.png';17import calendar from './../images/calendar.png';18import graphic from './../images/landing.png';19var settings = {20 arrows: false,21 dots: true,22 infinite: true,23 speed: 1000,24 autoplay: true,25 autoplaySpeed: 7000,26 slidesToShow: 1,27 slidesToScroll: 1,28 outline: 'none',29 fade: true,30 pauseOnHover: false,31 draggable: false32};33class Landing extends React.Component {34 constructor(props) {35 super(props);36 this.state = {37 inputFrom: "",38 fromPlaceID: "",39 fromCountryCode: "",40 fromLatLng: {},41 42 inputTo: "",43 toPlaceID: "",44 toCountryCode: "",45 toLatLng: {},46 navigate: false,47 response: {},48 message: "",49 modal: false,50 waiting: false,51 modalSubmit: false,52 landing: {},53 carousel: []54 }55 }56 componentDidMount() {57 if(this.props.match.params.url)58 {59 fetch(`/getlanding/${this.props.match.params.url}`, {60 method: 'GET',61 headers: {62 'Accept': 'application/json',63 'Content-Type': 'application/json'64 }65 }).then((response) => {66 return response.json();67 }).then((body) => {68 if(body.message !== 'Success')69 {70 console.log(body.message);71 }72 else73 {74 this.setState({landing: body.landing, carousel: body.landing.Carousel});75 }76 });77 }78 }79 handleChangeFrom = inputFrom => {80 this.setState({ inputFrom });81 };82 83 handleSelectFrom = address => {84 var inputFrom = {85 inputFrom: address,86 fromPlaceID: "",87 fromCountryCode: "",88 fromLatLng: {}89 };90 this.setState({ inputFrom: address });91 geocodeByAddress(address)92 .then(results => {93 inputFrom.fromPlaceID = results[0].place_id;94 inputFrom.fromCountryCode = results[0].address_components[results[0].address_components.length - 1].short_name;95 this.setState({96 fromPlaceID: results[0].place_id,97 fromCountryCode: results[0].address_components[results[0].address_components.length - 1].short_name,98 });99 getLatLng(results[0])100 .then((latlng) => {101 inputFrom.fromLatLng = latlng;102 this.setState({103 fromLatLng: latlng104 }, () => {105 sessionStorage.setItem('inputFrom', JSON.stringify(inputFrom));106 });107 })108 .catch(error => console.log('Error', error));109 })110 .catch(error => console.error('Error', error));111 };112 handleChangeTo = inputTo => {113 this.setState({ inputTo });114 };115 116 handleSelectTo = address => {117 var inputTo = {118 inputTo: address,119 toPlaceID: "",120 toCountryCode: "",121 toLatLng: {}122 };123 this.setState({ inputTo: address });124 geocodeByAddress(address)125 .then(results => {126 inputTo.toPlaceID = results[0].place_id;127 inputTo.toCountryCode = results[0].address_components[results[0].address_components.length - 1].short_name;128 this.setState({129 toPlaceID: results[0].place_id,130 toCountryCode: results[0].address_components[results[0].address_components.length - 1].short_name,131 });132 getLatLng(results[0])133 .then((latlng) => {134 inputTo.toLatLng = latlng;135 this.setState({136 toLatLng: latlng137 }, () => {138 sessionStorage.setItem('inputTo', JSON.stringify(inputTo));139 })140 })141 .catch(error => console.log('Error', error));142 })143 .catch(error => console.error('Error', error));144 };145 handleSubmitCheck = (e) => {146 e.preventDefault();147 console.log(this.state.fromCountryCode, this.state.toCountryCode);148 if(this.state.inputFrom === "" || this.state.inputTo === "")149 {150 this.setState({message: "Please enter a value for From and To.", modal: true});151 }152 else if(this.state.fromCountryCode === this.state.toCountryCode)153 {154 this.setState({modal: true, message: "We specialize in cross-country moves. There are likely more efficient solutions for your move. We recommend finding a local moving company.", modalSubmit: true});155 }156 else157 {158 this.handleSubmit();159 }160 }161 handleSubmit() {162 if(this.state.inputFrom === "" || this.state.inputTo === "")163 {164 this.setState({message: "Please enter a value for From and To.", modal: true});165 }166 else167 {168 if(!this.state.waiting) {169 this.setState({waiting: true, modalSubmit: false, modal: false, message: ""});170 fetch(`/calculate-move`, {171 method: 'POST',172 headers: {173 'Accept': 'application/json',174 'Content-Type': 'application/json'175 },176 body: JSON.stringify({177 inputFrom: this.state.inputFrom,178 fromPlaceID: this.state.fromPlaceID,179 fromCountryCode: this.state.fromCountryCode,180 fromLatLng: this.state.fromLatLng,181 182 inputTo: this.state.inputTo,183 toPlaceID: this.state.toPlaceID,184 toCountryCode: this.state.toCountryCode,185 toLatLng: this.state.toLatLng186 })187 })188 .then((response) => response.json())189 .then((body) => {190 if(body.message === "Success")191 {192 this.setState({193 response: {194 result: body.result,195 minIndex: body.minIndex196 },197 waiting: false,198 navigate: true199 })200 }201 else202 {203 this.setState({message: body.message, modal: true, waiting: false});204 }205 });206 }207 }208 }209 render() {210 const searchOptions = {211 types: ['(cities)']212 };213 if(this.state.navigate) {214 return (215 <Redirect216 push217 to={{218 pathname: '/instantprice',219 state: this.state.response220 }}221 />222 )223 }224 return (225 <div className="landingPageContainer">226 <Modal227 visible={this.state.modal}228 >229 <p className="modalMessage">230 {this.state.message || "Test message"}231 </p>232 {this.state.modalSubmit ?233 <button className="modalButton modalConfirm" onClick={() => this.handleSubmit()}>234 OK235 </button>236 :237 <button className="modalButton modalConfirm" onClick={() => this.setState({modal: false})}>238 OK239 </button>240 }241 </Modal>242 <div className="landingPageNav">243 <NavLink class="landingPageNavHome" to="/">244 <img className="landingPageBrand" src={navLogo} alt="Move Tailors"/>245 </NavLink>246 <div className="landingPageNavButtons">247 <NavLink className="landingPageNavButton tahoma landingPageButtonBlue" to="/about">248 Learn More249 </NavLink>250 <NavLink className="landingPageNavButton tahoma landingPageButtonRed" to="/contact">251 Request Info252 </NavLink>253 </div>254 </div>255 <div className="landingPageContent">256 <div className="landingPageForm">257 <h2 className="landingPageFormTitle tahomaBold">258 {this.state.landing.Header}259 </h2>260 <p className="landingPageFormSub tahoma">261 {this.state.landing.Description}262 </p>263 <form264 className="landingPageFormFields"265 onSubmit={this.handleSubmitCheck}266 >267 <PlacesAutocomplete268 value={this.state.inputFrom}269 onChange={this.handleChangeFrom}270 onSelect={this.handleSelectFrom}271 searchOptions={searchOptions}272 >273 {({ getInputProps, suggestions, getSuggestionItemProps, loading }) => (274 <div className="landingPageInputRowUnderline">275 <label className="landingPageLabel tahoma" for="from">From: </label>276 <input277 {...getInputProps({278 placeholder: '',279 className: 'landingPageInputUnderline tahoma location-search-input',280 })}281 id="from"282 // value={this.state.inputForm}283 // onChange={(inputFrom) => this.setState({inputFrom})}284 />285 <div className="autocomplete-dropdown-container">286 {loading && <div>Loading...</div>}287 {suggestions.map(suggestion => {288 const className = suggestion.active ? 'suggestion-item--active tahoma' : 'suggestion-item tahoma'; 289 return (290 <div291 {...getSuggestionItemProps(suggestion, {292 className293 })}294 >295 <span>{suggestion.description}</span>296 </div>297 );298 })}299 </div>300 </div>301 )}302 </PlacesAutocomplete>303 <PlacesAutocomplete304 value={this.state.inputTo}305 onChange={this.handleChangeTo}306 onSelect={this.handleSelectTo}307 searchOptions={searchOptions}308 >309 {({ getInputProps, suggestions, getSuggestionItemProps, loading }) => (310 <div className="landingPageInputRowUnderline">311 <label className="landingPageLabel tahoma" for="from">To: </label>312 <input313 {...getInputProps({314 placeholder: '',315 className: 'landingPageInputUnderline tahoma location-search-input',316 })}317 id="to"318 // value={this.state.inputForm}319 // onChange={(inputFrom) => this.setState({inputFrom})}320 />321 <div className="autocomplete-dropdown-container">322 {loading && <div>Loading...</div>}323 {suggestions.map(suggestion => {324 const className = suggestion.active ? 'suggestion-item--active tahoma' : 'suggestion-item tahoma'; 325 return (326 <div327 {...getSuggestionItemProps(suggestion, {328 className329 })}330 >331 <span>{suggestion.description}</span>332 </div>333 );334 })}335 </div>336 </div>337 )}338 </PlacesAutocomplete>339 <button340 className="landingPageSubmit view-price-home tahoma"341 type="submit"342 style={{backgroundColor: this.state.waiting ? "#e66f6d" : "#ee3b37"}}343 >344 Get price NOW345 </button>346 </form>347 <p className="poweredBy tahoma">Algorithmic pricing powered by Google Maps API</p>348 </div>349 <div className="landingPageSlick">350 <Slider {...settings}>351 {this.state.carousel.map((e, i) =>352 <div className="landingPageSlide">353 <div className="landingPageImg" style={{backgroundImage: `url(${e.url})`}}>354 </div>355 </div>356 )}357 {/* <div className="landingPageSlide">358 <div className="landingPageImg" id="landingPageImg1">359 </div>360 </div>361 <div className="landingPageSlide">362 <div className="landingPageImg" id="landingPageImg2">363 </div>364 </div>365 <div className="landingPageSlide">366 <div className="landingPageImg" id="landingPageImg3">367 </div>368 </div>369 <div className="landingPageSlide">370 <div className="landingPageImg" id="landingPageImg4">371 </div>372 </div>373 <div className="landingPageSlide">374 <div className="landingPageImg" id="landingPageImg5">375 </div>376 </div> */}377 </Slider>378 </div>379 </div>380 <div className="landingPageProcess">381 <div className="landingPageProcessInner">382 <div className="landingPageProcessGraphic">383 {[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].map((e, i) => 384 <div className="landingBlock"></div>385 )}386 </div>387 <div className="landingPageProcessItem">388 <h2 className="landingPageProcessTitle tahomaBold">389 Reserve Online390 </h2>391 <div className="landingPageProcessImgView">392 <img className="landingPageProcessImg" src={calendar} alt="Reserve Online"/>393 </div>394 <p className="landingPageProcessText tahoma">395 We help you in planning and preparing needed documents.396 </p>397 </div>398 <div className="landingPageProcessItem">399 <h2 className="landingPageProcessTitle tahomaBold">400 Fill Container401 </h2>402 <div className="landingPageProcessImgView">403 <img className="landingPageProcessImg" src={box} alt="Fill Container"/>404 </div>405 <p className="landingPageProcessText tahoma">406 You load household goods into the shipping container and seal it.407 </p>408 </div>409 <div className="landingPageProcessItem">410 <h2 className="landingPageProcessTitle tahomaBold">411 We Transport412 </h2>413 <div className="landingPageProcessImgView">414 <img className="landingPageProcessImg" src={boat} alt="We Transport"/>415 </div>416 <p className="landingPageProcessText tahoma">417 We move the container from your old home to your new home.418 </p>419 </div>420 <div className="landingPageProcessItem">421 <h2 className="landingPageProcessTitle tahomaBold">422 You Unpack423 </h2>424 <div className="landingPageProcessImgView">425 <img className="landingPageProcessImg" src={unpack} alt="You Unpack" />426 </div>427 <p className="landingPageProcessText tahoma">428 You receive the sealed container at the new address and unpack.429 </p>430 </div>431 </div>432 </div>433 <img className="landingPageGraphic" src={graphic} alt=""/>434 </div>435 )436 }437}...

Full Screen

Full Screen

acl.spec.js

Source:acl.spec.js Github

copy

Full Screen

1// / <reference types="Cypress" />2import CategoryPageObject from '../../../../support/pages/module/sw-category.page-object';3describe('Landing pages: Test ACL privileges', () => {4 beforeEach(() => {5 // Clean previous state and prepare Administration6 let salesChannel;7 cy.setToInitialState()8 .then(() => {9 cy.loginViaApi();10 return cy.searchViaAdminApi({11 endpoint: 'sales-channel',12 data: {13 field: 'name',14 type: 'equals',15 value: 'Storefront'16 }17 });18 })19 .then((data) => {20 salesChannel = data.id;21 return cy.createDefaultFixture('cms-page', {}, 'cms-landing-page');22 })23 .then((data) => {24 cy.createDefaultFixture('landing-page', {25 cmsPage: data,26 salesChannels: [27 {28 id: salesChannel29 }30 ]31 }, 'landing-page');32 })33 .then(() => {34 cy.openInitialPage(`${Cypress.env('admin')}#/sw/category/index`);35 });36 });37 it('@catalogue: can duplicate landing pages', () => {38 cy.loginAsUserWithPermissions([39 {40 key: 'category',41 role: 'viewer'42 },43 {44 key: 'landing_page',45 role: 'viewer'46 },47 {48 key: 'landing_page',49 role: 'editor'50 },51 {52 key: 'landing_page',53 role: 'creator'54 }55 ]);56 cy.visit(`${Cypress.env('admin')}#/sw/category/index`);57 // Request for duplicate landing page58 cy.intercept({59 url: `${Cypress.env('apiPath')}/_action/clone/landing-page/*`,60 method: 'POST'61 }).as('duplicateData');62 // Request for loading landing pages63 cy.intercept('POST', `${Cypress.env('apiPath')}/search/landing-page`).as('loadLandingPage');64 // Collapse category and expand landing page tree65 cy.get('.sw-category-detail__category-collapse .sw-sidebar-collapse__indicator').click();66 cy.get('.sw-category-detail__landing-page-collapse .sw-sidebar-collapse__indicator').click();67 // Waiting for loading landing pages68 cy.wait('@loadLandingPage');69 // Click on duplicate in context menu70 const page = new CategoryPageObject();71 cy.clickContextMenuItem(72 '.sw-context-menu__duplicate-action',73 page.elements.contextMenuButton,74 `${page.elements.categoryTreeItem}:nth-of-type(1)`75 );76 // Verify duplicate77 cy.wait('@duplicateData')78 .its('response.statusCode').should('equal', 200);79 cy.get(`${page.elements.categoryTreeItem}:nth-child(2)`).contains('Testingpage Copy');80 });81 it('@catalogue: can create landing pages', () => {82 cy.loginAsUserWithPermissions([83 {84 key: 'category',85 role: 'viewer'86 },87 {88 key: 'landing_page',89 role: 'viewer'90 },91 {92 key: 'landing_page',93 role: 'editor'94 },95 {96 key: 'landing_page',97 role: 'creator'98 }99 ]);100 cy.visit(`${Cypress.env('admin')}#/sw/category/index`);101 // Request for save landing page102 cy.intercept({103 url: `${Cypress.env('apiPath')}/landing-page`,104 method: 'POST'105 }).as('saveData');106 // Request for loading the landing pages107 cy.intercept('POST', `${Cypress.env('apiPath')}/search/landing-page`).as('loadLandingPage');108 // Collapse category tree and expand landing page tree109 cy.get('.sw-category-detail__category-collapse .sw-sidebar-collapse__indicator').click();110 cy.get('.sw-category-detail__landing-page-collapse .sw-sidebar-collapse__indicator').click();111 // Wait for loading the landing pages112 cy.wait('@loadLandingPage');113 // Click on add landing page button114 cy.get('.sw-landing-page-tree__add-button a').click();115 // Fill in landing page information116 cy.get('#landingPageName').typeAndCheck('MyLandingPage');117 cy.get('input[name="landingPageActive"]').check();118 cy.get('.sw-landing-page-detail-base__sales_channel').typeMultiSelectAndCheck('Storefront');119 cy.get('#sw-field--landingPage-url').typeAndCheck('my-landing-page');120 // Save landing page121 cy.get('.sw-category-detail__save-landing-page-action').click();122 cy.wait('@saveData')123 .its('response.statusCode').should('equal', 204);124 const page = new CategoryPageObject();125 cy.get(`${page.elements.categoryTreeItem}:nth-child(2)`).first().contains('MyLandingPage');126 });127 it('@catalogue: can view landing pages', () => {128 const page = new CategoryPageObject();129 cy.loginAsUserWithPermissions([130 {131 key: 'category',132 role: 'viewer'133 },134 {135 key: 'landing_page',136 role: 'viewer'137 }138 ]);139 cy.visit(`${Cypress.env('admin')}#/sw/category/index`);140 // Request for loading landing pages141 cy.intercept('POST', `${Cypress.env('apiPath')}/search/landing-page`).as('loadLandingPages');142 // Collapse category and expand landing page tree143 cy.get('.sw-category-detail__category-collapse .sw-sidebar-collapse__indicator').click();144 cy.get('.sw-category-detail__landing-page-collapse .sw-sidebar-collapse__indicator').click();145 // Loading landing pages146 cy.wait('@loadLandingPages');147 // Expect empty state148 cy.get('.sw-empty-state__title').contains('No category selected');149 // Click on the first landing page to view details150 cy.get(`${page.elements.categoryTreeItem}__content`).first().click();151 // Expect the landing page152 cy.get('#landingPageName').should('have.value', 'Testingpage');153 });154 it('@catalogue: can edit landing pages', () => {155 const page = new CategoryPageObject();156 cy.loginAsUserWithPermissions([157 {158 key: 'category',159 role: 'viewer'160 },161 {162 key: 'landing_page',163 role: 'viewer'164 },165 {166 key: 'landing_page',167 role: 'editor'168 }169 ]);170 cy.visit(`${Cypress.env('admin')}#/sw/category/index`);171 // Request for update landing page172 cy.intercept({173 url: `${Cypress.env('apiPath')}/landing-page/*`,174 method: 'PATCH'175 }).as('saveData');176 // Request for loading landing pages177 cy.intercept('POST', `${Cypress.env('apiPath')}/search/landing-page`).as('loadLandingPages');178 // Collapse category and expand landing page tree179 cy.get('.sw-category-detail__category-collapse .sw-sidebar-collapse__indicator').click();180 cy.get('.sw-category-detail__landing-page-collapse .sw-sidebar-collapse__indicator').click();181 // Loading landing pages182 cy.wait('@loadLandingPages');183 // Expect empty screen184 cy.get('.sw-empty-state__title').contains('No category selected');185 // Open landing page for edit186 cy.get(`${page.elements.categoryTreeItem}__content`).first().click();187 // Select landing page188 cy.get('#landingPageName').should('have.value', 'Testingpage');189 // Edit the landing page190 cy.get('#landingPageName').clearTypeAndCheck('Page');191 // Save the landing page192 cy.get('.sw-category-detail__save-landing-page-action').click();193 // Wait for landing page request with correct data to be successful194 cy.wait('@saveData')195 .its('response.statusCode').should('equal', 204);196 });197 it('@catalogue: can delete landing pages', () => {198 cy.loginAsUserWithPermissions([199 {200 key: 'category',201 role: 'viewer'202 },203 {204 key: 'landing_page',205 role: 'viewer'206 },207 {208 key: 'landing_page',209 role: 'editor'210 },211 {212 key: 'landing_page',213 role: 'creator'214 },215 {216 key: 'landing_page',217 role: 'deleter'218 }219 ]);220 cy.visit(`${Cypress.env('admin')}#/sw/category/index`);221 // Request for delete landing page222 cy.intercept({223 url: `${Cypress.env('apiPath')}/landing-page/*`,224 method: 'delete'225 }).as('deleteData');226 // Request for loading landing pages227 cy.intercept('POST', `${Cypress.env('apiPath')}/search/landing-page`).as('loadLandingPage');228 // Collapse category and expand landing page tree229 cy.get('.sw-category-detail__category-collapse .sw-sidebar-collapse__indicator').click();230 cy.get('.sw-category-detail__landing-page-collapse .sw-sidebar-collapse__indicator').click();231 // Loading landing pages232 cy.wait('@loadLandingPage');233 // Click on delete in context menu234 const page = new CategoryPageObject();235 cy.clickContextMenuItem(236 '.sw-context-menu__group-button-delete',237 page.elements.contextMenuButton,238 `${page.elements.categoryTreeItem}:nth-of-type(1)`239 );240 // Expect delete modal to be open241 cy.get('.sw-modal')242 .should('be.visible');243 cy.get('.sw_tree__confirm-delete-text')244 .contains('Testingpage');245 cy.get('.sw-modal__footer > .sw-button--danger > .sw-button__content')246 .should('not.be.disabled')247 .click();248 // Verify deletion249 cy.wait('@deleteData')250 .its('response.statusCode').should('equal', 204);251 });...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import template from './sw-landing-page-tree.html.twig';2import './sw-landing-page-tree.scss';3const { Component } = Shopware;4const { Criteria } = Shopware.Data;5const { mapState } = Shopware.Component.getComponentHelper();6Component.register('sw-landing-page-tree', {7 template,8 inject: ['repositoryFactory', 'syncService', 'acl'],9 mixins: [10 'notification',11 ],12 props: {13 landingPageId: {14 type: String,15 required: false,16 default: null,17 },18 currentLanguageId: {19 type: String,20 required: true,21 },22 allowEdit: {23 type: Boolean,24 required: false,25 default: true,26 },27 allowCreate: {28 type: Boolean,29 required: false,30 default: true,31 },32 allowDelete: {33 type: Boolean,34 required: false,35 default: true,36 },37 },38 data() {39 return {40 loadedLandingPages: {},41 translationContext: 'sw-landing-page',42 linkContext: 'sw.category.landingPage',43 isLoadingInitialData: true,44 };45 },46 computed: {47 ...mapState('swCategoryDetail', [48 'landingPagesToDelete',49 ]),50 cmsLandingPageCriteria() {51 const criteria = new Criteria();52 criteria.limit = 500;53 criteria.addSorting(Criteria.sort('name'));54 return criteria;55 },56 landingPage() {57 return Shopware.State.get('swCategoryDetail').landingPage;58 },59 landingPageRepository() {60 return this.repositoryFactory.create('landing_page');61 },62 landingPages() {63 return Object.values(this.loadedLandingPages);64 },65 disableContextMenu() {66 if (!this.allowEdit) {67 return true;68 }69 return this.currentLanguageId !== Shopware.Context.api.systemLanguageId;70 },71 contextMenuTooltipText() {72 if (!this.allowEdit) {73 return this.$tc('sw-privileges.tooltip.warning');74 }75 return null;76 },77 },78 watch: {79 landingPagesToDelete(value) {80 if (value === undefined) {81 return;82 }83 this.$refs.landingPageTree.onDeleteElements(value);84 Shopware.State.commit('swCategoryDetail/setLandingPagesToDelete', {85 landingPagesToDelete: undefined,86 });87 },88 landingPage(newVal, oldVal) {89 // load data when path is available90 if (!oldVal && this.isLoadingInitialData) {91 this.loadLandingPages();92 return;93 }94 // back to index95 if (newVal === null) {96 return;97 }98 // reload after save99 if (oldVal && this.landingPageId !== 'create' && newVal.id === oldVal.id) {100 this.landingPageRepository.get(newVal.id).then((newLandingPage) => {101 this.$set(this.loadedLandingPages, newLandingPage.id, newLandingPage);102 });103 }104 },105 currentLanguageId() {106 this.isLoadingInitialData = true;107 this.loadedLandingPages = {};108 this.loadLandingPages().finally(() => {109 this.isLoadingInitialData = false;110 });111 },112 },113 created() {114 this.createdComponent();115 },116 methods: {117 createdComponent() {118 this.loadLandingPages()119 .catch(() => {120 this.createNotificationError({121 message: this.$tc('global.notification.unspecifiedSaveErrorMessage'),122 });123 })124 .finally(() => {125 this.isLoadingInitialData = false;126 });127 },128 loadLandingPages() {129 return this.landingPageRepository.search(this.cmsLandingPageCriteria).then((result) => {130 this.addLandingPages(result);131 });132 },133 checkedElementsCount(count) {134 this.$emit('landingPage-checked-elements-count', count);135 },136 deleteCheckedItems(checkedItems) {137 const ids = Object.keys(checkedItems);138 this.landingPageRepository.syncDeleted(ids).then(() => {139 ids.forEach(id => this.removeFromStore(id));140 });141 },142 onDeleteLandingPage({ data: landingPage }) {143 if (landingPage.isNew()) {144 this.$delete(this.loadedLandingPages, landingPage.id);145 return Promise.resolve();146 }147 return this.landingPageRepository.delete(landingPage.id).then(() => {148 this.removeFromStore(landingPage.id);149 if (landingPage.id === this.landingPageId) {150 this.$router.push({ name: 'sw.category.index' });151 }152 });153 },154 changeLandingPage(landingPage) {155 const route = { name: 'sw.category.landingPageDetail', params: { id: landingPage.id } };156 if (this.landingPage && this.landingPageRepository.hasChanges(this.landingPage)) {157 this.$emit('unsaved-changes', route);158 } else {159 this.$router.push(route);160 }161 },162 duplicateElement(contextItem) {163 const behavior = {164 cloneChildren: false,165 overwrites: {166 name: `${contextItem.data.name} ${this.$tc('global.default.copy')}`,167 url: `${contextItem.data.url}-${this.$tc('global.default.copy')}`,168 active: false,169 },170 };171 this.landingPageRepository.clone(contextItem.id, Shopware.Context.api, behavior).then((clone) => {172 const criteria = new Criteria();173 criteria.setIds([clone.id]);174 this.landingPageRepository.search(criteria).then((landingPages) => {175 landingPages.forEach(element => {176 element.childCount = 0;177 element.parentId = null;178 });179 this.addLandingPages(landingPages);180 });181 }).catch(() => {182 this.createNotificationError({183 message: this.$tc('global.notification.unspecifiedSaveErrorMessage'),184 });185 });186 },187 createNewElement(contextItem, parentId, name = '') {188 const newLandingPage = this.createNewLandingPage(name);189 this.addLandingPage(newLandingPage);190 return newLandingPage;191 },192 syncLandingPages() {193 return this.landingPageRepository.sync(this.landingPages);194 },195 createNewLandingPage(name) {196 const newLandingPage = this.landingPageRepository.create();197 newLandingPage.name = name;198 newLandingPage.active = false;199 newLandingPage.save = () => {200 return this.landingPageRepository.save(newLandingPage).then(() => {201 const criteria = new Criteria();202 criteria.setIds([newLandingPage.id].filter((id) => id !== null));203 this.landingPageRepository.search(criteria).then((landingPages) => {204 this.addLandingPages(landingPages);205 });206 });207 };208 return newLandingPage;209 },210 addLandingPage(landingPage) {211 if (!landingPage) {212 return;213 }214 this.$set(this.loadedLandingPages, landingPage.id, landingPage);215 },216 addLandingPages(landingPages) {217 landingPages.forEach((landingPage) => {218 this.$set(this.loadedLandingPages, landingPage.id, landingPage);219 });220 },221 removeFromStore(id) {222 this.$delete(this.loadedLandingPages, id);223 },224 getLandingPageUrl(landingPage) {225 return this.$router.resolve({226 name: this.linkContext,227 params: { id: landingPage.id },228 }).href;229 },230 newLandingPageUrl() {231 return {232 name: 'sw.category.landingPageDetail',233 params: { id: 'create' },234 };235 },236 },...

Full Screen

Full Screen

LandingSpot.js

Source:LandingSpot.js Github

copy

Full Screen

1/************************************** 2 Copyright Unluck Software 3 www.chemicalbliss.com 4***************************************/5#pragma strict6@HideInInspector7var landingChild:FlockChild;8@HideInInspector9var landing:boolean;10private var lerpCounter:int;11@HideInInspector12var _controller:LandingSpotController;13private var _idle:boolean;14var _thisT:Transform; //Reference to transform component15function Start() {16 if(!_thisT) _thisT = transform;17 if (!_controller)18 _controller = _thisT.parent.GetComponent(LandingSpotController);19 if (_controller._autoCatchDelay.x > 0)20 GetFlockChild(_controller._autoCatchDelay.x, _controller._autoCatchDelay.y); 21 RandomRotate();22}23function OnDrawGizmos() {24 if(!_thisT) _thisT = transform;25 if (!_controller)26 _controller = _thisT.parent.GetComponent(LandingSpotController);27 28 Gizmos.color = Color.yellow;29 // Draw a yellow cube at the transforms position30 if (landingChild && landing)31 Gizmos.DrawLine(_thisT.position, landingChild._thisT.position);32 if (_thisT.rotation.eulerAngles.x != 0 || _thisT.rotation.eulerAngles.z != 0)33 _thisT.eulerAngles = new Vector3(0, _thisT.eulerAngles.y, 0);34 Gizmos.DrawWireCube(Vector3(_thisT.position.x, _thisT.position.y, _thisT.position.z), Vector3(.2, .2, .2));35 Gizmos.DrawWireCube(_thisT.position + (_thisT.forward * .2), Vector3(.1, .1, .1));36 Gizmos.color = Color(1, 1, 0, .05);37 Gizmos.DrawWireSphere(_thisT.position, _controller._maxBirdDistance);38}39function LateUpdate() {40 if (_controller._flock.gameObject.activeInHierarchy && landing && landingChild) {41 if(!landingChild.gameObject.activeInHierarchy){ 42 ReleaseFlockChild(0,0);43 }44 //Check distance to flock child45 var distance:float = Vector3.Distance(landingChild._thisT.position, _thisT.position);46 //Start landing if distance is close enough47 if (distance < 5 && distance > .5) {48 if(_controller._soarLand){49 landingChild._model.GetComponent.<Animation>().CrossFade(landingChild._spawner._soarAnimation, .5);50 if (distance < 2)51 landingChild._model.GetComponent.<Animation>().CrossFade(landingChild._spawner._flapAnimation, .5);52 }53 landingChild._targetSpeed = landingChild._spawner._maxSpeed*.5;54 landingChild._wayPoint = _thisT.position; 55 landingChild._damping = _controller._landingTurnSpeedModifier;56 landingChild._avoid = false;57 } else if (distance <= .5) {58 59 landingChild._wayPoint = _thisT.position;60 61 if (distance < .1 && !_idle) {62 _idle = true;63 landingChild._model.GetComponent.<Animation>().CrossFade(landingChild._spawner._idleAnimation, .55); 64 }65 66 if (distance > .01){ 67 landingChild._targetSpeed = landingChild._spawner._minSpeed*this._controller._landingSpeedModifier;68 landingChild._thisT.position += (_thisT.position - landingChild._thisT.position) * Time.deltaTime *landingChild._speed*_controller._landingSpeedModifier; 69 }70 71 landingChild._move = false;72 lerpCounter++;73 74 var rot:Quaternion = landingChild._thisT.rotation;75 var rotE:Vector3 = rot.eulerAngles; 76 rotE.y = Mathf.LerpAngle(landingChild._thisT.rotation.eulerAngles.y, _thisT.rotation.eulerAngles.y, lerpCounter * Time.deltaTime * .005); 77 rot.eulerAngles = rotE;78 landingChild._thisT.rotation = rot;79 landingChild._damping = _controller._landingTurnSpeedModifier;80 } else {81 //Move towards landing spot82 landingChild._wayPoint = _thisT.position;83 landingChild._damping = 1;84 }85 } 86}87function GetFlockChild(minDelay:float, maxDelay:float):IEnumerator {88 yield WaitForSeconds(Random.Range(minDelay, maxDelay));89 if (_controller._flock.gameObject.activeInHierarchy && !landingChild) {90 RandomRotate();91 92 var fChild:FlockChild;93 for (var i:int = 0; i < _controller._flock._roamers.Count; i++) {94 var child:FlockChild = _controller._flock._roamers[i] as FlockChild;95 if (!child._landing && !child._dived) { 96 if(!_controller._onlyBirdsAbove){ 97 if (!fChild && _controller._maxBirdDistance > Vector3.Distance(child._thisT.position, _thisT.position) && _controller._minBirdDistance < Vector3.Distance(child._thisT.position, _thisT.position)) {98 fChild = child;99 if (!_controller._takeClosest) break;100 } else if (fChild && Vector3.Distance(fChild._thisT.position, _thisT.position) > Vector3.Distance(child._thisT.position, _thisT.position)) {101 fChild = child;102 }103 }else{104 if (!fChild && child._thisT.position.y > _thisT.position.y && _controller._maxBirdDistance > Vector3.Distance(child._thisT.position, _thisT.position) && _controller._minBirdDistance < Vector3.Distance(child._thisT.position, _thisT.position)) {105 fChild = child;106 if (!_controller._takeClosest) break;107 } else if (fChild && child._thisT.position.y > _thisT.position.y && Vector3.Distance(fChild._thisT.position, _thisT.position) > Vector3.Distance(child._thisT.position, _thisT.position)) {108 fChild = child;109 }110 }111 }112 }113 if (fChild) {114 landingChild = fChild;115 landing = true;116 landingChild._landing = true;117 ReleaseFlockChild(_controller._autoDismountDelay.x, _controller._autoDismountDelay.y);118 } else if (_controller._autoCatchDelay.x > 0) {119 GetFlockChild(_controller._autoCatchDelay.x, _controller._autoCatchDelay.y);120 }121 }122}123function RandomRotate(){ 124 if (_controller._randomRotate){125 var rot:Quaternion = _thisT.rotation;126 var rotE:Vector3 = rot.eulerAngles; 127 rotE.y = Random.Range(0, 360);128 rot.eulerAngles = rotE;129 _thisT.rotation = rot;130 }131}132function InstantLand() {133 if (_controller._flock.gameObject.activeInHierarchy && !landingChild) {134 var fChild:FlockChild;135 136 for (var i:int = 0; i < _controller._flock._roamers.Count; i++) {137 var child:FlockChild = _controller._flock._roamers[i] as FlockChild;138 if (!child._landing && !child._dived) {139 fChild = child; 140 }141 }142 if (fChild) {143 landingChild = fChild;144 landing = true;145 landingChild._landing = true;146 landingChild._thisT.position = _thisT.position;147 landingChild._model.GetComponent.<Animation>().Play(landingChild._spawner._idleAnimation);148 ReleaseFlockChild(_controller._autoDismountDelay.x, _controller._autoDismountDelay.y);149 } else if (_controller._autoCatchDelay.x > 0) {150 GetFlockChild(_controller._autoCatchDelay.x, _controller._autoCatchDelay.y);151 }152 }153}154function ReleaseFlockChild(minDelay:float, maxDelay:float) {155 yield WaitForSeconds(Random.Range(minDelay, maxDelay));156 if (_controller._flock.gameObject.activeInHierarchy && landingChild) {157 lerpCounter = 0;158 if (_controller._featherPS){159 _controller._featherPS.position = landingChild._thisT.position;160 _controller._featherPS.GetComponent.<ParticleSystem>().Emit(Random.Range(0,3));161 } 162 landing = false;163 _idle = false;164 landingChild._avoid = true;165 //Reset flock child to flight mode166 landingChild._damping = landingChild._spawner._maxDamping;167 landingChild._model.GetComponent.<Animation>().CrossFade(landingChild._spawner._flapAnimation, .2);168 landingChild._dived = true;169 landingChild._speed = 0; 170 landingChild._move = true;171 landingChild._landing = false;172 landingChild.Flap(); 173 landingChild._wayPoint = Vector3(landingChild._wayPoint.x, _thisT.position.y+10, landingChild._wayPoint.z); 174 yield WaitForSeconds(.1);175 if (_controller._autoCatchDelay.x > 0) {176 GetFlockChild(_controller._autoCatchDelay.x, _controller._autoCatchDelay.y);177 }178 landingChild = null;179 }...

Full Screen

Full Screen

landing_spec.js

Source:landing_spec.js Github

copy

Full Screen

...5 beforeEach(function() {6 this.landingElement = {};7 this.dismissButton = {};8 this.cookieName = 'cookie_name';9 this.landing = new Landing(this.landingElement, this.dismissButton, this.cookieName);10 });11 it('should set .landing', function() {12 expect(this.landing.landingElement).toBe(this.landingElement);13 });14 it('should set .cookieName', function() {15 expect(this.landing.cookieName).toBe(this.cookieName);16 });17 it('should set .dismissButton', function() {18 expect(this.landing.dismissButton).toBe(this.dismissButton);19 });20 it('should set .eventWrapper', function() {21 expect(this.landing.eventWrapper).toEqual({});22 });23 });...

Full Screen

Full Screen

crud.spec.js

Source:crud.spec.js Github

copy

Full Screen

1// / <reference types="Cypress" />2describe('Category: Landing pages', () => {3 beforeEach(() => {4 // Clean previous state and prepare Administration5 cy.setToInitialState()6 .then(() => {7 cy.loginViaApi();8 cy.createDefaultFixture('cms-page', {}, 'cms-landing-page');9 })10 .then(() => {11 cy.openInitialPage(`${Cypress.env('admin')}#/sw/category/index`);12 });13 });14 it('@catalogue: create a landing page and check storefront behavior', () => {15 cy.intercept('POST', `${Cypress.env('apiPath')}/search/landing-page`).as('loadLandingPages');16 cy.intercept('POST', `${Cypress.env('apiPath')}/landing-page`).as('saveLandingPage');17 cy.get('.sw-category-detail__landing-page-collapse .sw-sidebar-collapse__indicator')18 .click();19 cy.wait('@loadLandingPages');20 cy.get('.sw-landing-page-tree__add-button a').click();21 // fill in information22 cy.get('#landingPageName').typeAndCheck('MyLandingPage');23 cy.get('input[name="landingPageActive"]').check();24 cy.get('.sw-landing-page-detail-base__sales_channel').typeMultiSelectAndCheck('Storefront');25 cy.get('#sw-field--landingPage-metaTitle').typeAndCheck('MyLandingPage-MetaTitle');26 cy.get('#sw-field--landingPage-metaDescription').typeAndCheck('MyLandingPage-MetaDescription');27 cy.get('#sw-field--landingPage-keywords').typeAndCheck('MyLandingPage-SeoKeyword MyLandingPage-AnotherSeoKeyword');28 cy.get('#sw-field--landingPage-url').typeAndCheck('my-landing-page');29 // assign layout30 cy.get('.sw-landing-page-detail__tab-cms').click();31 cy.get('.sw-category-detail-layout__change-layout-action').click();32 cy.get('.sw-cms-layout-modal__content-item--0 input[type="checkbox"]').click();33 cy.contains('.sw-modal__footer .sw-button', 'Save').click();34 // save35 cy.get('.sw-category-detail__save-landing-page-action').click();36 cy.wait('@saveLandingPage');37 // verify changes38 cy.intercept('POST', `${Cypress.env('apiPath')}/search/landing-page`).as('loadLandingPage');39 cy.reload();40 cy.wait('@loadLandingPage');41 cy.get('#landingPageName').should('have.value', 'MyLandingPage');42 cy.get('input[name="landingPageActive"]').should('be.checked');43 cy.get('.sw-landing-page-detail-base__sales_channel').should('contain', 'Storefront');44 cy.get('#sw-field--landingPage-metaTitle').should('have.value', 'MyLandingPage-MetaTitle');45 cy.get('#sw-field--landingPage-metaDescription').should('have.value', 'MyLandingPage-MetaDescription');46 cy.get('#sw-field--landingPage-keywords').should('have.value', 'MyLandingPage-SeoKeyword MyLandingPage-AnotherSeoKeyword');47 cy.get('#sw-field--landingPage-url').should('have.value', 'my-landing-page');48 // find entry in landing page tree49 cy.contains('.sw-landing-page-tree .sw-tree-item__content', 'MyLandingPage').should('be.visible');50 // check storefront51 let editPage = '';52 cy.url().then(urlString => {53 editPage = urlString;54 });55 cy.visit('/my-landing-page');56 cy.get('head title').should('contain', 'MyLandingPage-MetaTitle');57 cy.get('head meta[name="description"]').should('have.attr', 'content', 'MyLandingPage-MetaDescription');58 cy.get('head meta[name="keywords"]').should('have.attr', 'content', 'MyLandingPage-SeoKeyword MyLandingPage-AnotherSeoKeyword');59 cy.contains('.cms-page', 'Baumhaus landing page').should('be.visible');60 // disable landing page61 cy.intercept('POST', `${Cypress.env('apiPath')}/search/landing-page`).as('loadLandingPageForEdit');62 cy.then(() => {63 cy.visit(editPage);64 });65 cy.wait('@loadLandingPageForEdit');66 cy.get('input[name="landingPageActive"]').uncheck();67 cy.intercept('PATCH', `${Cypress.env('apiPath')}/landing-page/*`).as('patchLandingPage');68 cy.get('.sw-category-detail__save-landing-page-action').click();69 cy.wait('@patchLandingPage');70 // check for invalid storefront71 cy.visit('/my-landing-page', { failOnStatusCode: false });72 cy.contains('Page not found').should('be.visible');73 });...

Full Screen

Full Screen

landing-view.js

Source:landing-view.js Github

copy

Full Screen

1/**2 * @fileoverview Landing's view (MVC pattern), responsible for the view/UI.3 * Landing's controller is the only access into the view.4 * @summary view object for landing screen5 * @author Paul J Stales <https://twitter.com/pauljstales>6 * Copyright (c) 20217 */8import { CONFIGURATION } from "../../configuration/configuration.js";9import { CONSTANTS } from "../../constants/constants.js";10/**11 * Shows the progress bar load, controlled by variable "LANDING.TIME_PER_PROGRESS_BAR_INTERVAL".12 * Once the progress bar is loaded, show the landing screen with options to load the game, see the credits, or select a language.13 */14function loadProgressBar() {15 let processBarPercentage = 0;16 let processBarPercentageInterval = setInterval(() => {17 CONSTANTS.HTML.LANDING.SCREEN_PROGRESS_BAR.value = processBarPercentage;18 processBarPercentage++;19 if (processBarPercentage >= 101) {20 hideLandingScreenPart1();21 showLandingScreenPart2();22 clearInterval(processBarPercentageInterval);23 }24 }, CONFIGURATION.LANDING.TIME_PER_PROGRESS_BAR_INTERVAL);25}26/**27 * Shows both parts of the landing screen28 */29function showLandingScreen() {30 CONSTANTS.HTML.LANDING.SCREEN_LANDING.classList.remove(31 CONSTANTS.CSS.SCREEN_DISPLAY_NONE32 );33 CONSTANTS.HTML.LANDING.SCREEN_LANDING.classList.add(34 CONSTANTS.CSS.SCREEN_DISPLAY_BLOCK35 );36}37/**38 * Hides part 1 of the landing screen, the "progress bar".39 */40function hideLandingScreenPart1() {41 CONSTANTS.HTML.LANDING.SCREEN_LANDING_PART_1.classList.remove(42 CONSTANTS.CSS.SCREEN_DISPLAY_FLEXCOL43 );44 CONSTANTS.HTML.LANDING.SCREEN_LANDING_PART_1.classList.add(45 CONSTANTS.CSS.SCREEN_DISPLAY_NONE46 );47}48/**49 * Shows part 2 of the landing screen.50 * The "start game, see credits, select language" options.51 */52function showLandingScreenPart2() {53 CONSTANTS.HTML.LANDING.SCREEN_LANDING_PART_2.classList.remove(54 CONSTANTS.CSS.SCREEN_DISPLAY_NONE55 );56 CONSTANTS.HTML.LANDING.SCREEN_LANDING_PART_2.classList.add(57 CONSTANTS.CSS.SCREEN_DISPLAY_FLEXCOL58 );59}60/**61 * Hides both parts of the landing screen62 */63function hideLandingScreen() {64 CONSTANTS.HTML.LANDING.SCREEN_LANDING.classList.remove(65 CONSTANTS.CSS.SCREEN_DISPLAY_BLOCK66 );67 CONSTANTS.HTML.LANDING.SCREEN_LANDING.classList.add(68 CONSTANTS.CSS.SCREEN_DISPLAY_NONE69 );70}71/**72 * Exported VIEW object for the landing screen.73 */74const LANDING_VIEW = {75 loadProgressBar: loadProgressBar,76 showLandingScreen: showLandingScreen,77 hideLandingScreen: hideLandingScreen,78};...

Full Screen

Full Screen

LandingComponent.js

Source:LandingComponent.js Github

copy

Full Screen

...10import LandingFooterComponent from "./LandingFooterComponent";11import Toolbar from "@material-ui/core/Toolbar";12import { useDispatch, useSelector } from "react-redux";13import { fetchLandingStats } from "../redux/ActionCreators";14export default function Landing({ language, setLanguage }) {15 const dispatch = useDispatch();16 const landingStats = useSelector((state) => state.landingStats);17 useEffect(() => {18 dispatch(fetchLandingStats());19 }, [dispatch]);20 let dataLandingStats;21 if (landingStats.isLoading) {22 dataLandingStats = (23 <LandingThirdSection categories="···" points="···" users="···" />24 );25 } else if (landingStats.errMess) {26 dataLandingStats = (27 <LandingThirdSection categories="-" points="-" users="-" />28 );...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Landing Page', function() {2 it('should have the right title', function() {3 var title = browser.getTitle();4 expect(title).to.equal('Google');5 });6});7describe('Landing Page', function() {8 it('should have the right title', function() {9 var title = browser.getTitle();10 expect(title).to.equal('Google');11 });12});13describe('Landing Page', function() {14 it('should have the right title', function() {15 var title = browser.getTitle();16 expect(title).to.equal('Google');17 });18});19describe('Landing Page', function() {20 it('should have the right title', function() {21 var title = browser.getTitle();22 expect(title).to.equal('Google');23 });24});25describe('Landing Page', function() {26 it('should have the right title', function() {27 var title = browser.getTitle();28 expect(title).to.equal('Google');29 });30});31describe('Landing Page', function() {32 it('should have the right title', function() {33 var title = browser.getTitle();34 expect(title).to.equal('Google');35 });36});37describe('Landing Page', function() {38 it('should have the right title', function() {39 var title = browser.getTitle();40 expect(title).to.equal('Google');41 });42});43describe('Landing Page', function() {44 it('should have the right title', function() {45 var title = browser.getTitle();46 expect(title).to.equal('Google');47 });48});49describe('Landing Page', function() {50 it('should have the right title',

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Landing Page', function() {2 it('should have the right title', function() {3 var title = browser.getTitle();4 assert.equal(title, 'Google');5 });6});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Landing Page', function() {2 it('should have the right title', function() {3 var title = browser.getTitle();4 expect(title).to.equal('React App');5 });6});7describe('Landing Page', function() {8 it('should have the right title', function() {9 var title = browser.getTitle();10 expect(title).to.equal('React App');11 });12});13describe('Landing Page', function() {14 it('should have the right title', function() {15 var title = browser.getTitle();16 expect(title).to.equal('React App');17 });18});19describe('Landing Page', function() {20 it('should have the right title', function() {21 var title = browser.getTitle();22 expect(title).to.equal('React App');23 });24});25describe('Landing Page', function() {26 it('should have the right title', function() {27 var title = browser.getTitle();28 expect(title).to.equal('React App');29 });30});31describe('Landing Page', function() {32 it('should have the right title', function() {33 var title = browser.getTitle();34 expect(title).to.equal('React App');35 });36});37describe('Landing Page', function() {38 it('should have the right title', function() {39 var title = browser.getTitle();40 expect(title).to.equal('React App');41 });42});43describe('Landing Page', function() {44 it('should have the right title', function() {45 var title = browser.getTitle();46 expect(title).to.equal('React App');47 });48});49describe('

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('supertest');2var app = require('../app.js');3describe('GET /', function() {4 it('should return 200 OK', function(done) {5 request(app)6 .get('/')7 .expect(200, done);8 });9});10var express = require('express');11var app = express();12var routes = require('./routes/index');13var users = require('./routes/users');14app.set('views', path.join(__dirname, 'views'));15app.set('view engine', 'jade');16app.use('/', routes);17app.use('/users', users);18module.exports = app;19var express = require('express');20var router = express.Router();21router.get('/', function(req, res, next) {22 res.render('index', { title: 'Express' });23});24module.exports = router;25var express = require('express');26var router = express.Router();27router.get('/', function(req, res, next) {28 res.send('respond with a resource');29});30module.exports = router;31{32 "scripts": {33 },34 "dependencies": {35 },36 "devDependencies": {37 }38}

Full Screen

Using AI Code Generation

copy

Full Screen

1const assert = require('assert');2const MarioChar = require('../models/mariochar');3describe('Finding records', function(){4 var char;5 beforeEach(function(done){6 char = new MarioChar({7 });8 char.save().then(function(){9 done();10 });11 });12 it('Finds one record from the database', function(done){13 MarioChar.findOne({name: 'Mario'}).then(function(result){14 assert(result.name === 'Mario');15 done();16 });17 });18});19const mongoose = require('mongoose');20const Schema = mongoose.Schema;21const MarioCharSchema = new Schema({22});23const MarioChar = mongoose.model('mariochar', MarioCharSchema);24module.exports = MarioChar;25const assert = require('assert');26const MarioChar = require('../models/mariochar');27describe('Finding records', function(){28 var char;29 var char2;30 beforeEach(function(done){31 char = new MarioChar({32 });33 char2 = new MarioChar({34 });35 char.save().then(function(){36 char2.save().then(function(){37 done();38 });39 });40 });41 it('Finds one record from the database', function(done){42 MarioChar.findOne({name: 'Mario'}).then(function(result){43 assert(result.name === 'Mario');44 done();45 });46 });47 it('Finds one record by ID from the database', function(done){48 MarioChar.findOne({_id: char._id}).then(function(result){49 assert(result._id.toString() === char._id.toString());50 done();51 });52 });53});54const mongoose = require('mongoose');55const Schema = mongoose.Schema;56const MarioCharSchema = new Schema({

Full Screen

Using AI Code Generation

copy

Full Screen

1var Landing = require('../landing.js');2var expect = require('chai').expect;3describe('Landing', function() {4 describe('getLanding', function() {5 it('should return "Landing"', function() {6 var landing = new Landing();7 expect(landing.getLanding()).to.equal('Landing');8 });9 });10});11function Landing() {12 this.getLanding = function() {13 return "Landing";14 };15}16module.exports = Landing;17 1 passing (8ms)

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Landing page', function() {2 it('should have a title', function() {3 expect(browser.getTitle()).toEqual('Angular 2');4 });5});6module.exports = function(config) {7 config.set({

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 Mocha 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