File tree Expand file tree Collapse file tree 4 files changed +56
-60
lines changed
Expand file tree Collapse file tree 4 files changed +56
-60
lines changed Original file line number Diff line number Diff line change 1+ import { createStorage , expectToHavePrettierButton } from "./testUtils" ;
2+ import GitHub from "./github" ;
3+
4+ test ( "GitHub" , async ( ) => {
5+ // Basis: https://github.com/prettier/prettier-chrome-extension/issues/new
6+ const button = document . createElement ( "button" ) ;
7+ button . innerText = "Comment" ;
8+ document . body . appendChild ( button ) ;
9+ // Hack around JSDOM's lack of offsetHeight support to fix isElementVisible
10+ Object . defineProperty ( document . body , "offsetHeight" , { value : 1 } ) ;
11+
12+ new GitHub ( await createStorage ( ) ) ;
13+ expectToHavePrettierButton ( ) ;
14+ } ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { createStorage , expectToHavePrettierButton } from "./testUtils" ;
2+ import StackOverflow from "./stackOverflow" ;
3+
4+ test ( "Stack Overflow" , async ( ) => {
5+ // Basis: https://stackoverflow.com/questions/51875054
6+ const button = document . createElement ( "div" ) ;
7+ button . className = "wmd-button-row" ;
8+ document . body . appendChild ( button ) ;
9+
10+ new StackOverflow ( await createStorage ( ) ) ;
11+ expectToHavePrettierButton ( ) ;
12+ } ) ;
Original file line number Diff line number Diff line change 1+ import "@testing-library/jest-dom/extend-expect" ;
2+ import Storage from "./storage" ;
3+
4+ window . chrome = {
5+ runtime : { } ,
6+ storage : {
7+ onChanged : {
8+ addListener ( ) { }
9+ } ,
10+ sync : {
11+ get ( callback ) {
12+ setTimeout ( ( ) => callback ( { } ) ) ;
13+ }
14+ }
15+ }
16+ } ;
17+
18+ window . MutationObserver = class {
19+ constructor ( ) { }
20+ observe ( ) { }
21+ } ;
22+
23+ export function createStorage ( ) {
24+ const storage = new Storage ( ) ;
25+ return storage . init ( ) ;
26+ }
27+
28+ export function expectToHavePrettierButton ( ) {
29+ expect ( document . querySelector ( ".prettier-btn" ) ) . toHaveTextContent ( "Prettier" ) ;
30+ }
You can’t perform that action at this time.
0 commit comments