Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Babel, extend compat to node 0.10 #19

Merged
merged 2 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": { "node": "0.10" },
"bugfixes": true,
"spec": true,
"useBuiltIns": false,
"shippedProposals": true
}
]
]
}
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ jobs:
uses: ljharb/actions/.github/workflows/node-majors.yml@main
with:
range: '>= 12'
build-command: npm run build
build-output-dir: lib/
command: npm run tests-only
coverage: coveralls

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.nyc_output/
coverage/
node_modules/
lib/
18 changes: 14 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
},
"license": "MIT",
"scripts": {
"prepublishOnly": "npm run build",
"prebuild": "rimraf lib && mkdirp lib",
"build": "babel src -d lib",
"lint": "eslint --ext=js,mjs .",
"tests-only": "nyc mocha ./test/",
"tests-only": "nyc mocha --recursive test",
"pretest": "npm run lint",
"test": "npm run tests-only"
},
Expand All @@ -34,16 +37,20 @@
"language-subtag-registry": "^0.3.20"
},
"devDependencies": {
"@babel/cli": "^7.22.10",
"@babel/preset-env": "^7.22.10",
"coveralls": "^3.1.1",
"eslint": "^8.47.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0"
"mkdirp": "^0.5.6",
"mocha": "^3.5.3",
"nyc": "^10.3.2",
"rimraf": "^2.7.1"
},
"files": [
"/lib"
],
"engines": {
"node": ">=12"
"node": ">=0.10"
},
"eslintConfig": {
"parserOptions": {
Expand All @@ -53,6 +60,9 @@
"env": {
"node": true
},
"ignorePatterns": [
"!.babelrc.js"
],
"overrides": [
{
"files": "test/**",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 10 additions & 11 deletions test/lib/SubtagTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@
var assert = require('assert');
var Subtag = require('../../lib/Subtag');

suite('Subtag', function() {

test('subtag.type() returns type', function() {
describe('Subtag', function () {
it('subtag.type() returns type', function() {
assert.equal(new Subtag('zh', 'language').type(), 'language');
assert.equal(new Subtag('IQ', 'region').type(), 'region');
});

test('subtag.descriptions() returns descriptions', function() {
it('subtag.descriptions() returns descriptions', function() {
assert.deepEqual(new Subtag('IQ', 'region').descriptions(), ['Iraq']);
assert.deepEqual(new Subtag('vsv', 'extlang').descriptions(), ['Valencian Sign Language', 'Llengua de signes valenciana']);
});

test('subtag.preferred() returns preferred subtag', function() {
it('subtag.preferred() returns preferred subtag', function() {
var subtag, preferred;

// Extlang
Expand Down Expand Up @@ -60,7 +59,7 @@ suite('Subtag', function() {
assert.equal(subtag.preferred(), null);
});

test('subtag.script() returns suppress-script as subtag', function() {
it('subtag.script() returns suppress-script as subtag', function() {
var subtag, script;

subtag = new Subtag('en', 'language');
Expand All @@ -76,32 +75,32 @@ suite('Subtag', function() {
assert.equal(script, null);
});

test('subtag.scope() returns scope', function() {
it('subtag.scope() returns scope', function() {
assert.equal(new Subtag('zh', 'language').scope(), 'macrolanguage');
assert.equal(new Subtag('nah', 'language').scope(), 'collection');
assert.equal(new Subtag('en', 'language').scope(), null);
assert.equal(new Subtag('IQ', 'region').scope(), null);
});

test('subtag.deprecated() returns deprecation date if available', function() {
it('subtag.deprecated() returns deprecation date if available', function() {

// German Democratic Republic
assert.equal(new Subtag('DD', 'region').deprecated(), '1990-10-30');
assert.equal(new Subtag('DE', 'region').deprecated(), null);
});

test('subtag.added() returns date added', function() {
it('subtag.added() returns date added', function() {
assert.equal(new Subtag('DD', 'region').added(), '2005-10-16');
assert.equal(new Subtag('DG', 'region').added(), '2009-07-29');
});

test('subtag.comments() returns comments', function() {
it('subtag.comments() returns comments', function() {

// Yugoslavia
assert.deepEqual(new Subtag('YU', 'region').comments(), ['see BA, HR, ME, MK, RS, or SI']);
});

test('subtag.format() formats subtag according to conventions', function() {
it('subtag.format() formats subtag according to conventions', function() {

// Language
assert.equal(new Subtag('en', 'language').format(), 'en');
Expand Down
Loading