Skip to content

Commit 1708b70

Browse files
committed
Initialize tests
1 parent 87a8efe commit 1708b70

6 files changed

Lines changed: 4929 additions & 601 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.env
22
node_modules
3-
.vscode
3+
.vscode
4+
coverage/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ commtrackr.init({ // Initialize CommTracker with configurations
7979
label: 'Website Name', // Field label
8080
description: 'The name of the website or project.', // Field description
8181
placeholder: 'e.g. My Website', // Placeholder text for the field
82-
required: true // Whether the field is required
82+
required: true, // Whether the field is required
8383
options: [ // Options for select or radio fields
8484
{
8585
label: 'Option 1', // Option label

index.test.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const commtrackr = require('./index.js');
2+
3+
async function commTrackrHandler(data) {
4+
return data;
5+
};
6+
7+
commtrackr.on();
8+
9+
describe('CommTrackr Backend Initialization', () => {
10+
test('on', () => {
11+
expect(typeof commtrackr.on).toBe('function');
12+
expect(() => commtrackr.on()).not.toThrow();
13+
});
14+
test('init', () => {
15+
expect(typeof commtrackr.init).toBe('function');
16+
expect(() => commtrackr.init({
17+
tenant: {
18+
slug: 'commtrackr',
19+
name: 'CommTrackr',
20+
description: 'Testing',
21+
logo: 'http://localhost:3000/logo.png',
22+
domain: 'http://localhost:3000',
23+
path: '/commissions',
24+
auth: {
25+
enabled: true,
26+
provider: 'Test Authentication Provider',
27+
url: '/login'
28+
},
29+
},
30+
vars: {
31+
userId: 'id',
32+
name: 'name',
33+
access: {
34+
var: 'access',
35+
user: [0],
36+
dev: [1],
37+
admin: [2]
38+
},
39+
},
40+
fields: ['text', 'number', 'date', 'textarea', 'checkbox', 'radio', 'select'].flatMap(fieldType => [
41+
{
42+
id: `test-${fieldType}`,
43+
type: fieldType,
44+
label: fieldType,
45+
description: 'description',
46+
placeholder: 'placeholder',
47+
required: false
48+
},
49+
{
50+
id: `test-${fieldType}-required`,
51+
type: fieldType,
52+
label: fieldType,
53+
description: 'description',
54+
placeholder: 'placeholder',
55+
required: true
56+
}
57+
]),
58+
handler: commTrackrHandler,
59+
})).not.toThrow();
60+
});
61+
test('handler', async () => {
62+
expect(typeof commTrackrHandler).toBe('function');
63+
const result = await commTrackrHandler({ test: 'data' });
64+
expect(typeof result).toBe('object');
65+
expect(result).toHaveProperty('test', 'data');
66+
});
67+
});

jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
testEnvironment: 'node',
3+
collectCoverage: false,
4+
coverageDirectory: 'coverage',
5+
testMatch: ['**/*.test.js'],
6+
verbose: true
7+
};

0 commit comments

Comments
 (0)