From 1d892183e42855d7a9398867b62a41cc22fc1b12 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 13 Mar 2019 14:28:51 +0100 Subject: [PATCH 1/3] Add minimal karma setup --- package.json | 12 +++++++++++- test/index.test.js | 14 ++++++++++++++ test/karma.conf.js | 17 +++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/index.test.js create mode 100644 test/karma.conf.js diff --git a/package.json b/package.json index dc366bc..5975702 100644 --- a/package.json +++ b/package.json @@ -14,10 +14,20 @@ "author": "Andreas Hocevar", "license": "BSD-2-Clause", "scripts": { + "karma": "karma start test/karma.conf.js", "lint": "eslint *.js" }, "devDependencies": { "eslint": "^5.15.0", - "eslint-config-openlayers": "^11.0.0" + "eslint-config-openlayers": "^11.0.0", + "karma": "^4.0.1", + "karma-chrome-launcher": "^2.2.0", + "karma-mocha": "^1.3.0", + "karma-webpack": "^3.0.5", + "mocha": "^6.0.2", + "puppeteer": "^1.13.0", + "should": "^13.2.3", + "sinon": "^7.2.7", + "webpack": "^4.29.6" } } diff --git a/test/index.test.js b/test/index.test.js new file mode 100644 index 0000000..f0f85cf --- /dev/null +++ b/test/index.test.js @@ -0,0 +1,14 @@ +import should from 'should'; +import parseFont from '../index'; + +describe('mapbox-to-css-font', function() { + + describe('parseFont', function() { + it('handle font-weight', function() { + should(parseFont('Noto Sans', 16)).eql('normal 400 16px "Noto Sans"'); + should(parseFont('Noto Sans Bold', 16)).eql('normal 700 16px "Noto Sans"'); + should(parseFont('Noto Sans SemiBold Italic', 16)).eql('italic 600 16px "Noto Sans"'); + }); + }); + +}); diff --git a/test/karma.conf.js b/test/karma.conf.js new file mode 100644 index 0000000..7816e71 --- /dev/null +++ b/test/karma.conf.js @@ -0,0 +1,17 @@ +const path = require('path'); + +module.exports = function(karma) { + karma.set({ + frameworks: ['mocha'], + files: [{ + pattern: path.resolve(__dirname, './index.test.js') + }], + preprocessors: { + '**/*.js': ['webpack'] + }, + webpack: { + mode: 'development' + }, + browsers: ['ChromeHeadless'] + }); +}; From 18abbb0dce09a3a9ac23b05be2e919ed5d50d344 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 22 Mar 2019 13:20:57 +0100 Subject: [PATCH 2/3] Add 'pretest' and 'test' scripts in package.json --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 5975702..48fb1f5 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,9 @@ "license": "BSD-2-Clause", "scripts": { "karma": "karma start test/karma.conf.js", - "lint": "eslint *.js" + "lint": "eslint *.js", + "pretest": "npm run lint", + "test": "npm run karma -- --single-run --log-level error" }, "devDependencies": { "eslint": "^5.15.0", From 2fe61660721f1c2d51ac0065b5ba2543d7679914 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 22 Mar 2019 13:22:16 +0100 Subject: [PATCH 3/3] Add circleCI config file --- .circleci/config.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..a5409bb --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,37 @@ +# Javascript Node CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-javascript/ for more details +# +version: 2 +jobs: + build: + docker: + # specify the version you desire here + - image: circleci/node:latest-browsers + + # Specify service dependencies here if necessary + # CircleCI maintains a library of pre-built images + # documented at https://circleci.com/docs/2.0/circleci-images/ + # - image: circleci/mongo:3.4.4 + + working_directory: ~/repo + + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: npm install + + - save_cache: + paths: + - node_modules + key: v1-dependencies-{{ checksum "package.json" }} + + # run tests! + - run: npm test