Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3893743
url.subtest.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
url.subtest.ts
View Options
import
assert
from
"assert"
;
import
{
Collection
,
FieldTypes
,
SuperContext
}
from
"../../../main"
;
import
{
assertThrowsAsync
}
from
"../../../test_utils/assert-throws-async"
;
import
{
TestApp
}
from
"../../../test_utils/test-app"
;
import
{
TestAppConstructor
,
withRunningApp
}
from
"../../../test_utils/with-test-app"
;
import
type
{
UrlParams
}
from
"./url"
;
const
create_app_with_url
=
(
test_app
:
TestAppConstructor
<
TestApp
>
,
params
:
UrlParams
)
=>
{
const
website
=
new
(
class
extends
Collection
{
fields
=
{
url
:
new
FieldTypes
.
Url
(
params
),
};
})();
return
class
extends
test_app
{
collections
=
{
...
TestApp
.
BaseCollections
,
website
,
};
};
};
describe
(
"url"
,
()
=>
{
it
(
"should be able to create any url when no options provided"
,
async
()
=>
{
return
withRunningApp
(
(
test_app
)
=>
create_app_with_url
(
test_app
,
{}),
async
({
app
})
=>
{
const
wb
=
await
app
.
collections
.
website
.
create
(
new
SuperContext
(
app
),
{
url
:
"https://example.com/"
,
});
assert
.
strictEqual
(
"https://example.com/"
,
wb
.
get
(
"url"
));
}
);
});
it
(
"should throw exception when domain is not allowed"
,
async
()
=>
{
return
withRunningApp
(
(
test_app
)
=>
create_app_with_url
(
test_app
,
{
allowed_origins
:
[
"https://www.youtube.com"
]
}),
async
({
app
})
=>
{
await
assertThrowsAsync
(
async
()
=>
{
await
app
.
collections
.
website
.
create
(
new
SuperContext
(
app
),
{
url
:
"https://example.com/"
,
});
});
}
);
});
it
(
"should throw exception when protocol is not allowed"
,
async
()
=>
{
return
withRunningApp
(
(
test_app
)
=>
create_app_with_url
(
test_app
,
{
allowed_protocols
:
[
"https"
]
}),
async
({
app
})
=>
{
await
assertThrowsAsync
(
async
()
=>
{
await
app
.
collections
.
website
.
create
(
new
SuperContext
(
app
),
{
url
:
"http://example.com/"
,
});
});
}
);
});
});
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Mon, May 19, 00:53 (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
634924
Default Alt Text
url.subtest.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment