-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20669 from emberjs/kg-break-deprecations-at-until-2
[FEATURE] Make deprecations throw when the `until` for `ember-source` has passed
- Loading branch information
Showing
13 changed files
with
280 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
packages/@ember/-internals/deprecations/tests/index-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
import { AbstractTestCase, moduleFor } from 'internal-test-helpers'; | ||
import { deprecateUntil, isRemoved, emberVersionGte } from '../index'; | ||
import { ENV } from '@ember/-internals/environment'; | ||
|
||
let originalEnvValue; | ||
|
||
moduleFor( | ||
'@ember/-internals/deprecations', | ||
class extends AbstractTestCase { | ||
constructor() { | ||
super(); | ||
originalEnvValue = ENV.RAISE_ON_DEPRECATION; | ||
ENV.RAISE_ON_DEPRECATION = false; | ||
} | ||
|
||
teardown() { | ||
ENV.RAISE_ON_DEPRECATION = originalEnvValue; | ||
} | ||
|
||
['@test deprecateUntil throws when deprecation has been removed'](assert) { | ||
assert.expect(1); | ||
|
||
let MY_DEPRECATION = { | ||
options: { | ||
id: 'test', | ||
until: '3.0.0', | ||
for: 'ember-source', | ||
url: 'http://example.com/deprecations/test', | ||
since: { | ||
available: '1.0.0', | ||
enabled: '1.0.0', | ||
}, | ||
}, | ||
isRemoved: true, | ||
}; | ||
|
||
assert.throws( | ||
() => deprecateUntil('Old long gone api is deprecated', MY_DEPRECATION), | ||
/Error: The API deprecated by test was removed in ember-source 3.0.0. The message was: Old long gone api is deprecated. Please see http:\/\/example.com\/deprecations\/test for more details./, | ||
'deprecateUntil throws when isRemoved is true on deprecation' | ||
); | ||
} | ||
|
||
['@test deprecateUntil does not throw when isRemoved is false on deprecation'](assert) { | ||
assert.expect(1); | ||
|
||
let MY_DEPRECATION = { | ||
options: { | ||
id: 'test', | ||
until: '3.0.0', | ||
for: 'ember-source', | ||
url: 'http://example.com/deprecations/test', | ||
since: { | ||
available: '1.0.0', | ||
enabled: '1.0.0', | ||
}, | ||
}, | ||
isRemoved: false, | ||
}; | ||
|
||
deprecateUntil('Deprecation is thrown', MY_DEPRECATION); | ||
|
||
assert.ok(true, 'exception on until was not thrown'); | ||
} | ||
['@test isRemoved is true when until has passed current ember version'](assert) { | ||
assert.expect(1); | ||
|
||
let options = { | ||
id: 'test', | ||
until: '3.0.0', | ||
for: 'ember-source', | ||
url: 'http://example.com/deprecations/test', | ||
since: { available: '1.0.0', enabled: '1.0.0' }, | ||
}; | ||
|
||
assert.strictEqual(isRemoved(options), true, 'isRemoved is true when until has passed'); | ||
} | ||
|
||
['@test isRemoved is false before until has passed current ember version'](assert) { | ||
assert.expect(1); | ||
|
||
let options = { | ||
id: 'test', | ||
until: '30.0.0', | ||
for: 'ember-source', | ||
url: 'http://example.com/deprecations/test', | ||
since: { available: '1.0.0', enabled: '1.0.0' }, | ||
}; | ||
|
||
assert.strictEqual( | ||
isRemoved(options), | ||
false, | ||
'isRemoved is false until the until has passed' | ||
); | ||
} | ||
|
||
['@test emberVersionGte returns whether the ember version is greater than or equal to the provided version']( | ||
assert | ||
) { | ||
assert.strictEqual( | ||
emberVersionGte('3.0.0', parseFloat('5.0.0')), | ||
true, | ||
'5.0.0 is after 3.0.0' | ||
); | ||
assert.strictEqual( | ||
emberVersionGte('30.0.0', parseFloat('5.0.0')), | ||
false, | ||
'5.0.0 is before 30.0.0' | ||
); | ||
assert.strictEqual( | ||
emberVersionGte('5.0.0-beta.1', parseFloat('5.0.0')), | ||
true, | ||
'5.0.0 is after 5.0.0-beta.1' | ||
); | ||
assert.strictEqual( | ||
emberVersionGte('5.0.1', parseFloat('5.0.0-beta.1')), | ||
false, | ||
'5.0.0-beta.1 is before 5.0.1' | ||
); | ||
assert.strictEqual( | ||
emberVersionGte('5.0.0-alpha.abcde', parseFloat('5.0.0')), | ||
true, | ||
'5.0.0 is after 5.0.0-alpha' | ||
); | ||
assert.strictEqual( | ||
emberVersionGte('5.9.0', parseFloat('5.8.9')), | ||
false, | ||
'5.8.9 is before 5.9.0' | ||
); | ||
assert.strictEqual( | ||
emberVersionGte('5.10.0', parseFloat('5.9.2')), | ||
true, | ||
'5.10.1 is after 5.9.2' | ||
); | ||
} | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.