-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndex.html
More file actions
229 lines (201 loc) · 12.9 KB
/
Index.html
File metadata and controls
229 lines (201 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jsert | Lightweight JS Unit Testing</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
rel="stylesheet">
<style>
body {
font-family: 'DM Sans', sans-serif;
}
/* Custom scrollbar for dark code blocks */
.code-block::-webkit-scrollbar {
height: 8px;
}
.code-block::-webkit-scrollbar-track {
background: #1e293b;
border-radius: 10px;
}
.code-block::-webkit-scrollbar-thumb {
background: #475569;
border-radius: 10px;
}
.syntax-keyword {
color: #f472b6;
}
.syntax-func {
color: #38bdf8;
}
.syntax-string {
color: #4ade80;
}
.syntax-comment {
color: #94a3b8;
}
</style>
</head>
<body class="bg-slate-50 text-slate-900 scroll-smooth">
<nav class="sticky top-0 z-50 bg-white/80 backdrop-blur-md border-b border-slate-200">
<div class="max-w-6xl mx-auto px-6 h-16 flex items-center justify-between">
<div class="flex items-center gap-2">
<div class="w-8 h-8 bg-indigo-600 rounded flex items-center justify-center text-white font-bold">J</div>
<span class="text-xl font-bold tracking-tight">Jsert</span>
</div>
<a href="https://github.com/Staviro/jsert/" target="_blank"
class="bg-slate-900 text-white px-5 py-2 rounded-lg text-sm font-medium hover:bg-indigo-600 transition-colors">
GitHub
</a>
</div>
</nav>
<header class="py-20 px-6 text-center">
<div class="max-w-4xl mx-auto">
<h1 class="text-5xl md:text-6xl font-extrabold mb-6 tracking-tight text-slate-900">
Unit testing, <span class="text-indigo-600">simplified.</span>
</h1>
<p class="text-xl text-slate-600 max-w-2xl mx-auto leading-relaxed">
A lightweight JavaScript library designed for quick and easy testing on both the client side and
Node.js.
</p>
</div>
</header>
<section class="max-w-3xl mx-auto px-6 mb-20">
<div class="bg-indigo-50 border border-indigo-100 rounded-2xl p-4 flex items-center justify-center gap-3">
<span class="flex h-2 w-2 rounded-full bg-indigo-500 animate-pulse"></span>
<p class="text-indigo-900 font-medium text-sm">
Current Version: <span class="font-bold">Beta</span>. We're actively polishing the API.
</p>
</div>
</section>
<main id="docs" class="max-w-5xl mx-auto px-6 pb-24">
<div class="mb-12">
<h2 class="text-3xl font-bold mb-4">Documentation</h2>
<p class="text-slate-600 text-lg">
Explore the assertion methods below. Every method is designed to be intuitive and provide immediate
feedback in your target environment.
</p>
</div>
<div class="space-y-10">
<div class="bg-white border border-slate-200 rounded-3xl p-8 shadow-sm">
<h3 class="text-xl font-bold mb-3 text-indigo-600">passWhen(test, condition)</h3>
<p class="text-slate-600 mb-6">Passes if the provided condition is strictly true.</p>
<div class="code-block bg-slate-900 rounded-xl p-6 overflow-x-auto">
<pre class="text-sm font-mono text-slate-300"><code><span class="syntax-keyword">const</span> jsert = <span class="syntax-keyword">new</span> <span class="syntax-func">Jsert</span>({ group: <span class="syntax-string">"Math Tests"</span> });
jsert.<span class="syntax-func">test</span>(<span class="syntax-string">"Addition check"</span>, <span class="syntax-keyword">function</span>() {
jsert.<span class="syntax-func">passWhen</span>(<span class="syntax-keyword">this</span>, <span class="syntax-string">1 + 1 === 2</span>);
});</code></pre>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-3xl p-8 shadow-sm">
<h3 class="text-xl font-bold mb-3 text-indigo-600">passWhenWithoutStrict(test, condition)</h3>
<p class="text-slate-600 mb-6">Evaluates truthiness using non-strict comparison.</p>
<div class="code-block bg-slate-900 rounded-xl p-6 overflow-x-auto">
<pre class="text-sm font-mono text-slate-300"><code>jsert.<span class="syntax-func">test</span>(<span class="syntax-string">"Loose check"</span>, <span class="syntax-keyword">function</span>() {
jsert.<span class="syntax-func">passWhenWithoutStrict</span>(<span class="syntax-keyword">this</span>, <span class="syntax-string">"1" == 1</span>);
});</code></pre>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-3xl p-8 shadow-sm">
<h3 class="text-xl font-bold mb-3 text-indigo-600">passWhenEquals(test, actual, expected)</h3>
<p class="text-slate-600 mb-6">Performs a strict equality check (===).</p>
<div class="code-block bg-slate-900 rounded-xl p-6 overflow-x-auto">
<pre class="text-sm font-mono text-slate-300"><code>jsert.<span class="syntax-func">test</span>(<span class="syntax-string">"String check"</span>, <span class="syntax-keyword">function</span>() {
<span class="syntax-keyword">let</span> name = <span class="syntax-string">"John"</span>;
jsert.<span class="syntax-func">passWhenEquals</span>(<span class="syntax-keyword">this</span>, <span class="syntax-keyword">typeof</span> name, <span class="syntax-string">"string"</span>);
});</code></pre>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-3xl p-8 shadow-sm">
<h3 class="text-xl font-bold mb-3 text-indigo-600">passWhenNotEquals(test, actual, unexpected)</h3>
<p class="text-slate-600 mb-6">Ensures the actual value does not match the unexpected value.</p>
<div class="code-block bg-slate-900 rounded-xl p-6 overflow-x-auto">
<pre class="text-sm font-mono text-slate-300"><code>jsert.<span class="syntax-func">test</span>(<span class="syntax-string">"Inequality check"</span>, <span class="syntax-keyword">function</span>() {
jsert.<span class="syntax-func">passWhenNotEquals</span>(<span class="syntax-keyword">this</span>, <span class="syntax-string">10</span>, <span class="syntax-string">20</span>);
});</code></pre>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-3xl p-8 shadow-sm">
<h3 class="text-xl font-bold mb-3 text-indigo-600">passWhenTruthy / passWhenFalsy</h3>
<p class="text-slate-600 mb-6">Validates if a value is truthy or falsy.</p>
<div class="code-block bg-slate-900 rounded-xl p-6 overflow-x-auto">
<pre
class="text-sm font-mono text-slate-300"><code>jsert.<span class="syntax-func">passWhenTruthy</span>(<span class="syntax-keyword">this</span>, <span class="syntax-string">"Content exists"</span>);
jsert.<span class="syntax-func">passWhenFalsy</span>(<span class="syntax-keyword">this</span>, <span class="syntax-string">0</span>);</code></pre>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-3xl p-8 shadow-sm">
<h3 class="text-xl font-bold mb-3 text-indigo-600">passWhenNull / passWhenNotNull</h3>
<p class="text-slate-600 mb-6">Specific checks for null values.</p>
<div class="code-block bg-slate-900 rounded-xl p-6 overflow-x-auto">
<pre
class="text-sm font-mono text-slate-300"><code>jsert.<span class="syntax-func">passWhenNull</span>(<span class="syntax-keyword">this</span>, <span class="syntax-keyword">null</span>);
jsert.<span class="syntax-func">passWhenNotNull</span>(<span class="syntax-keyword">this</span>, <span class="syntax-string">"Valid data"</span>);</code></pre>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-3xl p-8 shadow-sm">
<h3 class="text-xl font-bold mb-3 text-indigo-600">passWhenTypeIs(test, actual, expectedType)</h3>
<p class="text-slate-600 mb-6">Checks data type. Supports "array" as a specific type.</p>
<div class="code-block bg-slate-900 rounded-xl p-6 overflow-x-auto">
<pre
class="text-sm font-mono text-slate-300"><code>jsert.<span class="syntax-func">passWhenTypeIs</span>(<span class="syntax-keyword">this</span>, [<span class="syntax-string">1, 2, 3</span>], <span class="syntax-string">"array"</span>);</code></pre>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-3xl p-8 shadow-sm">
<h3 class="text-xl font-bold mb-3 text-indigo-600">passWhenHasLength(test, collection, length)</h3>
<p class="text-slate-600 mb-6">Validates the length of an array or string.</p>
<div class="code-block bg-slate-900 rounded-xl p-6 overflow-x-auto">
<pre
class="text-sm font-mono text-slate-300"><code>jsert.<span class="syntax-func">passWhenHasLength</span>(<span class="syntax-keyword">this</span>, <span class="syntax-string">"Jsert"</span>, <span class="syntax-string">5</span>);</code></pre>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-3xl p-8 shadow-sm">
<h3 class="text-xl font-bold mb-3 text-indigo-600">passWhenIncludes(test, array, item)</h3>
<p class="text-slate-600 mb-6">Checks if an array contains a specific item.</p>
<div class="code-block bg-slate-900 rounded-xl p-6 overflow-x-auto">
<pre
class="text-sm font-mono text-slate-300"><code>jsert.<span class="syntax-func">passWhenIncludes</span>(<span class="syntax-keyword">this</span>, [<span class="syntax-string">"js"</span>, <span class="syntax-string">"ts"</span>], <span class="syntax-string">"js"</span>);</code></pre>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-3xl p-8 shadow-sm">
<h3 class="text-xl font-bold mb-3 text-indigo-600">passWhenEmpty(test, collection)</h3>
<p class="text-slate-600 mb-6">Passes if the collection length is zero.</p>
<div class="code-block bg-slate-900 rounded-xl p-6 overflow-x-auto">
<pre
class="text-sm font-mono text-slate-300"><code>jsert.<span class="syntax-func">passWhenEmpty</span>(<span class="syntax-keyword">this</span>, []);</code></pre>
</div>
</div>
<div class="bg-white border border-slate-200 rounded-3xl p-8 shadow-sm">
<h3 class="text-xl font-bold mb-3 text-indigo-600">passWhenMatch(test, obj1, obj2)</h3>
<p class="text-slate-600 mb-6">Performs a deep equality match for objects and arrays.</p>
<div class="code-block bg-slate-900 rounded-xl p-6 overflow-x-auto">
<pre
class="text-sm font-mono text-slate-300"><code>jsert.<span class="syntax-func">passWhenMatch</span>(<span class="syntax-keyword">this</span>, {a: <span class="syntax-string">1</span>}, {a: <span class="syntax-string">1</span>});</code></pre>
</div>
</div>
</div>
</main>
<footer class="bg-white border-t border-slate-200 py-12 px-6">
<div class="max-w-6xl mx-auto flex flex-col md:flex-row justify-between items-center gap-6">
<div class="flex items-center gap-2">
<div class="w-6 h-6 bg-slate-300 rounded flex items-center justify-center text-white text-xs font-bold">
J</div>
<span class="font-bold text-slate-400 uppercase tracking-widest text-sm">Jsert Library</span>
</div>
<p class="text-slate-400 text-sm">
© 2026 Joseph Morukhuladi. MIT Licensed.
</p>
<div class="flex gap-4">
<a href="https://github.com/Staviro/jsert/"
class="text-slate-400 hover:text-indigo-600 transition-colors">Github</a>
</div>
</div>
</footer>
<script src="./jsert.js"></script>
<script src="./tests.jsert.js"></script>
</body>
</html>