-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(alert): add basic test coverage
- Loading branch information
1 parent
0fed319
commit 6b00045
Showing
4 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
const { createDefaultConfig } = require('@open-wc/testing-karma'); | ||
const merge = require('deepmerge'); | ||
|
||
module.exports = config => { | ||
config.set( | ||
merge(createDefaultConfig(config), { | ||
files: [ | ||
// runs all files ending with .test in the test folder, | ||
// can be overwritten by passing a --grep flag. examples: | ||
// | ||
// npm run test -- --grep test/foo/bar.test.js | ||
// npm run test -- --grep test/bar/* | ||
{ pattern: config.grep ? config.grep : 'test/**/*.test.js', type: 'module' }, | ||
], | ||
|
||
esm: { | ||
nodeResolve: true, | ||
}, | ||
// you can overwrite/extend the config further | ||
}), | ||
); | ||
return config; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { fixture, html, expect, elementUpdated } from '@open-wc/testing'; | ||
import '../awc-alert.js'; | ||
|
||
describe('awc-alert', () => { | ||
const markup = html`<awc-alert title="Test title" message="Test message"></awc-alert>`; | ||
|
||
it('should initialise its markup correctly', async () => { | ||
const el = await fixture(markup); | ||
|
||
await elementUpdated(el); | ||
|
||
expect(el).dom.to.equal(` | ||
<awc-alert | ||
message="Test message" | ||
title="Test title"> | ||
</awc-alert> | ||
`); | ||
}); | ||
|
||
it('has a static shadow-dom', async () => { | ||
const el = await fixture(html` <awc-alert></awc-alert> `); | ||
|
||
expect(el).shadowDom.to.equal(` | ||
<div role="alert"> | ||
<p class="alert__message"> | ||
</p> | ||
</div> | ||
`); | ||
}); | ||
|
||
it('should pass an automated accessibility test', async () => { | ||
const el = await fixture(markup); | ||
|
||
await elementUpdated(el); | ||
|
||
expect(el).to.be.accessible(); | ||
}); | ||
}); |