Skip to content

Commit dc65cf0

Browse files
committed
init
0 parents  commit dc65cf0

File tree

4 files changed

+125
-0
lines changed

4 files changed

+125
-0
lines changed

.gitignore

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Node.js
2+
node_modules/
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Jest Coverage
8+
coverage/
9+
10+
# Jest cache
11+
jest-cache/
12+
jest-debug.log
13+
14+
# Logs
15+
*.log
16+
*.log.*
17+
logs/
18+
pids/
19+
*.pid
20+
*.seed
21+
*.pid.lock
22+
23+
# Dependency directories
24+
node_modules/
25+
26+
# OS or Editor directories
27+
.DS_Store
28+
Thumbs.db
29+
.vscode/
30+
.idea/
31+
32+
# Temporary files
33+
*.tmp
34+
*.temp
35+
36+
# Environment variables
37+
.env
38+
.env.local
39+
.env.development.local
40+
.env.test.local
41+
.env.production.local
42+
43+
# Ignore output of tests
44+
*.out
45+
*.test-out
46+
47+
# Ignore generated configuration files
48+
package-lock.json
49+
yarn.lock

index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const CupertinoPane = require('cupertino-pane');
2+
let pane;
3+
4+
function initializePane() {
5+
pane = new CupertinoPane('.pane');
6+
return true;
7+
}
8+
9+
async function presentPane() {
10+
await pane.present();
11+
if (pane.rendered) {
12+
return true;
13+
}
14+
}
15+
16+
async function destroyPane() {
17+
await pane.destroy();
18+
if (!pane.rendered) {
19+
return true;
20+
}
21+
}
22+
23+
module.exports = {
24+
initializePane,
25+
presentPane,
26+
destroyPane
27+
};

index.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { initializePane, presentPane, destroyPane } = require('./index');
2+
3+
beforeEach(() => {
4+
// Set up a DOM element for CupertinoPane to target
5+
document.body.innerHTML = '<div class="pane"></div>';
6+
});
7+
8+
beforeAll(() => {
9+
global.CSS = {
10+
supports: () => true, // or any other method required
11+
};
12+
});
13+
14+
test('Initialize pane', () => {
15+
expect(initializePane()).toBe(true);
16+
});
17+
18+
test('Present pane', async () => {
19+
initializePane(); // Initialize the pane first
20+
const result = await presentPane();
21+
expect(result).toBe(true);
22+
});
23+
24+
test('Destroy pane', async () => {
25+
initializePane(); // Initialize the pane first
26+
await presentPane();
27+
const result = await destroyPane();
28+
expect(result).toBe(true);
29+
});

package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "panejs-jest-test",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "jest"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"jest": {
12+
"testEnvironment": "jsdom"
13+
},
14+
"license": "ISC",
15+
"devDependencies": {
16+
"cupertino-pane": "^1.4.21",
17+
"jest": "^29.7.0",
18+
"jest-environment-jsdom": "^29.7.0"
19+
}
20+
}

0 commit comments

Comments
 (0)