Skip to content

Commit

Permalink
chore: update to jest 27 (#147)
Browse files Browse the repository at this point in the history
* chore: update to jest 27

* fix: lint

* chore: update @testing-library/dom too

* test: relax coverage test

* test: fix coverage
  • Loading branch information
nolanlawson authored Jun 26, 2021
1 parent fe47d65 commit 17ff749
Show file tree
Hide file tree
Showing 7 changed files with 952 additions and 928 deletions.
2 changes: 1 addition & 1 deletion config/babelJestTransform.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const babelJest = require('babel-jest')
const babelJest = require('babel-jest').default

module.exports = babelJest.createTransformer({
presets: [
Expand Down
3 changes: 2 additions & 1 deletion jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
testEnvironment: 'jsdom',
testMatch: [
'<rootDir>/test/spec/**/*.{spec,test}.{js,jsx,ts,tsx}'
],
Expand Down Expand Up @@ -36,7 +37,7 @@ module.exports = {
},
'./src/picker/components/Picker/Picker.svelte': {
statements: 98,
branches: 96,
branches: 95,
functions: 100,
lines: 100
}
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-replace": "^2.3.4",
"@rollup/plugin-strip": "^2.0.1",
"@testing-library/dom": "^7.29.0",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/user-event": "^12.6.0",
"babel-jest": "^26.6.3",
"@testing-library/dom": "^8.0.0",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/user-event": "^13.1.9",
"babel-jest": "^27.0.5",
"blob-util": "^2.0.2",
"bundlesize": "^0.18.1",
"compression": "^1.7.4",
Expand All @@ -93,7 +93,7 @@
"focus-visible": "^5.2.0",
"get-folder-size": "^2.0.1",
"husky": "^4.3.6",
"jest": "^26.6.3",
"jest": "^27.0.5",
"lint-staged": "^10.5.3",
"lodash-es": "^4.17.15",
"markdown-table": "^2.0.0",
Expand Down
4 changes: 4 additions & 0 deletions src/database/Database.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,16 @@ export default class Database {
}

async close () {
// TODO: this else never gets hit in tests
/* istanbul ignore else */
if (await this._shutdown()) {
await closeDatabase(this._dbName)
}
}

async delete () {
// TODO: this else never gets hit in tests
/* istanbul ignore else */
if (await this._shutdown()) {
await deleteDatabase(this._dbName)
}
Expand Down
9 changes: 9 additions & 0 deletions test/spec/picker/dataSource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('dataSource test', () => {
mockDataSourceWithNoShortcodes()
const dataSource = NO_SHORTCODES
const picker = new Picker({ dataSource, locale: 'en-no-shortcodes' })
document.body.appendChild(picker)
const container = picker.shadowRoot.querySelector('.picker')
await tick(20)

Expand All @@ -26,12 +27,15 @@ describe('dataSource test', () => {

await picker.database.delete()
await tick(20)
document.body.removeChild(picker)
await tick(20)
})

test('emoji with emojibase v5 data source still work', async () => {
mockEmojibaseV5DataSource()
const dataSource = EMOJIBASE_V5
const picker = new Picker({ dataSource, locale: 'en-emojibase' })
document.body.appendChild(picker)
const container = picker.shadowRoot.querySelector('.picker')
await tick(20)

Expand All @@ -43,13 +47,16 @@ describe('dataSource test', () => {

await picker.database.delete()
await tick(20)
document.body.removeChild(picker)
await tick(20)
})

test('emoji with array skin tones work', async () => {
mockDataSourceWithArraySkinTones()

const dataSource = WITH_ARRAY_SKIN_TONES
const picker = new Picker({ dataSource, locale: 'en-arrayskintones' })
document.body.appendChild(picker)
const container = picker.shadowRoot.querySelector('.picker')
await tick(20)

Expand All @@ -66,5 +73,7 @@ describe('dataSource test', () => {

await picker.database.delete()
await tick(20)
document.body.removeChild(picker)
await tick(20)
})
})
3 changes: 3 additions & 0 deletions test/spec/picker/element.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@ describe('element tests', () => {

test('has a default locale/dataSource', async () => {
const picker = new Picker()
document.body.appendChild(picker)
const container = picker.shadowRoot.querySelector('.picker')
await tick(20)

await waitFor(() => expect(getByRole(container, 'menuitem', { name: /😀/ })).toBeVisible())

await new Database().delete()
await tick(20)
await document.body.removeChild(picker)
await tick(20)
})
})
})
Loading

0 comments on commit 17ff749

Please sign in to comment.