Skip to content

Commit

Permalink
chore: add mocha test suite (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Dec 6, 2021
1 parent 2c7b840 commit 6312fa2
Show file tree
Hide file tree
Showing 5 changed files with 316 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: yarn lint

- name: Test
run: yarn dev
run: yarn test

# - name: Coverage
# uses: codecov/codecov-action@v1
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@
],
"scripts": {
"build": "siroc build",
"dev": "jiti test/test.ts",
"lint": "eslint --ext .js,.ts .",
"prepack": "yarn build",
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint"
"test": "mocha -r jiti/register ./test/**/*.test.ts"
},
"dependencies": {
"recast": "^0.20.4"
},
"devDependencies": {
"@nuxtjs/eslint-config-typescript": "latest",
"@types/chai": "^4.2.22",
"@types/mocha": "^9.0.0",
"chai": "^4.3.4",
"eslint": "latest",
"jiti": "latest",
"mocha": "^9.1.3",
"siroc": "latest",
"standard-version": "latest"
}
Expand Down
27 changes: 27 additions & 0 deletions test/ast.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { expect } from 'chai'
import { parse, proxifyAST, generate } from '../src'

describe('proxyAST', () => {
it('should produce correct code', () => {
const ast = proxifyAST(
parse(`
export const a = {}
export default {
// This is foo
foo: ['a']
}`)
)

ast.exports.default.props.foo.push('b')

// eslint-disable-next-line no-console
expect(generate(ast).code).to.equal(
`
export const a = {}
export default {
// This is foo
foo: ['a', "b"]
}`
)
})
})
13 changes: 0 additions & 13 deletions test/test.ts

This file was deleted.

0 comments on commit 6312fa2

Please sign in to comment.