forked from mdn/browser-compat-data
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move build scripts into its own folder; add unittests (mdn#21638)
* Move build scripts into its own folder; add unittests * Apply suggestions from code review Co-authored-by: Florian Scholz <[email protected]> --------- Co-authored-by: Florian Scholz <[email protected]>
- Loading branch information
1 parent
c95c9bc
commit cf69a62
Showing
10 changed files
with
139 additions
and
13 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
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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
*.json | ||
!/*.json | ||
!/schemas/*.json | ||
!/scripts/build/ | ||
|
||
LICENSE | ||
.*ignore | ||
.editorconfig | ||
/package-lock.json | ||
/CODE_OF_CONDUCT.md | ||
build/ | ||
/build/ | ||
coverage/ | ||
.features.json | ||
types.d.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
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,116 @@ | ||
/* This file is a part of @mdn/browser-compat-data | ||
* See LICENSE file for more information. */ | ||
|
||
import assert from 'node:assert/strict'; | ||
|
||
import { walk } from '../../utils/index.js'; | ||
|
||
import { | ||
generateMeta, | ||
applyMirroring, | ||
addVersionLast, | ||
createManifest, | ||
} from './index.js'; | ||
|
||
describe('Build functions', () => { | ||
it('generateMeta', () => { | ||
const result = generateMeta(); | ||
assert.ok(result.version); | ||
assert.ok(result.timestamp instanceof Date); | ||
}); | ||
|
||
it('applyMirroring', () => { | ||
const data: any = { | ||
feature: { | ||
__compat: { | ||
support: { | ||
chrome: { | ||
version_added: '90', | ||
}, | ||
edge: 'mirror', | ||
firefox: { | ||
version_added: '40', | ||
}, | ||
ie: { | ||
version_added: false, | ||
}, | ||
opera: 'mirror', | ||
safari: { | ||
version_added: '10', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const walker = walk(undefined, data); | ||
for (const feature of walker) { | ||
applyMirroring(feature); | ||
} | ||
|
||
assert.equal(data.feature.__compat.support.edge.version_added, '90'); | ||
assert.equal(data.feature.__compat.support.opera.version_added, '76'); | ||
}); | ||
|
||
it('addVersionLast', () => { | ||
const data: any = { | ||
feature: { | ||
__compat: { | ||
support: { | ||
chrome: { | ||
version_added: '10', | ||
version_removed: '20', | ||
}, | ||
firefox: [ | ||
{ | ||
version_added: '18', | ||
}, | ||
{ | ||
version_added: '1', | ||
version_removed: '4', | ||
}, | ||
], | ||
safari: { | ||
version_added: '10', | ||
version_removed: 'preview', | ||
version_last: 'preview', | ||
}, | ||
edge: { | ||
version_added: '12', | ||
version_removed: true, | ||
version_last: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const walker = walk(undefined, data); | ||
for (const feature of walker) { | ||
addVersionLast(feature); | ||
} | ||
|
||
assert.equal(data.feature.__compat.support.chrome.version_last, '19'); | ||
assert.equal( | ||
data.feature.__compat.support.firefox[0].version_last, | ||
undefined, | ||
); | ||
assert.equal(data.feature.__compat.support.firefox[1].version_last, '3.6'); | ||
assert.equal(data.feature.__compat.support.safari.version_last, 'preview'); | ||
assert.equal(data.feature.__compat.support.edge.version_last, true); | ||
}); | ||
it('createManifest', () => { | ||
const manifest = createManifest(); | ||
assert.ok(manifest.main); | ||
assert.ok(manifest.exports); | ||
assert.ok(manifest.types); | ||
assert.ok(manifest.name); | ||
assert.ok(manifest.description); | ||
assert.ok(manifest.repository); | ||
assert.ok(manifest.keywords); | ||
assert.ok(manifest.author); | ||
assert.ok(manifest.license); | ||
assert.ok(manifest.bugs); | ||
assert.ok(manifest.homepage); | ||
}); | ||
}); |
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
File renamed without changes.
File renamed without changes.
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
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
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