How to use fetchComparison method in Best

Best JavaScript code snippet using best

metrics.test.js

Source:metrics.test.js Github

copy

Full Screen

...181 t.is(latest.id, t.context.snapshot.id);182 t.is(latest.userId, t.context.user.id);183 await snapshot.destroy();184});185test.serial('fetchComparison() returns comparison of week apart snapshots', async t => {186 const STAR_DIFFERENCE = 3;187 const FORK_DIFFERENCE = 10;188 const VIEW_DIFFERENCE = 6;189 const CLONE_DIFFERENCE = 2;190 const [snapshot] = await userSnapshots(t.context.user.id);191 const alteredSnapshot = _.cloneDeep(snapshot);192 alteredSnapshot.metrics.map(repo => {193 repo.stars -= STAR_DIFFERENCE;194 repo.forks -= FORK_DIFFERENCE;195 repo.views -= VIEW_DIFFERENCE;196 repo.clones -= CLONE_DIFFERENCE;197 return repo;198 });199 const previousSnapshot = await createSnapshot(200 {201 metrics: alteredSnapshot.metrics,202 userId: t.context.user.id,203 createdAt: moment().subtract(WEEK_IN_DAYS, 'days'),204 },205 {206 returning: true,207 },208 );209 const comparison = await fetchComparison(t.context.user.id);210 const expectedRepoNames = REPOS211 .filter(repo => repo.selected)212 .map(repo => repo.name);213 const actualRepoNames = comparison.map(repo => repo.name);214 t.deepEqual(actualRepoNames, expectedRepoNames);215 t.true(comparison.length > 0);216 comparison.forEach(repo => t.deepEqual(Object.keys(repo), REPO_KEYS));217 comparison.forEach(repo => {218 t.deepEqual(Object.keys(repo), REPO_KEYS);219 Object.keys(repo).filter(key => key !== 'name').forEach(key => {220 t.deepEqual(Object.keys(repo[key]), COMPARISON_KEYS);221 });222 });223 t.true(comparison.every(repo => repo.stars.difference === STAR_DIFFERENCE));224 t.true(comparison.every(repo => repo.forks.difference === FORK_DIFFERENCE));225 t.true(comparison.every(repo => repo.views.difference === VIEW_DIFFERENCE));226 t.true(comparison.every(repo => repo.clones.difference === CLONE_DIFFERENCE));227 await previousSnapshot.destroy();228});229test.serial('fetchComparison() returns comparison based on selected metric types', async t => {230 const [snapshot] = await userSnapshots(t.context.user.id);231 const previousSnapshot = await createSnapshot(232 {233 metrics: snapshot.metrics,234 userId: t.context.user.id,235 createdAt: moment().subtract(WEEK_IN_DAYS, 'days'),236 },237 {238 returning: true,239 },240 );241 const UNSELECTED_METRIC_TYPES = new Set(['views', 'forks']);242 const ALTERED_METRIC_TYPES = _.cloneDeep(METRIC_TYPES).map(metricType => {243 if (UNSELECTED_METRIC_TYPES.has(metricType.name)) {244 metricType.selected = false;245 }246 return metricType;247 });248 await setUserMetricTypes(t.context.user, ALTERED_METRIC_TYPES);249 const comparison = await fetchComparison(t.context.user.id);250 t.true(comparison.length > 0);251 const actualRepoNames = comparison.map(repo => repo.name);252 const expectedRepoNames = REPOS253 .filter(repo => repo.selected)254 .map(repo => repo.name);255 t.deepEqual(actualRepoNames, expectedRepoNames);256 const EXPECTED_REPO_KEYS = REPO_KEYS.filter(key => !UNSELECTED_METRIC_TYPES.has(key));257 comparison.forEach(repo => t.deepEqual(Object.keys(repo), EXPECTED_REPO_KEYS));258 comparison.forEach(repo => {259 t.deepEqual(Object.keys(repo), EXPECTED_REPO_KEYS);260 Object.keys(repo).filter(key => key !== 'name').forEach(key => {261 t.deepEqual(Object.keys(repo[key]), COMPARISON_KEYS);262 });263 });264 await previousSnapshot.destroy();265});266test.serial('fetchComparison() returns null without sufficient snapshots', async t => {267 const comparison = await fetchComparison(t.context.user.id);268 t.is(comparison, null);...

Full Screen

Full Screen

queues.test.js

Source:queues.test.js Github

copy

Full Screen

...34 sinon.assert.calledWith(ingest, user.id);35 t.deepEqual(jobResult, SNAPSHOT);36 ingest.restore();37});38test.serial('sendEmailWorker calls metrics.fetchComparison() and email.send()', async t => {39 const fetchComparison = sinon.stub(metrics, 'fetchComparison');40 fetchComparison.returns(Promise.resolve(WEEKLY_METRICS));41 const send = sinon.stub(email, 'send');42 send.returns(Promise.resolve(SENDGRID_SUCCESS));43 const jobResult = await sendEmailWorker(job);44 t.true(fetchComparison.calledOnce);45 t.true(send.calledOnce);46 sinon.assert.calledWith(fetchComparison, user.id);47 sinon.assert.calledWith(send, {48 user,49 metrics: WEEKLY_METRICS,50 date: moment().format('LL'),51 });52 t.deepEqual(jobResult, SENDGRID_SUCCESS);...

Full Screen

Full Screen

ComparisonResult.js

Source:ComparisonResult.js Github

copy

Full Screen

...30 if (this.timer) {31 clearTimeout(this.timer);32 }33 }34 fetchComparison() {35 this.props.getComparison(this.props.research.comparisonID);36 }37 formatTime(time) {38 if (time > 9) {39 return _.toString(time);40 }41 return `0${time}`;42 }43 renderProgress() {44 const {comparison} = this.props;45 if (comparison.finished || !comparison.total) {46 return null;47 }48 const percentage = Math.min(100 * _.round(comparison.processed / comparison.total, 2), 100);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var bb = require('./bestbuy');2var b = new bb.BestBuy();3b.fetchComparison('Toshiba Satellite', 'Samsung Series 9', function(result) {4 console.log(result);5});6{ product1: 'Toshiba Satellite',7 product2SalePrice: 1299.99 }

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