Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix edge case of since query (fix #646) #647

Merged
merged 1 commit into from Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -209,7 +209,8 @@ function filterByYear(since, context) {
var data = byName(name, context)
if (!data) return selected
var versions = Object.keys(data.releaseDate).filter(function (v) {
return data.releaseDate[v] >= since
var date = data.releaseDate[v]
return date !== null && date >= since
})
return selected.concat(versions.map(nameMapper(data.name)))
}, [])
Expand Down
13 changes: 11 additions & 2 deletions test/since.test.js
Expand Up @@ -14,6 +14,15 @@ beforeEach(() => {
2: 1483228800, // Sun, 01 Jan 2017 00:00:00 +0000
3: 1485907200 // Wed, 01 Feb 2017 00:00:00 +0000
}
},
safari: {
name: 'safari',
versions: ['TP'],
released: [],
releaseDate: {
1: 1451606400, // Fri, 01 Jan 2016 00:00:00 +0000
TP: null // unreleased
}
}
}
console.warn = function (...args) {
Expand All @@ -28,11 +37,11 @@ afterEach(() => {
})

it('selects versions released on year boundaries', () => {
expect(browserslist('since 1970')).toEqual(['ie 3', 'ie 2', 'ie 1'])
expect(browserslist('since 1970')).toEqual(['ie 3', 'ie 2', 'ie 1', 'safari 1'])
})

it('is case insensitive', () => {
expect(browserslist('Since 1970')).toEqual(['ie 3', 'ie 2', 'ie 1'])
expect(browserslist('Since 1970')).toEqual(['ie 3', 'ie 2', 'ie 1', 'safari 1'])
})

it('selects versions released on year and month boundaries', () => {
Expand Down