File tree Expand file tree Collapse file tree 3 files changed +210
-0
lines changed
Expand file tree Collapse file tree 3 files changed +210
-0
lines changed Original file line number Diff line number Diff line change 1+ var localStorageMock = ( function ( ) {
2+ var store = { } ;
3+ return {
4+ getItem : function ( key ) {
5+ return store [ key ] ;
6+ } ,
7+ setItem : function ( key , value ) {
8+ store [ key ] = value . toString ( ) ;
9+ } ,
10+ clear : function ( ) {
11+ store = { } ;
12+ } ,
13+ removeItem : function ( key ) {
14+ delete store [ key ] ;
15+ }
16+ } ;
17+ } ) ( ) ;
18+ Object . defineProperty ( window , 'localStorage' , {
19+ value : localStorageMock
20+ } ) ;
Original file line number Diff line number Diff line change 1+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+ exports [` <NavBar /> Unit Tests renders correctly 1` ] = `
4+ <div >
5+ <div
6+ class = " pusher"
7+ >
8+ <div
9+ class = " ui menu asd borderless"
10+ >
11+ <a
12+ class = " item openbtn"
13+ href = " #!"
14+ onClick = { [Function ]}
15+ >
16+ <i
17+ class = " icon content"
18+ />
19+ </a >
20+ <img
21+ alt = " Nodecloud logo"
22+ class = " nav-logo"
23+ onClick = { [Function ]}
24+ src = " ../media/nodecloudlogo.png"
25+ />
26+ <a
27+ class = " item"
28+ href = " #!"
29+ onClick = { [Function ]}
30+ >
31+
32+ Node Cloud
33+ </a >
34+ <div
35+ class = " right menu"
36+ >
37+ <div
38+ aria-expanded = { false }
39+ className = " ui inline dropdown"
40+ onBlur = { [Function ]}
41+ onChange = { [Function ]}
42+ onClick = { [Function ]}
43+ onFocus = { [Function ]}
44+ onMouseDown = { [Function ]}
45+ role = " listbox"
46+ style = {
47+ Object {
48+ " padding" : 12 ,
49+ }
50+ }
51+ tabIndex = { 0 }
52+ >
53+ <div
54+ aria-atomic = { true }
55+ aria-live = " polite"
56+ className = " default text"
57+ role = " alert"
58+ >
59+ Select Provider
60+ </div >
61+ <i
62+ aria-hidden = " true"
63+ className = " dropdown icon"
64+ onClick = { [Function ]}
65+ />
66+ <div
67+ className = " menu transition"
68+ >
69+ <div
70+ aria-checked = { false }
71+ aria-selected = { true }
72+ className = " selected item"
73+ onClick = { [Function ]}
74+ role = " option"
75+ style = {
76+ Object {
77+ " pointerEvents" : " all" ,
78+ }
79+ }
80+ >
81+ <img
82+ className = " ui avatar image"
83+ src = " ../media/aws.png"
84+ />
85+ <span
86+ className = " text"
87+ >
88+ Amazon Web Services
89+ </span >
90+ </div >
91+ <div
92+ aria-checked = { false }
93+ aria-selected = { false }
94+ className = " item"
95+ onClick = { [Function ]}
96+ role = " option"
97+ style = {
98+ Object {
99+ " pointerEvents" : " all" ,
100+ }
101+ }
102+ >
103+ <img
104+ className = " ui avatar image"
105+ src = " ../media/azure.png"
106+ />
107+ <span
108+ className = " text"
109+ >
110+ Azure
111+ </span >
112+ </div >
113+ <div
114+ aria-checked = { false }
115+ aria-selected = { false }
116+ className = " item"
117+ onClick = { [Function ]}
118+ role = " option"
119+ style = {
120+ Object {
121+ " pointerEvents" : " all" ,
122+ }
123+ }
124+ >
125+ <img
126+ className = " ui avatar image"
127+ src = " ../media/gcp.png"
128+ />
129+ <span
130+ className = " text"
131+ >
132+ Google Cloud Platform
133+ </span >
134+ </div >
135+ </div >
136+ </div >
137+ <div
138+ class = " ui dropdown item"
139+ >
140+ test
141+
142+ <i
143+ class = " dropdown icon"
144+ />
145+ <div
146+ class = " menu"
147+ >
148+ <a
149+ class = " item"
150+ href = " #!"
151+ >
152+ Help
153+ </a >
154+ <a
155+ class = " item"
156+ href = " #!"
157+ >
158+ Logout
159+ </a >
160+ </div >
161+ </div >
162+ <div
163+ class = " item"
164+ />
165+ </div >
166+ </div >
167+ </div >
168+ </div >
169+ ` ;
Original file line number Diff line number Diff line change 1+ import TestRenderer from "react-test-renderer" ;
2+ import SideBar from "../src/_components/NavBar" ;
3+ import React from "react" ;
4+
5+ describe ( "<NavBar /> Unit Tests" , ( ) => {
6+ it ( "renders correctly" , ( ) => {
7+ var testFunction = jest . fn ( ) ;
8+ const testUser = {
9+ username : 'test'
10+ }
11+ const testUserString = JSON . stringify ( testUser ) ;
12+ localStorage . setItem ( 'user' , testUserString ) ;
13+ var component = TestRenderer . create ( <
14+ SideBar handleShowSidebar = {
15+ testFunction
16+ }
17+ />
18+ ) ;
19+ expect ( component ) . toMatchSnapshot ( ) ;
20+ } ) ;
21+ } ) ;
You can’t perform that action at this time.
0 commit comments