Skip to content

Commit 107e784

Browse files
authored
Merge pull request #2 from fredj/karma
Add minimal karma setup
2 parents b08d69c + 2fe6166 commit 107e784

File tree

4 files changed

+82
-2
lines changed

4 files changed

+82
-2
lines changed

.circleci/config.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
docker:
9+
# specify the version you desire here
10+
- image: circleci/node:latest-browsers
11+
12+
# Specify service dependencies here if necessary
13+
# CircleCI maintains a library of pre-built images
14+
# documented at https://circleci.com/docs/2.0/circleci-images/
15+
# - image: circleci/mongo:3.4.4
16+
17+
working_directory: ~/repo
18+
19+
steps:
20+
- checkout
21+
22+
# Download and cache dependencies
23+
- restore_cache:
24+
keys:
25+
- v1-dependencies-{{ checksum "package.json" }}
26+
# fallback to using the latest cache if no exact match is found
27+
- v1-dependencies-
28+
29+
- run: npm install
30+
31+
- save_cache:
32+
paths:
33+
- node_modules
34+
key: v1-dependencies-{{ checksum "package.json" }}
35+
36+
# run tests!
37+
- run: npm test

package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,22 @@
1414
"author": "Andreas Hocevar",
1515
"license": "BSD-2-Clause",
1616
"scripts": {
17-
"lint": "eslint *.js"
17+
"karma": "karma start test/karma.conf.js",
18+
"lint": "eslint *.js",
19+
"pretest": "npm run lint",
20+
"test": "npm run karma -- --single-run --log-level error"
1821
},
1922
"devDependencies": {
2023
"eslint": "^5.15.0",
21-
"eslint-config-openlayers": "^11.0.0"
24+
"eslint-config-openlayers": "^11.0.0",
25+
"karma": "^4.0.1",
26+
"karma-chrome-launcher": "^2.2.0",
27+
"karma-mocha": "^1.3.0",
28+
"karma-webpack": "^3.0.5",
29+
"mocha": "^6.0.2",
30+
"puppeteer": "^1.13.0",
31+
"should": "^13.2.3",
32+
"sinon": "^7.2.7",
33+
"webpack": "^4.29.6"
2234
}
2335
}

test/index.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import should from 'should';
2+
import parseFont from '../index';
3+
4+
describe('mapbox-to-css-font', function() {
5+
6+
describe('parseFont', function() {
7+
it('handle font-weight', function() {
8+
should(parseFont('Noto Sans', 16)).eql('normal 400 16px "Noto Sans"');
9+
should(parseFont('Noto Sans Bold', 16)).eql('normal 700 16px "Noto Sans"');
10+
should(parseFont('Noto Sans SemiBold Italic', 16)).eql('italic 600 16px "Noto Sans"');
11+
});
12+
});
13+
14+
});

test/karma.conf.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const path = require('path');
2+
3+
module.exports = function(karma) {
4+
karma.set({
5+
frameworks: ['mocha'],
6+
files: [{
7+
pattern: path.resolve(__dirname, './index.test.js')
8+
}],
9+
preprocessors: {
10+
'**/*.js': ['webpack']
11+
},
12+
webpack: {
13+
mode: 'development'
14+
},
15+
browsers: ['ChromeHeadless']
16+
});
17+
};

0 commit comments

Comments
 (0)