This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function decode(score) { | |
const decodedInformation = [ | |
{ name: 'The user has not read the article', value: score & 8 }, | |
{ name: 'The user has tags that match the article tags', value: score & 4 }, | |
{ name: 'The article is flagged important', value: score & 2 } | |
] | |
decodedInformation.forEach(info => { | |
// value is either 0 or the number used with the '&' operator. | |
// we transform it to a boolean, 0 => false, anything else => true. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_index": "useralgo", | |
"_type": "article", | |
"_id": "articleId1", | |
"_score": 1, | |
"_source": { | |
"title": "My thoughts on the last season of Game of Thrones", | |
"tags": [ | |
"GOT", | |
"TVshow" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Suspense, lazy } from 'react' | |
const LazyHeavy = lazy(() => import('./Heavy')) | |
export default function AsyncHeavy() { | |
return ( | |
<div> | |
<Suspense fallback={<div>Loading...</div>}> | |
<LazyHeavy /> | |
</Suspense> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { BrowserRouter as Router, Route, Link } from 'react-router-dom' | |
import Home from './Home' | |
import AsyncHeavy from './AsyncHeavy' | |
function AppRouter() { | |
return ( | |
<Router> | |
<div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { BrowserRouter as Router, Route, Link } from 'react-router-dom' | |
import Home from './Home' | |
import Heavy from './Heavy' | |
function AppRouter() { | |
return ( | |
<Router> | |
<div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import _ from 'lodash' | |
import moment from 'moment' | |
export default function Heavy() { | |
const now = moment().format('YYYY-MM-DD') | |
const textArray = ['The', 'date', 'is'] | |
const text = _.join(textArray, '') | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
export default function Home() { | |
return <div>Home</div> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// module.js | |
const test = 'test' | |
export default test | |
// static.js | |
import test from './test' | |
console.log(test) | |
// dynamic.js | |
import('./test').then(({default: test}) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
after: function(browser) { | |
console.log('I am done.') | |
}, | |
'Demo test': function (browser) { | |
browser | |
.url('https://nightwatch-demo.netlify.com/') | |
.waitForElementVisible('[data-nw=name-input]') | |
.setValue('[data-nw=name-input]', 'Pierre') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
'Demo test': function (browser) { | |
browser | |
.url(browser.launch_url) | |
.waitForElementVisible('[data-nw=name-input]') | |
.setValue('[data-nw=name-input]', 'Pierre') | |
.weirdPause(browser.globals.timeToWait) | |
.assert.containsText('[data-nw=welcome-message]', 'Welcome Pierre !') | |
.end() | |
} |