Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F5665599
money.test.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
money.test.ts
View Options
import
assert
from
"assert"
;
import
{
Collection
,
FieldTypes
,
Policies
}
from
"../../../main.js"
;
import
{
TestApp
}
from
"../../../test_utils/test-app.js"
;
import
{
TestAppConstructor
,
withRunningApp
}
from
"../../../test_utils/with-test-app.js"
;
function
extend
(
t
:
TestAppConstructor
)
{
return
class
extends
t
{
collections
=
{
...
TestApp
.
BaseCollections
,
wallet
:
new
(
class
extends
Collection
{
fields
=
{
simoleon
:
new
FieldTypes
.
Money
(),
};
defaultPolicy
=
new
Policies
.
Public
();
})(),
};
};
}
describe
(
"money"
,
()
=>
{
it
(
"should return two digits after the decimal separator even for integers"
,
async
()
=>
withRunningApp
(
extend
,
async
({
app
})
=>
{
await
app
.
collections
.
wallet
.
suCreate
({
simoleon
:
1
});
const
response
=
await
app
.
collections
.
wallet
.
list
(
new
app
.
SuperContext
())
.
format
({
simoleon
:
"string"
})
.
fetch
();
assert
.
strictEqual
(
response
.
items
[
0
].
get
(
"simoleon"
),
"1.00"
);
}));
it
(
"should correctly format with two decimal points float value"
,
async
()
=>
withRunningApp
(
extend
,
async
({
app
})
=>
{
await
app
.
collections
.
wallet
.
suCreate
({
simoleon
:
14.43
});
const
response
=
await
app
.
collections
.
wallet
.
list
(
new
app
.
SuperContext
())
.
format
({
simoleon
:
"string"
})
.
fetch
();
assert
.
strictEqual
(
response
.
items
[
0
].
get
(
"simoleon"
),
"14.43"
);
}));
it
(
"should correctly format with more than two decimal points float value"
,
async
()
=>
withRunningApp
(
extend
,
async
({
app
})
=>
{
await
app
.
collections
.
wallet
.
suCreate
({
simoleon
:
53.1423
});
const
response
=
await
app
.
collections
.
wallet
.
list
(
new
app
.
SuperContext
())
.
format
({
simoleon
:
"string"
})
.
fetch
();
assert
.
strictEqual
(
response
.
items
[
0
].
get
(
"simoleon"
),
"53.14"
);
}));
});
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sat, Jun 7, 23:21 (5 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
634195
Default Alt Text
money.test.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment