-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby): invite (1%) of Gatsby users to try out develop ssr (#28139
- Loading branch information
1 parent
04349a0
commit a612f26
Showing
4 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
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
17 changes: 17 additions & 0 deletions
17
packages/gatsby/src/utils/__tests__/__snapshots__/sample-site-for-experiment.ts.snap
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 1`] = `true`; | ||
|
||
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 2`] = `false`; | ||
|
||
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 3`] = `true`; | ||
|
||
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 4`] = `true`; | ||
|
||
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 5`] = `false`; | ||
|
||
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 6`] = `true`; | ||
|
||
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 7`] = `false`; | ||
|
||
exports[`sampleSiteForExperiment returns true or false depending on if they randomly are bucketed in or not 8`] = `false`; |
12 changes: 12 additions & 0 deletions
12
packages/gatsby/src/utils/__tests__/sample-site-for-experiment.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import sampleSiteForExperiment from "../sample-site-for-experiment" | ||
|
||
describe(`sampleSiteForExperiment`, () => { | ||
it(`returns true or false depending on if they randomly are bucketed in or not`, () => { | ||
const experiments = [`a`, `b`, `c`, `d`, `e`, `f`, `h`, `i`] | ||
experiments.forEach(experiment => { | ||
expect(sampleSiteForExperiment(experiment, 0)).toBeFalsy() | ||
expect(sampleSiteForExperiment(experiment, 50)).toMatchSnapshot() | ||
expect(sampleSiteForExperiment(experiment, 100)).toBeTruthy() | ||
}) | ||
}) | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { getRepositoryId } from "gatsby-telemetry/lib/repository-id" | ||
import { murmurhash } from "babel-plugin-remove-graphql-queries" | ||
|
||
const sampleSite = (experimentName: string, percentage: number): boolean => | ||
murmurhash( | ||
experimentName + `` + JSON.stringify(getRepositoryId().repositoryId) | ||
) % | ||
100 < | ||
percentage | ||
|
||
export default sampleSite |