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

#668 remove custom stringify function in test #670

Merged
merged 5 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## main

### ✨ Features and improvements
- remove custom `stringify` function in test [#668](https://github.com/maplibre/maplibre-style-spec/issues/668))
HarelM marked this conversation as resolved.
Show resolved Hide resolved
- _...Add new stuff here..._

### 🐞 Bug fixes
Expand Down
3 changes: 1 addition & 2 deletions test/integration/expression/expression.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import ExpressionParsingError from '../../../src/expression/parsing_error';
import {Result} from '../../../src/util/result';
import {getGeometry} from '../../lib/geometry';
import {stringify} from '../../lib/util';
import {deepEqual, stripPrecision} from '../../lib/json-diff';

const DECIMAL_SIGNIFICANT_FIGURES = 6;
Expand Down Expand Up @@ -52,7 +51,7 @@ describe('expression', () => {
delete fixture.metadata;

const fname = path.join(__dirname, expressionTestFileName);
fs.writeFileSync(fname, `${stringify(fixture)}\n`);
fs.writeFileSync(fname, JSON.stringify(fixture, null, 2));
return;
}

Expand Down
15 changes: 0 additions & 15 deletions test/lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import compactStringify from 'json-stringify-pretty-compact';
import Color from '../../src/util/color';

/**
Expand Down Expand Up @@ -27,17 +26,3 @@ export function expectToMatchColor(toTest: Color, expectedSerialized: string, nu
export function expectCloseToArray(toTest: number[], expected: number[], numDigits = 5) {
expect(toTest).toEqual(expected.map(n => isNaN(n) ? n : expect.closeTo(n, numDigits)));
}

// we have to handle this edge case here because we have test fixtures for this
// edge case, and we don't want UPDATE=1 to mess with them
export function stringify(v) {
let s = compactStringify(v);

if (s.indexOf('\u2028') >= 0) {
s = s.replace(/\u2028/g, '\\u2028');
}
if (s.indexOf('\u2029') >= 0) {
s = s.replace(/\u2029/g, '\\u2029');
}
return s;
}