Skip to content

Commit

Permalink
Merge pull request #12 from snohio/lastlink/jest
Browse files Browse the repository at this point in the history
init jest tests
  • Loading branch information
lastlink authored Mar 23, 2024
2 parents c4ee776 + eb3eeba commit a263038
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ _site/

# Local Netlify folder
.netlify
junit.xml
22 changes: 22 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
globals: {
"ts-jest": {
tsConfig: "tsconfig.json"
}
},
moduleFileExtensions: [
"ts",
"js"
],
transform: {
"^.+\\.(ts|tsx)$": "ts-jest"
},
testMatch: [
"**/tests/**/*.spec.(ts|js)"
],
runner: "jest-serial-runner",
testEnvironment: "node",
reporters: ["default", "jest-junit"],
// collectCoverage: true,
collectCoverageFrom: ["src/**/*.{ts,js}", "!**/node_modules/**"]
};
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,36 @@
"debug": "set DEBUG=* & eleventy",
"css": "postcss src/static/css/tailwind.css --o _site/static/css/style.css --watch",
"build": "cross-env NODE_ENV=production eleventy && cross-env NODE_ENV=production postcss src/static/css/tailwind.css --o _site/static/css/style.css",
"browsersync": "browser-sync start --server \"_site\" --files \"_site\" --port 8080 --no-notify --no-open"
"browsersync": "browser-sync start --server \"_site\" --files \"_site\" --port 8080 --no-notify --no-open",
"test": "jest -c ./jest.config.js --forceExit --verbose -i --no-cache",
"test:coverage": "jest --forceExit --coverage --verbose",
"test:watch": "jest --watchAll"
},
"devDependencies": {
"@11ty/eleventy": "^2.0.1",
"@11ty/eleventy-plugin-syntaxhighlight": "^4.0.0",
"@11ty/eleventy-plugin-webc": "^0.11.2",
"@tailwindcss/typography": "^0.5.1",
"@types/jest": "^29.5.12",
"alpinejs": "^3.12.0",
"autoprefixer": "^10.4.2",
"browser-sync": "^2.27.7",
"cross-env": "^7.0.3",
"cssnano": "^5.0.16",
"html-minifier": "^4.0.0",
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
"jest-serial-runner": "^1.2.1",
"js-yaml": "^4.1.0",
"luxon": "^2.3.0",
"node-fetch": "^2.7.0",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.6",
"postcss-cli": "^9.1.0",
"prismjs": "^1.26.0",
"tailwindcss": "^3.3.2"
"tailwindcss": "^3.3.2",
"ts-jest": "^29.1.2",
"typescript": "^5.4.3"
},
"dependencies": {
"browsersync": "^0.0.1-security",
Expand Down
11 changes: 11 additions & 0 deletions tests/_data/flat_events.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

const events = require('../../src/_data/flat_events') as any[];

describe('flat_events', () => {
it('should return an array of events', () => {
expect(events).toBeInstanceOf(Array)
});



})
11 changes: 11 additions & 0 deletions tests/js/filters.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


const filters = require('../../src/js/filters');


describe('filters', function() {
it('no address return default', async () => {
const r = await filters.geoApify('');
expect(r).toEqual("[0,0]")
});
})
28 changes: 28 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"target": "es5",
"module": "CommonJS",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"importHelpers": true,
"allowJs": true,
"declaration": true,
"outDir": "./lib",
"lib": [
"es2018",
"dom"
],
"strict": true,
"types": [
"jest",
"node"
]
},
"include": [
"src"
],
"exclude": [
"node_modules",
"**/tests/*"
]
}

0 comments on commit a263038

Please sign in to comment.