Skip to content

Commit

Permalink
chore: Update isSame before after
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun committed Mar 7, 2019
1 parent 8eb5404 commit 1768305
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/plugin/badMutable/index.js
Expand Up @@ -36,18 +36,18 @@ export default (o, c) => { // locale needed later
}

const oldIsSame = proto.isSame
proto.isSame = function () {
return oldIsSame.bind(this.clone())()
proto.isSame = function (that, units) {
return oldIsSame.bind(this.clone())(that, units)
}

const oldIsBefore = proto.isBefore
proto.isBefore = function () {
return oldIsBefore.bind(this.clone())()
proto.isBefore = function (that, units) {
return oldIsBefore.bind(this.clone())(that, units)
}

const oldIsAfter = proto.isAfter
proto.isAfter = function () {
return oldIsAfter.bind(this.clone())()
proto.isAfter = function (that, units) {
return oldIsAfter.bind(this.clone())(that, units)
}
}

3 changes: 3 additions & 0 deletions test/plugin/badMutable.test.js
Expand Up @@ -167,8 +167,11 @@ it('isAfter isBefore isSame', () => {
const format = dayjs().format()
d.isSame(dayjs, 'year')
expect(d.format()).toBe(format)
expect(d.isSame()).toBe(true)
d.isBefore(dayjs, 'hour')
expect(d.format()).toBe(format)
expect(d.isBefore()).toBe(false)
d.isAfter(dayjs, 'month')
expect(d.format()).toBe(format)
expect(d.isAfter()).toBe(false)
})

0 comments on commit 1768305

Please sign in to comment.