Skip to content

Commit

Permalink
Add unit test for issue #7336.
Browse files Browse the repository at this point in the history
Legacy function conversion is covered by the expression test suite, but the serialization code it uses for testing against fixtures hides extraneous `Literal` expressions.
  • Loading branch information
ChrisLoer authored and ryanhamley committed Sep 26, 2018
1 parent db39099 commit beae7b7
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/unit/style-spec/migrate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,50 @@ t('converts token strings to expressions', (t) => {
t.end();
});

t('converts stop functions to expressions', (t) => {
const migrated = migrate({
version: 8,
layers: [{
id: '1',
type: 'background',
paint: {
'background-opacity': {
base: 1.0,
stops: [[0, 1], [10, 0.72]]
}
}
}, {
id: '2',
type: 'background',
paint: {
'background-opacity': {
base: 1.0,
stops: [[0, [1, 2]], [10, [0.72, 0.98]]]
}
}
}]
}, spec.latest.$version);
t.deepEqual(migrated.layers[0].paint['background-opacity'], [
'interpolate',
['exponential', 1],
['zoom'],
0,
1,
10,
0.72
]);
t.deepEqual(migrated.layers[1].paint['background-opacity'], [
'interpolate',
['exponential', 1],
['zoom'],
0,
['literal', [1, 2]],
10,
['literal', [0.72, 0.98]]
]);
t.end();
});

glob.sync(`${__dirname}/fixture/v7-migrate/*.input.json`).forEach((file) => {
t(path.basename(file), (t) => {
const outputfile = file.replace('.input', '.output');
Expand Down

0 comments on commit beae7b7

Please sign in to comment.