Skip to content

Commit

Permalink
Merge pull request #952 from gbengaoluwadahunsi/pathJS-testFunctions
Browse files Browse the repository at this point in the history
Test functions and automated git workflows testing for PathJS
  • Loading branch information
birm committed Apr 29, 2024
2 parents c0ef52b + 0e3f4ed commit 6a14d67
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
"devDependencies": {
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0"
},

"jest": {
"testEnvironment": "jest-environment-jsdom"
}

},

"jest": {
"testEnvironment": "jest-environment-jsdom"
}
}
36 changes: 36 additions & 0 deletions test/paths.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

let Path;
if (typeof Path2D === 'function' || typeof Path2D === 'object') {
Path = Path2D;
} else {
// Define a mock implementation for the Path object
Path = function() {
this.components = [];
};
Path.prototype.contains = jest.fn();
Path.prototype.stroke = jest.fn();
Path.prototype.fill = jest.fn();
Path.prototype.strokeAndFill = jest.fn();
}

describe('Path', () => {
it('should contain a contains method', () => {
const path = new Path();
expect(typeof path.contains).toBe('function');
});

it('should contain a stroke method', () => {
const path = new Path();
expect(typeof path.stroke).toBe('function');
});

it('should contain a fill method', () => {
const path = new Path();
expect(typeof path.fill).toBe('function');
});

it('should contain a strokeAndFill method', () => {
const path = new Path();
expect(typeof path.strokeAndFill).toBe('function');
});
});

0 comments on commit 6a14d67

Please sign in to comment.