Skip to content

Commit

Permalink
feat(client): display positions with only two decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlatz committed Apr 21, 2024
1 parent 55e0934 commit 0f9d60f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions client/app/components/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Component from '@glimmer/component';

export default class PositionComponent extends Component {
format(coordinate: number) {
const truncatedNumber = Math.trunc(coordinate * 1000) / 1000;
return truncatedNumber.toFixed(3);
const truncatedNumber = Math.trunc(coordinate * 100) / 100;
return truncatedNumber.toFixed(2);
}
}
4 changes: 2 additions & 2 deletions client/tests/acceptance/sokown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module('Acceptance | sokown', function (hooks) {
.hasText('100 km/s');
assert
.dom(screen.getByRole('definition', { name: 'Current location' }))
.hasText('3.000 3.000 Moon');
.hasText('3.00 3.00 Moon');
assert
.dom(screen.getByRole('definition', { name: 'Current destination' }))
.hasText('—');
Expand Down Expand Up @@ -116,7 +116,7 @@ module('Acceptance | sokown', function (hooks) {
assert.strictEqual(currentURL(), '/ships/1');
assert
.dom(screen.getByRole('definition', { name: 'Current destination' }))
.hasText('17.000 23.000');
.hasText('17.00 23.00');
});

test('visiting /user/profile', async function (assert) {
Expand Down
4 changes: 2 additions & 2 deletions client/tests/integration/components/position-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ module('Integration | Component | position', function (hooks) {
// then
assert
.dom(screen.getByRole('definition', { name: 'Coordinate X' }))
.hasText('1.234');
.hasText('1.23');
assert
.dom(screen.getByRole('definition', { name: 'Coordinate Y' }))
.hasText('9.800');
.hasText('9.80');
});

test('it displays an hyphen if position is null', async function (assert) {
Expand Down

0 comments on commit 0f9d60f

Please sign in to comment.