See the code (using bundle.js)
-// Drop `TopMarksDevelopment` in CJS
-new TopMarksDevelopment.Autocomplete('#aC1', {
+new TopMarksDevelopment.Autocomplete('#aC1', {
source: () => [
{
type: 'My type one',
@@ -72,8 +71,7 @@ As above (+ onOpen match width)
See the code (using bundle.js)
-// Drop `TopMarksDevelopment` in CJS
-new TopMarksDevelopment.Autocomplete('#aC2', {
+new TopMarksDevelopment.Autocomplete('#aC2', {
source: () => [
{
type: 'My type one',
@@ -106,8 +104,7 @@ String array as source
See the code (using bundle.js)
-// Drop `TopMarksDevelopment` in CJS
-new TopMarksDevelopment.Autocomplete('#aC3', {
+new TopMarksDevelopment.Autocomplete('#aC3', {
source: [
"String 1",
"String 2",
@@ -122,8 +119,7 @@ As above (+ autoFocus)
See the code (using bundle.js)
-// Drop `TopMarksDevelopment` in CJS
-new TopMarksDevelopment.Autocomplete('#aC4', {
+new TopMarksDevelopment.Autocomplete('#aC4', {
source: [
"String 1",
"String 2",
@@ -139,8 +135,7 @@ Redirect on itemSelect with { link }
See the code (using bundle.js)
-// Drop `TopMarksDevelopment` in CJS
-new TopMarksDevelopment.Autocomplete('#aC5', {
+new TopMarksDevelopment.Autocomplete('#aC5', {
source: () => [
{
value: 'TopMarksDevelopment.com',
@@ -160,8 +155,7 @@ With a URL source
See the code (using bundle.js)
-// Drop `TopMarksDevelopment` in CJS
-new TopMarksDevelopment.Autocomplete('#aC6', {
+new TopMarksDevelopment.Autocomplete('#aC6', {
source: './tests/testdata.json'
}).start();
@@ -203,7 +197,6 @@ With a URL source
// AC - example 2
//===============
- // Drop `TopMarksDevelopment` in CJS
new TopMarksDevelopment.Autocomplete('#aC2', {
source: () => [
{
@@ -235,7 +228,6 @@ With a URL source
// AC - example 3
//===============
- // Drop `TopMarksDevelopment` in CJS
new TopMarksDevelopment.Autocomplete('#aC3', {
source: [
"String 1",
@@ -249,7 +241,6 @@ With a URL source
// AC - example 4
//===============
- // Drop `TopMarksDevelopment` in CJS
new TopMarksDevelopment.Autocomplete('#aC4', {
source: [
"String 1",
@@ -264,7 +255,6 @@ With a URL source
// AC - example 5
//===============
- // Drop `TopMarksDevelopment` in CJS
new TopMarksDevelopment.Autocomplete('#aC5', {
source: () => [
{
@@ -283,10 +273,9 @@ With a URL source
// AC - example 6
//===============
- // Drop `TopMarksDevelopment` in CJS
new TopMarksDevelopment.Autocomplete('#aC6', {
source: './testdata.json'
}).start();
}
-
+
diff --git a/tests/index.test.ts b/tests/index.test.ts
index d8d8095..75f07f5 100644
--- a/tests/index.test.ts
+++ b/tests/index.test.ts
@@ -1,9 +1,9 @@
import { Autocomplete, AutocompleteStatus } from '../src/index';
-describe('testing index file', () => {
+describe('Core Tests', () => {
let inputEL: HTMLInputElement, autocomplete: Autocomplete;
- describe('Setup Tes Env', () => {
+ describe('Test environment:-', () => {
it('has added element', () => {
inputEL = document.createElement('input');
@@ -35,24 +35,27 @@ describe('testing index file', () => {
});
});
- test('Initial state = stopped', () =>
- expect(autocomplete.status).toBe(AutocompleteStatus.Stopped));
+ describe('Upon init/start:-', () => {
+ it('the initial state is "stopped"', () =>
+ expect(autocomplete.status).toBe(AutocompleteStatus.Stopped));
- describe('Starting', () => {
- it('should not throw', () => expect(autocomplete.start).not.toThrow());
+ it('"starting" should not throw', () =>
+ expect(autocomplete.start).not.toThrow());
- it('state = started', () =>
+ it('the new state should be "started"', () =>
expect(autocomplete.status).toBe(AutocompleteStatus.Started));
- });
- describe('After Start: bound element', () => {
- it('has id', () => expect(inputEL.dataset.acId).toBeDefined());
- it('has event', () =>
+ it('the input has the AC id', () =>
+ expect(inputEL.dataset.acId).toBeDefined());
+
+ it('the input has the focus event', () =>
expect(inputEL.dispatchEvent(new Event('focus'))).toBe(true));
});
- describe('Searching', () => {
- it('creates ', () => {
+ describe('Searching ensures :-', () => {
+ let ul: HTMLUListElement;
+
+ it('is created', () => {
const was = document.body.childElementCount;
inputEL.value = 'Test Value';
@@ -60,12 +63,8 @@ describe('testing index file', () => {
expect(document.body.childElementCount).not.toEqual(was);
});
- });
-
- describe('New ', () => {
- let ul: HTMLUListElement;
- it('has correct id', () => {
+ it('has the correct id', () => {
ul =
(document.getElementById(
inputEL.dataset.acId ?? '',
@@ -78,7 +77,7 @@ describe('testing index file', () => {
it("isn't hidden", () => expect(ul.hidden).toBe(false));
- it('has position', () => {
+ it('has position data', () => {
// Will be 0, as Jest does no rendering
expect(ul.style.top).toBeDefined();
});