Skip to content

Commit

Permalink
fix: use entity data for dist/
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed May 14, 2019
1 parent b09f4d2 commit f6c6159
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bin/build-entity-json-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function cleanStatsFromEntity(entity) {
const sourceEntities = JSON5.parse(fs.readFileSync(`${DATA_DIR}/entities.json5`, 'utf8'))
fs.writeFileSync(`${DIST_DIR}/entities.json`, JSON.stringify(sourceEntities))

const httpArchiveData = require('../data/2019-03-01-origin-scripting.json')
const httpArchiveData = require('../data/2019-04-01-entity-scripting.json')
const {getEntity} = require('../lib/index.js') // IMPORTANT: require this after entities have been written
const entityExecutionStats = _(httpArchiveData)
.groupBy(({origin}) => {
Expand Down Expand Up @@ -47,5 +47,5 @@ fs.writeFileSync(`${DIST_DIR}/entities.json`, JSON.stringify(sourceEntities))
fs.writeFileSync(`${DIST_DIR}/entities-httparchive.json`, JSON.stringify(entitiesInHTTPArchive))
fs.writeFileSync(
`${DIST_DIR}/entities-httparchive-nostats.json`,
JSON.stringify(entitiesInHTTPArchive.map(e => cleanStatsFromEntity(e))),
JSON.stringify(entitiesInHTTPArchive.map(e => cleanStatsFromEntity(e)))
)
12 changes: 6 additions & 6 deletions lib/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('getEntity', () => {
it('works for direct domain usage', () => {
expect(getEntity('https://js.connect.facebook.net/lib.js')).toMatchInlineSnapshot(`
Object {
"averageExecutionTime": 119.80635511714381,
"averageExecutionTime": 142.3708560765058,
"categories": Array [
"social",
],
Expand Down Expand Up @@ -54,16 +54,16 @@ Object {
],
"homepage": "https://www.facebook.com",
"name": "Facebook",
"totalExecutionTime": 132167256,
"totalOccurrences": 1103174,
"totalExecutionTime": 144421993,
"totalOccurrences": 1014407,
}
`)
})

it('works for inferred domain usage', () => {
expect(getEntity('https://unknown.typekit.net/fonts.css')).toMatchInlineSnapshot(`
Object {
"averageExecutionTime": 95.1277705345502,
"averageExecutionTime": 91.7116918051686,
"categories": Array [
"library",
],
Expand All @@ -75,8 +75,8 @@ Object {
],
"homepage": "https://fonts.adobe.com/",
"name": "Adobe TypeKit",
"totalExecutionTime": 656667,
"totalOccurrences": 6903,
"totalExecutionTime": 954627,
"totalOccurrences": 10409,
}
`)
})
Expand Down

0 comments on commit f6c6159

Please sign in to comment.