diff --git a/src/components/aboutme.vue b/src/components/aboutme.vue new file mode 100755 index 0000000..2d42e3d --- /dev/null +++ b/src/components/aboutme.vue @@ -0,0 +1,32 @@ + + + + + diff --git a/src/me.js b/src/me.js new file mode 100755 index 0000000..3c59fe6 --- /dev/null +++ b/src/me.js @@ -0,0 +1,21 @@ +module.exports = { + age: age, +}; + +function age() { + let birthdate = new Date(2002, 8, 29); + let now = new Date(); + + let age = now.getFullYear() - birthdate.getFullYear(); + + if (now.getMonth() < birthdate.getMonth()) { + age--; + } + if ( + birthdate.getMonth() === now.getMonth() && + now.getDate() < birthdate.getDate() + ) { + age--; + } + return age; +} diff --git a/test/me.js b/test/me.js new file mode 100755 index 0000000..9a6358d --- /dev/null +++ b/test/me.js @@ -0,0 +1,10 @@ +const assert = require("chai").assert; +const me = require("../src/me"); + +describe("me", () => { + describe("age", () => { + it("should return a positive number", () => { + assert.isAbove(me.age(), 0); + }); + }); +});