Skip to content

Commit

Permalink
Merge pull request #15 from deinsoftware/dev
Browse files Browse the repository at this point in the history
add unit testing before publish
  • Loading branch information
equiman authored Feb 27, 2023
2 parents f655f06 + 36ebdfa commit 7621ff9
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ on:
types: [published]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm run test

publish-vsce:
needs: test
if: ${{ success() }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ node_modules
*.vsix
*.log
.DS_Store
.test
!test
test/**
!test/**.test.js
2 changes: 1 addition & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.vscode/**
.gitignore
CHANGELOG.md
.test/**
test/**
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Fixed for any bug fixes.
Security to invite users to upgrade in case of vulnerabilities.
-->

## 3.2.0 - 2023/02/27

### Added

- Unit test before publish task

## 3.1.2 - 2022/12/14

### Fixed
Expand Down
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arrow-function-snippets",
"description": "VS Code Arrow function snippets for JS and TS",
"version": "3.1.2",
"version": "3.2.0",
"displayName": "Arrow Function Snippets",
"publisher": "deinsoftware",
"icon": "images/light-icon.png",
Expand Down Expand Up @@ -165,8 +165,16 @@
}
]
},
"scripts": {
"test": "vitest --run --reporter verbose",
"test:w": "vitest",
"test:ui": "vitest --ui"
},
"volta": {
"node": "18.7.0",
"npm": "8.15.0"
"node": "18.14.2",
"npm": "9.5.0"
},
"devDependencies": {
"vitest": "0.29.1"
}
}
48 changes: 48 additions & 0 deletions test/snippets.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { it, expect, describe } from 'vitest'

const arraysSnippets = require("../snippets/arrays.json")
const arrowSnippets = require("../snippets/arrow.json")
const promiseSnippets = require("../snippets/promise.json")
const functionJsSnippets = require("../snippets/function-js.json")
const functionTsSnippets = require("../snippets/var-ts.json")

const snippets = {
...arraysSnippets,
...arrowSnippets,
...promiseSnippets,
...functionJsSnippets,
...functionTsSnippets,
}

const unique = (xs) => [...new Set(xs)]

describe("snippets.json", () => {
it("has entries", () => {
expect(Object.keys(snippets).length).toBeGreaterThan(0)
})

it("has unique prefixes", () => {
const prefixes = Object.values(snippets).map((x) => x.prefix)
expect(prefixes).toEqual(unique(prefixes))
})

describe.each(Object.keys(snippets))("%s", (k) => {
it("has prefix", () => {
const { prefix } = snippets[k]
expect(prefix).toBeDefined()
expect(prefix).not.toEqual("")
})

it("has body", () => {
const { body } = snippets[k]
expect(body).toBeDefined()
expect(body).not.toEqual("")
})

it("has description", () => {
const { description } = snippets[k]
expect(description).toBeDefined()
expect(description).not.toEqual("")
})
})
})

0 comments on commit 7621ff9

Please sign in to comment.